-
Notifications
You must be signed in to change notification settings - Fork 104
/
Copy pathstepper.dart
61 lines (58 loc) · 1.54 KB
/
stepper.dart
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
import 'package:flutter/material.dart';
class MyStepper extends StatefulWidget {
const MyStepper({Key? key}) : super(key: key);
@override
State<MyStepper> createState() => _MyStepperState();
}
class _MyStepperState extends State<MyStepper> {
int _currentStep = 0;
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: Colors.deepPurple[100],
appBar: AppBar(title: const Text('Stepper')),
body: Center(
child: Stepper(
steps: const [
Step(
title: Text('Step 1'),
content: Text('Information for step 1'),
),
Step(
title: Text('Step 2'),
content: Text('Information for step 2'),
),
Step(
title: Text('Step 3'),
content: Text('Information for step 3'),
),
Step(
title: Text('Step 4'),
content: Text('Information for step 4'),
),
],
onStepTapped: (int newIndex) {
setState(() {
_currentStep = newIndex;
});
},
currentStep: _currentStep,
onStepContinue: () {
if (_currentStep != 3) {
setState(() {
_currentStep += 1;
});
}
},
onStepCancel: () {
if (_currentStep != 0) {
setState(() {
_currentStep = 0;
});
}
},
),
),
);
}
}