Created
May 20, 2018 17:38
-
-
Save slightfoot/4bd20ccdff6ddf6c30256c0f78090b61 to your computer and use it in GitHub Desktop.
Flutter Stepper Example
This file contains hidden or 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
import 'package:flutter/material.dart'; | |
class MyApp extends StatefulWidget { | |
@override | |
_MyAppState createState() => new _MyAppState(); | |
} | |
class _MyAppState extends State<MyApp> { | |
int _currentStep = 0; | |
@override | |
Widget build(BuildContext context) { | |
return new MaterialApp( | |
title: 'App', | |
home: new Scaffold( | |
appBar: new AppBar(title: new Text('App')), | |
body: new Stepper( | |
type: StepperType.horizontal, | |
currentStep: _currentStep, | |
onStepTapped: (int step) => setState(() => _currentStep = step), | |
onStepContinue: _currentStep < 2 ? () => setState(() => _currentStep += 1) : null, | |
onStepCancel: _currentStep > 0 ? () => setState(() => _currentStep -= 1) : null, | |
steps: <Step>[ | |
new Step( | |
title: new Text('Shipping'), | |
content: new Text('This is the first step.'), | |
isActive: _currentStep >= 0, | |
state: _currentStep >= 0 ? StepState.complete : StepState.disabled, | |
), | |
new Step( | |
title: new Text('Payment'), | |
content: new Text('This is the second step.'), | |
isActive: _currentStep >= 0, | |
state: _currentStep >= 1 ? StepState.complete : StepState.disabled, | |
), | |
new Step( | |
title: new Text('Order'), | |
content: new Text('This is the third step.'), | |
isActive: _currentStep >= 0, | |
state: _currentStep >= 2 ? StepState.complete : StepState.disabled, | |
), | |
], | |
), | |
), | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Wrap Stepper inside Expanded, and wrap Expanded inside Container