Flutter步进器插件easy_bi_stepper的使用
Flutter步进器插件easy_bi_stepper的使用
Easy-Bi-Stepper
Flutter 包提供了一个简单易用的双向步进器小部件。
屏幕截图
特性
- 双向步进器:提供一个允许水平和垂直步骤的步进器小部件。
- 可定制范围:用户可以指定步进器的最小值和最大值。
- 步进值:用户可以定义步进器的增量或减量步长。
- 跨平台兼容性:在所有提到的平台上无缝工作。
- 轻量级:包体积小,性能高效,以提供流畅的用户体验。
安装
要使用 Easy-Bi-Stepper
包,请遵循以下步骤:
-
在
pubspec.yaml
文件中添加包依赖:dependencies: easy_bi_stepper: <最新版本>
-
运行以下命令以获取包:
flutter pub get
-
在 Dart 代码中导入包:
import 'package:easy_bi_stepper/easy_bi_stepper.dart';
使用
要在 Flutter 应用中使用 Easy-Bi-Stepper
,请参阅以下示例:
class MyHomePage extends StatefulWidget {
const MyHomePage({super.key, required this.title});
final String title;
[@override](/user/override)
State<MyHomePage> createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
int activeIndex = 0;
[@override](/user/override)
Widget build(BuildContext context) {
List<StepperData> stepperData = [
StepperData(
title: Column(
children: [
Container(
height: 40.0,
width: 40.0,
alignment: Alignment.center,
child: const Icon(
Icons.ac_unit,
size: 36.0,
),
),
const SizedBox(
height: .0,
width: 10.0,
),
const Text("Title Goes Here",
style: TextStyle(
color: Colors.black,
fontSize: 18.0
),
),
],
),
),
// 其他步进项...
];
return Scaffold(
appBar: AppBar(
backgroundColor: Theme.of(context).colorScheme.inversePrimary,
title: Text(widget.title),
),
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
EasyBiStepper(
stepperList: stepperData,
activeBarColor: Colors.green,
activeIndex: activeIndex,
stepperDirection: Axis.vertical,
),
const SizedBox(
height: 20.0,
width: 0.0,
),
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
GestureDetector(
onTap: () {
setState(() {
activeIndex--;
});
},
child: Container(
height: 40.0,
width: 100.0,
decoration: BoxDecoration(
color: Theme.of(context).colorScheme.inversePrimary,
borderRadius: BorderRadius.circular(10.0),
),
alignment: Alignment.center,
child: const Icon(
Icons.remove,
color: Colors.white,
size: 30.0,
),
),
),
const SizedBox(
height: 0.0,
width: 30.0,
),
GestureDetector(
onTap: () {
setState(() {
activeIndex++;
});
},
child: Container(
height: 40.0,
width: 100.0,
decoration: BoxDecoration(
color: Theme.of(context).colorScheme.inversePrimary,
borderRadius: BorderRadius.circular(10.0),
),
alignment: Alignment.center,
child: const Icon(
Icons.add,
color: Colors.white,
size: 30.0,
),
),
),
],
),
],
),
),
);
}
}
更多关于Flutter步进器插件easy_bi_stepper的使用的实战教程也可以访问 https://www.itying.com/category-92-b0.html
1 回复