本文介绍了如何在Flutter中从GitHub添加软件包?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要使用软件包的最新源代码,而最新源尚未发布.要在Github中获得软件包,我应该写什么 pubspec.yaml ?
I need to use the latest source code of a package and the latest source hasn't been published yet.What should I write into pubspec.yaml
to get a package in Github?
下面的代码不起作用.它不会下载该软件包,也无法将其导入到我的源代码中
The code below doesn't work. It doesn't download the package and I can't import it into my source code
dependencies:
flutter:
sdk: flutter
carousel_pro:
git:
url: https://github.com/jlouage/flutter-carousel-pro.git
推荐答案
pubsec.yaml
dependencies:
flutter:
sdk: flutter
carousel_pro:
git:
url: git://github.com/jlouage/flutter-carousel-pro.git
ref: main
导入包的文件示例
import 'package:carousel_pro/src/carousel_pro_widgets.dart';
import 'package:flutter/material.dart';
class NewsCarousel extends StatelessWidget {
@override
Widget build(BuildContext context) {
return SizedBox(
height: 200.0,
child: WidgetCarousel(
autoplay: false,
pages: [],
),
);
}
}
注意:如果您的IDE找不到软件包,请尝试重新启动它.
Note: If your IDE doesn't see the package, try to restart it.
这篇关于如何在Flutter中从GitHub添加软件包?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!