@@ -6,6 +6,7 @@ class Index extends StatefulWidget {
66}
77
88class _IndexState extends State <Index > {
9+ int _currentStep = 0 ;
910 @override
1011 void initState () {
1112 super .initState ();
@@ -17,9 +18,57 @@ class _IndexState extends State<Index> {
1718 appBar: AppBar (
1819 title: Text ('Stepper' ),
1920 ),
20- body: Center (
21- child: Text ('更新中' ),
22- ),
21+ body: Container (
22+ padding: EdgeInsets .all (16.0 ),
23+ child: Column (
24+ mainAxisAlignment: MainAxisAlignment .center,
25+ children: < Widget > [
26+ Theme (
27+ data: Theme .of (context).copyWith (
28+ primaryColor: Colors .black
29+ ),
30+ child: Stepper (
31+ currentStep: _currentStep,
32+ onStepTapped: (int value) {
33+ setState (() {
34+ _currentStep = value;
35+ });
36+ },
37+ onStepContinue: () {
38+ setState (() {
39+ _currentStep < 2 ? _currentStep += 1 : _currentStep = 0 ;
40+ });
41+ },
42+ onStepCancel: (){
43+ setState (() {
44+ _currentStep > 0 ? _currentStep -= 1 : _currentStep = 0 ;
45+ });
46+ },
47+ steps: [
48+ Step (
49+ title: Text ('Login' ),
50+ subtitle: Text ('Login first' ),
51+ content: Text ('Confirm your information' ),
52+ isActive: _currentStep == 0
53+ ),
54+ Step (
55+ title: Text ('Choose plan' ),
56+ subtitle: Text ('Choose your plan' ),
57+ content: Text ('Confirm your information' ),
58+ isActive: _currentStep == 1
59+ ),
60+ Step (
61+ title: Text ('Confirm payment' ),
62+ subtitle: Text ('Confirm yoir payment method' ),
63+ content: Text ('Confirm your information' ),
64+ isActive: _currentStep == 2
65+ ),
66+ ],
67+ ),
68+ )
69+ ],
70+ ),
71+ )
2372 );
2473 }
2574}
0 commit comments