找到这篇文章,它似乎为使用许多pub包的分叉版本提供了足够的说明。
但是,我想要派生的包(scrollable_positioned_list(是flatter.widgets存储库的一部分,它本身不是包,而是包的集合。
我已经能够分叉和修改包,我的问题是能够在我的项目中使用我的分叉。
我尝试过显而易见的:
dependencies:
flutter:
sdk: flutter
scrollable_positioned_list:
git:
url: https://github.com/bendelonlee/flutter.widgets
这导致flutter pub get
失败,并出现错误:
pub get failed (1; Could not find a file named "pubspec.yaml" in https://github.com/bendelonlee/flutter.widgets 1f2935687390a9315c3336007a4eac00563365a4.)
事实上,该目录的根目录中没有pubspec.yaml,尽管包中嵌套了一个。
我还尝试过在存储库中使用包的url
scrollable_positioned_list:
git:
url: https://github.com/bendelonlee/flutter.widgets/tree/master/packages/scrollable_positioned_list
此操作失败,并出现一个错误,抱怨找不到存储库:
fatal: repository 'https://github.com/bendelonlee/flutter.widgets/tree/master/packages/scrollable_positioned_list/' not found
应该像官方文档所说的那样添加路径参数:
Pub假设包位于Git存储库的根目录中。要在回购中指定不同的位置,请使用路径自变量
在您的特定cace中,这将是
scrollable_positioned_list:
git:
url: https://github.com/bendelonlee/flutter.widgets
path: packages/scrollable_positioned_list