Skip to content

Instantly share code, notes, and snippets.

@slightfoot
Created May 20, 2018 17:38
Show Gist options
  • Star 17 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save slightfoot/4bd20ccdff6ddf6c30256c0f78090b61 to your computer and use it in GitHub Desktop.
Save slightfoot/4bd20ccdff6ddf6c30256c0f78090b61 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,
),
],
),
),
);
}
}
@npenalopez
Copy link

Any idea why I cannot run this code? I get a blank screen when I run in the simulator :( Thanks for sharing!!

@sprintal
Copy link

sprintal commented Jun 4, 2019

Any idea why I cannot run this code? I get a blank screen when I run in the simulator :( Thanks for sharing!!

You need to add void main() => runApp(MyApp());

@vinceramcesoliveros
Copy link

Stepper gives layout error when exceeding to more than 3 Step(s) Widget for type Horizontal

@ElasticBottle
Copy link

Stepper gives layout error when exceeding to more than 3 Step(s) Widget for type Horizontal

This is a known issue with stepper. see #40601 for more information

@RohitSharma5
Copy link

RohitSharma5 commented Jan 8, 2021

overflow issue in horizontal. it should be scrollable

@azackmatoff
Copy link

Wrap Stepper inside Expanded, and wrap Expanded inside Container

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment