如何修改Dart代码Flutter插件? [英] How to modify plugins Dart code Flutter?

查看:764
本文介绍了如何修改Dart代码Flutter插件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发Flutter应用程序,它使用 map_view 插件。我想通过修改源代码为插件添加新功能。通过Flutter安装插件后,如何在项目中找到插件的实际源代码?

I am developing a Flutter app, and it uses map_view plugin. I want to add new functionalities to the plugin by modifying the source code. How do I find the actual source code of the plugin in my project after installing it through Flutter?

如何在Flutter中添加插件

<$ c $的依赖项将c> map_view 插件添加到 pubspec.yaml 如下,然后运行 flutter软件包获取会将其添加到项目中。
dev_dependecies:
map_view:

The dependency for map_view plugin is added to pubspec.yaml as below, then running flutter packages get will add it to the project. dev_dependecies: map_view:

推荐答案

下面是逐步在本地修改插件的步骤,插件名为: flutter_abc-0.4.1

Here is step by step of how to modify plugin locally, my plugin named: flutter_abc-0.4.1


  1. 右键单击软件包/ plugin的导入文件名,选择在Finder
    中显示或按住CMD,然后单击该文件名以转到该文件,然后右键单击文件中的任何位置,然后选择在Finder中显示。

  1. Right click on package/plugin's import file name, choose Reveal in Finder Or hold CMD + Click on that file name to go to that file, then Right click anywhere in the file and choose "Reveal in Finder".

通常它位于〜/ .pub-cache / hosted / pub.darlang.org / flutter_abc-0.4.1

将整个程序包文件夹复制到您的应用程序文件夹中

Copy whole package folder to your app folder

要轻松劫持文件,只需复制全部放入您的应用文件夹(与 pubspec.yaml 相同级别,而不在 lib 文件夹中),然后重命名版本:

For easy hijacking files, just copy all to your app folder (same level with pubspec.yaml, not in the lib folder), then renaming version:

例如: flutter_abc-0.4.1-hijacking

现在,您可以修改要在本地修复错误的任何内容。

Now you can modify whatever you want to fix bug locally.

修改pubspec.yaml以指向本地包

Modify pubspec.yaml to point to local package

打开项目pubspec.yaml
将依赖关系的路径更改为例如:

Open your project pubspec.yaml Change path of dependencies to, for example:

flutter_abc:
路径:./ flutter_abcd-0.4.1-hijacking /

这篇关于如何修改Dart代码Flutter插件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆