Created
July 16, 2020 14:27
-
-
Save usimsek/f638cc5030ed6995b1d078806f89e132 to your computer and use it in GitHub Desktop.
stepper for dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class SimpleWidget extends StatefulWidget { | |
@override | |
SimpleWidgetState createState() => new SimpleWidgetState(); | |
} | |
class SimpleWidgetState extends State<SimpleWidget> { | |
int stepCounter = 0; | |
List<Step> steps = [ | |
new Step( | |
title:new Text("Step One"), | |
content: new Text("This is the first step"), | |
isActive: true, | |
), | |
new Step( | |
title:new Text("Step Two"), | |
content: new Text("This is the second step"), | |
isActive: true, | |
), | |
new Step( | |
title:new Text("Step Three"), | |
content: new Wrap( | |
spacing: 8.0, // gap between adjacent chips | |
runSpacing: 4.0, // gap between lines | |
direction: Axis.horizontal, // main axis (rows or columns) | |
children: <Widget>[ | |
new Chip( | |
label: new Text('Chips11') | |
),new Chip( | |
label: new Text('Chips12') | |
),new Chip( | |
label: new Text('Chips13') | |
),new Chip( | |
label: new Text('Chips14') | |
),new Chip( | |
label: new Text('Chips15') | |
),new Chip( | |
label: new Text('Chips16') | |
) | |
], | |
), | |
state: StepState.editing, | |
isActive: true, | |
), | |
new Step( | |
title: new Text("Step Four"), | |
content: new Text("This is the fourth step"), | |
isActive: true, | |
), | |
]; | |
@override | |
Widget build(BuildContext context) { | |
return new Container( | |
child: new Stepper( | |
currentStep: this.stepCounter, | |
steps: steps, | |
type: StepperType.vertical, | |
onStepTapped: (step) { | |
setState(() { | |
stepCounter = step; | |
}); | |
}, | |
onStepCancel: () { | |
setState(() { | |
stepCounter > 0 ? stepCounter -= 1 : stepCounter = 0; | |
}); | |
}, | |
onStepContinue: () { | |
setState(() { | |
stepCounter < steps.length - 1 ? stepCounter += 1 : stepCounter = 0; | |
}); | |
}, | |
), | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
preview