Flutter轮播按钮插件buttons_swiper的使用
Flutter轮播按钮插件buttons_swiper的使用
Installation(安装)
- 在
pubspec.yaml文件中添加该包的最新版本,并运行flutter pub get:
dependencies:
buttons_swiper: ^0.1.0
- 导入包并在Flutter应用中使用:
import 'package:buttons_swiper/buttons_swiper.dart';
Example(示例)
以下是buttons_swiper的一些可修改属性示例:
alignementheightcircleBorderWidthcircleBorderColoronTapfirstIconsListsecondIconsListloopfadestartIndexviewportFractionscale
完整示例代码
class SwiperTest extends StatelessWidget {
const SwiperTest({Key? key}) : super(key: key);
[@override](/user/override)
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: Colors.orange,
body: Container(
child: swiper(
onTap: (index) {
// 点击时打印当前索引
print(index);
},
onSwip: (index) {
// 滑动时打印当前索引
print(index);
},
pages: [
// 轮播页面列表
Container(color: Colors.blueAccent,),
Container(color: Colors.redAccent,),
Container(color: Colors.yellow,),
],
height: 100, // 轮播的高度
alignement: Alignment.bottomCenter, // 对齐方式
circleBorderColor: Colors.white, // 圆形按钮边框颜色
secondIconsList: [
// 第二层图标列表
Text(
"BUY",
style: TextStyle(
color: Colors.red,
fontWeight: FontWeight.w900,
),
textScaleFactor: 2.0,
),
Text(
"SETUP",
style: TextStyle(
color: Colors.red,
fontWeight: FontWeight.w900,
),
textScaleFactor: 1.7,
),
Text(
"CALL",
style: TextStyle(
color: Colors.red,
fontWeight: FontWeight.w900,
),
textScaleFactor: 2.0,
),
],
firstIconsList: [
// 第一层图标列表
Icon(
Icons.monetization_on,
color: Colors.white,
size: 50,
),
Icon(
Icons.settings,
color: Colors.white,
size: 50,
),
Icon(
Icons.phone_enabled,
color: Colors.white,
size: 50,
)
],
),
),
);
}
}
更多关于Flutter轮播按钮插件buttons_swiper的使用的实战教程也可以访问 https://www.itying.com/category-92-b0.html
1 回复


