【发布时间】:2022-11-13 22:10:46
【问题描述】:
【问题讨论】:
-
你是在尊重步骤吗?你能包括你到目前为止尝试过的东西吗?
-
我对颤动很陌生。我已经开始了,但无法弄清楚。
-
尝试
Stepper小部件,但可能会错过渐变 ui。您可能需要使用 Custompaint 创建小部件
标签: flutter
【问题讨论】:
Stepper 小部件,但可能会错过渐变 ui。您可能需要使用 Custompaint 创建小部件
标签: flutter
您可以使用Stepper 小部件。您也可以查看im_stepper 包。
Stepper的文档示例
class MyStatefulWidget extends StatefulWidget {
const MyStatefulWidget({super.key});
@override
State<MyStatefulWidget> createState() => _MyStatefulWidgetState();
}
class _MyStatefulWidgetState extends State<MyStatefulWidget> {
int _index = 0;
@override
Widget build(BuildContext context) {
return Stepper(
currentStep: _index,
onStepCancel: () {
if (_index > 0) {
setState(() {
_index -= 1;
});
}
},
onStepContinue: () {
if (_index <= 0) {
setState(() {
_index += 1;
});
}
},
onStepTapped: (int index) {
setState(() {
_index = index;
});
},
steps: <Step>[
Step(
title: const Text('Step 1 title'),
content: Container(
alignment: Alignment.centerLeft,
child: const Text('Content for Step 1')),
),
const Step(
title: Text('Step 2 title'),
content: Text('Content for Step 2'),
),
],
);
}
}
【讨论】: