Skip to content

Instantly share code, notes, and snippets.

@ftvs
Forked from slightfoot/stepper.dart
Created February 3, 2020 07:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ftvs/a7d8f827d802aecec4e43a020ef6f51b to your computer and use it in GitHub Desktop.
Save ftvs/a7d8f827d802aecec4e43a020ef6f51b to your computer and use it in GitHub Desktop.
Flutter Stepper Example
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