Flutter 颤振从步进器文本字段获取数据
如何从步进文本字段获取数据。。。无论字段是什么,总是返回null。在本例中,我使用电子邮件进行测试。我遵循Aseem Wangoo的这一方法,该方法似乎出现在以下链接中:。并用于我的解决方案,如下所示:Flutter 颤振从步进器文本字段获取数据,flutter,dart,Flutter,Dart,如何从步进文本字段获取数据。。。无论字段是什么,总是返回null。在本例中,我使用电子邮件进行测试。我遵循Aseem Wangoo的这一方法,该方法似乎出现在以下链接中:。并用于我的解决方案,如下所示: List<GlobalKey<FormState>> formKeys = [GlobalKey<FormState>(), GlobalKey<FormState>()]; class MyData { String _password;
List<GlobalKey<FormState>> formKeys = [GlobalKey<FormState>(), GlobalKey<FormState>()];
class MyData {
String _password;
String _email;
String _name;
String _lastname;
}
class _SigninState extends State<Signin> {
GlobalKey<FormState> _formKey = GlobalKey<FormState>();
static var _focusNode = FocusNode();
static MyData data = new MyData();
@override
void initState() {
super.initState();
_focusNode.addListener(() {
setState(() {});
print('Has focus: $_focusNode.hasFocus');
});
}
@override
void dispose() {
_focusNode.dispose();
super.dispose();
}
List<Step> steps = [
Step(
title: const Text('Crear cuenta'),
isActive: true,
state: StepState.indexed,
content: Form(
key: formKeys[0],
child: Column(
children: <Widget>[
TextFormField(
focusNode: _focusNode,
autocorrect: false,
onSaved: (String value) {
data._email = value;
},
maxLines: 1,
keyboardType: TextInputType.emailAddress,
validator: (value) {
if (value.isEmpty || value.length < 1) {
return 'Please enter name';
}
},
decoration: InputDecoration(labelText: 'Correo electrónico'),
),
TextFormField(
validator: (value) {
if (value.isEmpty) {
return 'Ingrese su contraseña';
}
return null;
},
obscureText: true,
autocorrect: false,
onSaved: (String value) {
data._password = value;
},
decoration: InputDecoration(labelText: 'Contraseña'),
),
],
),
)
),
Step(
isActive: true,
state: StepState.indexed,
title: const Text('Nombre y Apellido'),
content: Form(
key: formKeys[1],
child: Column(
children: <Widget>[
TextFormField(
onSaved: (String value) {
data._name = value;
},
autocorrect: false,
decoration: InputDecoration(labelText: 'Nombre'),
),
TextFormField(
onSaved: (String value) {
data._password = value;
},
autocorrect: false,
decoration: InputDecoration(labelText: 'Apellido'),
),
],
),
)
),
];
int currentStep = 0;
bool complete = false;
next() {
currentStep + 1 != steps.length
? goTo(currentStep + 1)
: setState(() => complete = true);
}
cancel() {
if (currentStep > 0) {
goTo(currentStep - 1);
}
}
goTo(int step) {
setState(() => currentStep = step);
}
@override
Widget build(BuildContext context) {
return Scaffold(
resizeToAvoidBottomInset: false,
body: Stack(children: <Widget>[
Container(
height: double.infinity,
width: double.infinity,
decoration: BoxDecoration(
gradient: LinearGradient(
begin: Alignment.topCenter,
end: Alignment.bottomCenter,
colors: [
MustardColor,
FlanColor,
FlanLightColor
],
stops: [0.1, 0.9, 1.5]
)
)
),
Container(
height: 180.0,
width: 320.0,
child: Image.asset('assets/images/crypto.png'),
margin: const EdgeInsets.only(left: 50.0, right: 50.0, top: 20.0, bottom: 50.0),
),
Center(child:
Container(
height: 480.0,
width: 320.0,
margin: const EdgeInsets.only(top: 100.0),
decoration: BoxDecoration(
color: FlanLightColor,
borderRadius: BorderRadius.circular(25)
),
)
),
Container(
height: 80.0,
width: 200.0,
child: Text('Regístrate',
textAlign: TextAlign.center,
style: TextStyle(
fontFamily: 'Montserrat',
fontSize: 30,
fontWeight: FontWeight.w600
),
),
margin: const EdgeInsets.only(left: 120.0, right: 120.0, top: 180.0, bottom: 100.0),
),
// STEPPER
Center(
child: Container(
margin: const EdgeInsets.only(top: 100),
height: 380.0,
width: 300.0,
child: Form(
key: _formKey,
child:
Column(
children: <Widget>[
Expanded(
child: Stepper(
steps: steps,
currentStep: currentStep,
onStepContinue: next,
onStepTapped: (step) => goTo(step),
onStepCancel: cancel,
controlsBuilder: (BuildContext context,
{VoidCallback onStepContinue, VoidCallback onStepCancel}) {
return Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
SizedBox(
height: 80.0,
),
FlatButton(
color: MustardColor,
onPressed: currentStep == 0 ? onStepContinue : () async {
onStepContinue();
// save the fields..
final FormState formState = _formKey.currentState;
if (!formState.validate()) {
print('Please enter correct data');
} else {
formState.save();
print("Email: ${data._email}"); // THIS RETURNS Email: Null
}
},
child: currentStep == 0 ? const Text('SIGUIENTE') : const Text('FINALIZAR'),
),
FlatButton(
color: GoldColor,
onPressed: onStepCancel,
child: const Text('CANCELAR'),
),
],
);
},
)
),
])
)
))
],)
);
}
}
List formKeys=[GlobalKey(),GlobalKey()];
类MyData{
字符串\u密码;
字符串\u电子邮件;
字符串\u名称;
字符串_lastname;
}
类_SigninState扩展状态{
GlobalKey _formKey=GlobalKey();
静态变量_focusNode=focusNode();
静态MyData数据=新的MyData();
@凌驾
void initState(){
super.initState();
_focusNode.addListener(){
setState((){});
打印('Has focus:$\u focusNode.hasFocus');
});
}
@凌驾
无效处置(){
_focusNode.dispose();
super.dispose();
}
列出步骤=[
台阶(
标题:常量文本('Crear cuenta'),
是的,
状态:StepState.index,
内容:表格(
关键字:formKeys[0],
子:列(
儿童:[
TextFormField(
focusNode:_focusNode,
自动更正:错误,
onSaved:(字符串值){
数据。_email=值;
},
maxLines:1,
键盘类型:TextInputType.emailAddress,
验证器:(值){
if(value.isEmpty | value.length<1){
返回“请输入姓名”;
}
},
装饰:输入装饰(标签文字:“Correo Electroónico”),
),
TextFormField(
验证器:(值){
if(value.isEmpty){
返回“Ingree su contraseña”;
}
返回null;
},
蒙昧文字:对,
自动更正:错误,
onSaved:(字符串值){
数据。_密码=值;
},
装饰:输入装饰(标签文字:“Contraseña”),
),
],
),
)
),
台阶(
是的,
状态:StepState.index,
标题:const Text(“Nombre y Apellido”),
内容:表格(
key:formkey[1],
子:列(
儿童:[
TextFormField(
onSaved:(字符串值){
数据。_name=值;
},
自动更正:错误,
装饰:输入装饰(标签文本:“Nombre”),
),
TextFormField(
onSaved:(字符串值){
数据。_密码=值;
},
自动更正:错误,
装饰:输入装饰(labelText:“Apellido”),
),
],
),
)
),
];
int currentStep=0;
bool complete=false;
下一个(){
当前步长+1!=步长。长度
?转到(当前步骤+1)
:setState(()=>complete=true);
}
取消{
如果(当前步骤>0){
转到(当前步骤-1);
}
}
转到(整数步){
设置状态(()=>currentStep=step);
}
@凌驾
小部件构建(构建上下文){
返回脚手架(
resizeToAvoidBottomInset:false,
主体:堆栈(子对象:[
容器(
高度:双无限,
宽度:double.infinity,
装饰:盒子装饰(
梯度:线性梯度(
开始:Alignment.topCenter,
结束:对齐。底部中心,
颜色:[
MustardColor,
弗兰科,
浅色
],
停止:[0.1,0.9,1.5]
)
)
),
容器(
高度:180.0,
宽度:320.0,
子级:Image.asset('assets/images/crypto.png'),
边距:仅限常量边集(左:50.0,右:50.0,顶部:20.0,底部:50.0),
),
中心(儿童:
容器(
身高:480.0,
宽度:320.0,
边距:仅限常量边集(顶部:100.0),
装饰:盒子装饰(
颜色:FlanLightColor,
边界半径:边界半径。圆形(25)
),
)
),
容器(
身高:80.0,
宽度:200.0,
child:Text('Regístrate',
textAlign:textAlign.center,
样式:TextStyle(
fontFamily:“蒙特塞拉特”,
尺寸:30,
fontWeight:fontWeight.w600
),
),
边距:仅限常量边集(左:120.0,右:120.0,顶部:180.0,底部:100.0),
),
//步进机
居中(
子:容器(
边距:仅限常量边集(顶部:100),
身高:380.0,
宽度:300.0,
孩子:表格(
键:_formKey,
儿童:
纵队(
儿童:[
扩大(
孩子:步进机(
步骤:步骤,
currentStep:currentStep,
onStepContinue:下一步,
onStepTapped:(步骤)=>转到(步骤),
onStepCancel:取消,
controlsBuilder:(BuildContext上下文,
{VoidCallback onStepContinue,VoidCallback onStepCancel}){
返回行(
mainAxisAlignment:mainAxisAlignment.spaceBetween,
儿童:[
大小盒子(
身高:80.0,
@override
void initState() {
...
steps = [
Step(
onStepContinue: () {
setState(() {
if (formKeys[currentStep].currentState.validate()) {
if (currentStep < steps.length - 1) {
currentStep = currentStep + 1;
} else {
currentStep = 0;
}
}
});
},
import 'package:flutter/material.dart';
void main() {
runApp(MyApp());
}
class MyApp extends StatefulWidget {
@override
State<StatefulWidget> createState() {
return MyAppScreenMode();
}
}
class MyData {
String _password;
String _email;
String _name;
String _lastname;
}
class MyAppScreenMode extends State<MyApp> {
@override
Widget build(BuildContext context) {
return MaterialApp(
theme: ThemeData(
primarySwatch: Colors.lightGreen,
),
home: Scaffold(
appBar: AppBar(
title: Text('Steppers'),
),
body: Signin(),
));
}
}
class Signin extends StatefulWidget {
@override
_SigninState createState() => _SigninState();
}
class _SigninState extends State<Signin> {
List<GlobalKey<FormState>> formKeys = [
GlobalKey<FormState>(),
GlobalKey<FormState>()
];
static var _focusNode = FocusNode();
static MyData data = new MyData();
List<Step> steps;
@override
void initState() {
super.initState();
_focusNode.addListener(() {
setState(() {});
print('Has focus: $_focusNode.hasFocus');
});
steps = [
Step(
title: const Text('Crear cuenta'),
isActive: true,
state: StepState.indexed,
content: Form(
key: formKeys[0],
child: Column(
children: <Widget>[
TextFormField(
focusNode: _focusNode,
autocorrect: false,
onSaved: (String value) {
data._email = value;
},
maxLines: 1,
keyboardType: TextInputType.emailAddress,
validator: (value) {
if (value.isEmpty || value.length < 1) {
return 'Please enter name';
}
},
decoration: InputDecoration(labelText: 'Correo electrónico'),
),
TextFormField(
validator: (value) {
if (value.isEmpty) {
return 'Ingrese su contraseña';
}
return null;
},
obscureText: true,
autocorrect: false,
onSaved: (String value) {
data._password = value;
},
decoration: InputDecoration(labelText: 'Contraseña'),
),
],
),
)),
Step(
isActive: true,
state: StepState.indexed,
title: const Text('Nombre y Apellido'),
content: Form(
key: formKeys[1],
child: Column(
children: <Widget>[
TextFormField(
onSaved: (String value) {
data._name = value;
print("save $data._name");
},
autocorrect: false,
decoration: InputDecoration(labelText: 'Nombre'),
),
TextFormField(
onSaved: (String value) {
data._lastname = value;
print("save $data._lastname");
},
autocorrect: false,
decoration: InputDecoration(labelText: 'Apellido'),
),
],
),
)),
];
}
@override
void dispose() {
_focusNode.dispose();
super.dispose();
}
int currentStep = 0;
bool complete = false;
next() {
currentStep + 1 != steps.length
? goTo(currentStep + 1)
: setState(() => complete = true);
}
cancel() {
if (currentStep > 0) {
goTo(currentStep - 1);
}
}
goTo(int step) {
setState(() => currentStep = step);
}
@override
Widget build(BuildContext context) {
return Scaffold(
resizeToAvoidBottomInset: false,
body: Stack(
children: <Widget>[
Container(
height: double.infinity,
width: double.infinity,
decoration: BoxDecoration(
gradient: LinearGradient(
begin: Alignment.topCenter,
end: Alignment.bottomCenter,
colors: [Colors.white, Colors.white, Colors.white],
stops: [0.1, 0.9, 1.5]))),
Container(
height: 180.0,
width: 320.0,
child: Image.network('https://picsum.photos/250?image=9'),
margin: const EdgeInsets.only(
left: 50.0, right: 50.0, top: 20.0, bottom: 50.0),
),
Center(
child: Container(
height: 480.0,
width: 320.0,
margin: const EdgeInsets.only(top: 100.0),
decoration: BoxDecoration(
//color: FlanLightColor,
borderRadius: BorderRadius.circular(25)),
)),
Container(
height: 80.0,
width: 200.0,
child: Text(
'Regístrate',
textAlign: TextAlign.center,
style: TextStyle(
fontFamily: 'Montserrat',
fontSize: 30,
fontWeight: FontWeight.w600),
),
margin: const EdgeInsets.only(
left: 120.0, right: 120.0, top: 180.0, bottom: 100.0),
),
// STEPPER
Center(
child: Container(
margin: const EdgeInsets.only(top: 100),
height: 380.0,
width: 300.0,
child: Column(children: <Widget>[
Expanded(
child: Stepper(
steps: steps,
currentStep: currentStep,
onStepContinue: () {
setState(() {
if (formKeys[currentStep].currentState.validate()) {
currentStep + 1 != steps.length
? goTo(currentStep + 1)
: setState(() => complete = true);
}
});
},
onStepTapped: (step) => goTo(step),
onStepCancel: cancel,
controlsBuilder: (BuildContext context,
{VoidCallback onStepContinue,
VoidCallback onStepCancel}) {
return Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
SizedBox(
height: 80.0,
),
FlatButton(
//color: MustardColor,
onPressed: currentStep == 0
? onStepContinue
: () async {
onStepContinue();
print(currentStep);
formKeys[currentStep]
.currentState
.save();
print(
"Email: ${data._email}");
print(
"name: ${data._name}");
print(
"lastname: ${data._lastname}");// THIS RETURNS Email: Null
},
child: currentStep == 0
? const Text('SIGUIENTE')
: const Text('FINALIZAR'),
),
FlatButton(
//color: GoldColor,
onPressed: onStepCancel,
child: const Text('CANCELAR'),
),
],
);
},
)),
])))
],
));
}
}
class _SigninState extends State<Signin> {
GlobalKey<FormState> _formKey = GlobalKey<FormState>();
static var _focusNode = FocusNode();
static MyData data = new MyData();
static TextEditingController _emailController = new TextEditingController();
static TextEditingController _passwordController = new TextEditingController();
static TextEditingController _nameController = new TextEditingController();
static TextEditingController _lastnameController = new TextEditingController();
@override
void initState() {
super.initState();
_focusNode.addListener(() {
setState(() {});
print('Has focus: $_focusNode.hasFocus');
});
}
@override
void dispose() {
_focusNode.dispose();
super.dispose();
}
List<Step> steps = [
Step(
title: const Text('Crear cuenta'),
isActive: true,
state: StepState.indexed,
content: Form(
key: formKeys[0],
child: Column(
children: <Widget>[
TextFormField(
focusNode: _focusNode,
autocorrect: false,
onSaved: (String value) {
data._email = value;
},
maxLines: 1,
keyboardType: TextInputType.emailAddress,
validator: (value) {
if (value.isEmpty || value.length < 1) {
return 'Please enter name';
}
},
controller: _emailController,
decoration: InputDecoration(labelText: 'Correo electrónico'),
),
TextFormField(
validator: (value) {
if (value.isEmpty) {
return 'Ingrese su contraseña';
}
return null;
},
obscureText: true,
autocorrect: false,
onSaved: (String value) {
data._password = value;
},
controller: _passwordController,
decoration: InputDecoration(labelText: 'Contraseña'),
),
],
),
)
),
Step(
isActive: true,
state: StepState.indexed,
title: const Text('Nombre y Apellido'),
content: Form(
key: formKeys[1],
child: Column(
children: <Widget>[
TextFormField(
onSaved: (String value) {
data._name = value;
},
autocorrect: false,
controller: _nameController,
decoration: InputDecoration(labelText: 'Nombre'),
),
TextFormField(
onSaved: (String value) {
data._password = value;
},
controller: _passwordController,
autocorrect: false,
decoration: InputDecoration(labelText: 'Apellido'),
),
],
),
)
),
];
int currentStep = 0;
bool complete = false;
next() {
currentStep + 1 != steps.length
? goTo(currentStep + 1)
: setState(() => complete = true);
}
cancel() {
if (currentStep > 0) {
goTo(currentStep - 1);
}
}
goTo(int step) {
setState(() => currentStep = step);
}
@override
Widget build(BuildContext context) {
return Scaffold(
resizeToAvoidBottomInset: false,
body: Stack(children: <Widget>[
Container(
height: double.infinity,
width: double.infinity,
decoration: BoxDecoration(
gradient: LinearGradient(
begin: Alignment.topCenter,
end: Alignment.bottomCenter,
colors: [
Colors.blueAccent,
Colors.amber,
Colors.red
],
stops: [0.1, 0.9, 1.5]
)
)
),
Container(
height: 180.0,
width: 320.0,
child: Image.asset('assets/images/crypto.png'),
margin: const EdgeInsets.only(left: 50.0, right: 50.0, top: 20.0, bottom: 50.0),
),
Center(child:
Container(
height: 480.0,
width: 320.0,
margin: const EdgeInsets.only(top: 100.0),
decoration: BoxDecoration(
color: Colors.cyan,
borderRadius: BorderRadius.circular(25)
),
)
),
Container(
height: 80.0,
width: 200.0,
child: Text('Regístrate',
textAlign: TextAlign.center,
style: TextStyle(
fontFamily: 'Montserrat',
fontSize: 30,
fontWeight: FontWeight.w600
),
),
margin: const EdgeInsets.only(left: 120.0, right: 120.0, top: 180.0, bottom: 100.0),
),
// STEPPER
Center(
child: Container(
margin: const EdgeInsets.only(top: 100),
height: 380.0,
width: 300.0,
child: Form(
key: _formKey,
child:
Column(
children: <Widget>[
Expanded(
child: Stepper(
steps: steps,
currentStep: currentStep,
onStepContinue: next,
onStepTapped: (step) => goTo(step),
onStepCancel: cancel,
controlsBuilder: (BuildContext context,
{VoidCallback onStepContinue, VoidCallback onStepCancel}) {
return Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
SizedBox(
height: 80.0,
),
FlatButton(
color: Colors.green,
onPressed: currentStep == 0 ? onStepContinue : () async {
onStepContinue();
// save the fields..
final FormState formState = _formKey.currentState;
if (!formState.validate()) {
print('Please enter correct data');
} else {
formState.save();
print("Email: ${_emailController.value.text}"); // THIS RETURNS Email: Null
}
},
child: currentStep == 0 ? const Text('SIGUIENTE') : const Text('FINALIZAR'),
),
FlatButton(
color: Colors.amber,
onPressed: onStepCancel,
child: const Text('CANCELAR'),
),
],
);
},
)
),
])
)
))
],)
);
}
}
import 'package:firebase_auth/firebase_auth.dart';
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
import '../../styles/colors.dart';
import '../../api/auth.dart';
import '../../views/calc/calc.dart';
class Signin extends StatefulWidget {
Signin({Key key}) : super(key: key);
_SigninState createState() => _SigninState();
}
class _SigninState extends State<Signin> {
static TextEditingController _emailController = new TextEditingController();
static TextEditingController _passwordController = new TextEditingController();
static TextEditingController _nameController = new TextEditingController();
static TextEditingController _lastnameController = new TextEditingController();
List<GlobalKey<FormState>> formKeys = [
GlobalKey<FormState>(),
GlobalKey<FormState>()
];
List<Step> steps;
@override
void initState() {
super.initState();
steps = [
Step(
title: const Text('Crear cuenta'),
isActive: currentStep == 0 ? true : false,
state: StepState.indexed,
content: Form(
key: formKeys[0],
child: Column(
children: <Widget>[
TextFormField(
autocorrect: false,
controller: _emailController,
maxLines: 1,
keyboardType: TextInputType.emailAddress,
validator: (value) {
if (value.isEmpty || value.length < 1) {
return 'Ingrese su correo';
}
},
decoration: InputDecoration(labelText: 'Correo electrónico'),
),
TextFormField(
validator: (value) {
if (value.isEmpty) {
return 'Ingrese su contraseña';
}
return null;
},
obscureText: true,
autocorrect: false,
controller: _passwordController,
decoration: InputDecoration(labelText: 'Contraseña'),
),
],
),
)),
Step(
isActive: currentStep == 1 ? true : false,
state: StepState.indexed,
title: const Text('Nombre y Apellido'),
content: Form(
key: formKeys[1],
child: Column(
children: <Widget>[
TextFormField(
autocorrect: false,
controller: _nameController,
validator: (value) {
if (value.isEmpty) {
return 'Ingrese su nombre';
}
return null;
},
decoration: InputDecoration(labelText: 'Nombre'),
),
TextFormField(
autocorrect: false,
controller: _lastnameController,
validator: (value) {
if (value.isEmpty) {
return 'Ingrese su apellido';
}
return null;
},
decoration: InputDecoration(labelText: 'Apellido'),
),
],
),
)),
];
}
int currentStep = 0;
bool complete = false;
cancel() {
if (currentStep > 0) {
goTo(currentStep - 1);
}
}
goTo(int step) {
setState(() => currentStep = step);
}
_submitDetails() async {
final FormState formState = formKeys[currentStep].currentState;
if (formState.validate()) {
formState.save();
print('email');
print(_emailController.value.text);
print('nombre completo');
print(_nameController.value.text + ' ' + _lastnameController.value.text);
try {
FirebaseUser result = await Provider.of<AuthService>(context).createUser(
email: _emailController.value.text,
password: _passwordController.value.text,
firstName: _nameController.value.text,
lastName: _lastnameController.value.text
);
print('result:');
print(result);
if(result.email == _emailController.value.text){
Navigator.push(
context,
MaterialPageRoute(builder: (context) => Calc()),
);
}
} on AuthException catch (error) {
return _buildErrorDialog(context, error.message);
} on Exception catch (error) {
return _buildErrorDialog(context, error.toString());
}
}
}
@override
Widget build(BuildContext context) {
return Scaffold(
resizeToAvoidBottomInset: false,
body: Stack(children: <Widget>[
Container(
height: double.infinity,
width: double.infinity,
decoration: BoxDecoration(
gradient: LinearGradient(
begin: Alignment.topCenter,
end: Alignment.bottomCenter,
colors: [
MustardColor,
FlanColor,
FlanLightColor
],
stops: [0.1, 0.9, 1.5]
)
)
),
Container(
height: 180.0,
width: 320.0,
child: Image.asset('assets/images/crypto.png'),
margin: const EdgeInsets.only(left: 50.0, right: 50.0, top: 20.0, bottom: 50.0),
),
Center(child:
Container(
height: 480.0,
width: 320.0,
margin: const EdgeInsets.only(top: 100.0),
decoration: BoxDecoration(
color: FlanLightColor,
borderRadius: BorderRadius.circular(25)
),
)
),
Container(
height: 80.0,
width: 200.0,
child: Text('Regístrate',
textAlign: TextAlign.center,
style: TextStyle(
fontFamily: 'Montserrat',
fontSize: 30,
fontWeight: FontWeight.w600
),
),
margin: const EdgeInsets.only(left: 120.0, right: 120.0, top: 180.0, bottom: 100.0),
),
// STEPPER
Center(
child: Container(
margin: const EdgeInsets.only(top: 100),
height: 380.0,
width: 300.0,
child: Column(children: <Widget>[
Expanded(
child: Stepper(
steps: steps,
currentStep: currentStep,
onStepContinue: () {
setState(() {
if (formKeys[currentStep].currentState.validate()) {
print('steps lenght');
print(steps.length);
print('current step');
print(currentStep);
print('eval');
print(currentStep < steps.length - 1);
if (currentStep < steps.length - 1) {
currentStep = currentStep + 1;
} else {
setState(() => complete = true);
_submitDetails();
}
}
});
},
onStepTapped: (step) => goTo(step),
onStepCancel: cancel,
controlsBuilder: (BuildContext context,
{VoidCallback onStepContinue,
VoidCallback onStepCancel}) {
return Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
SizedBox(
height: 80.0,
),
FlatButton(
color: MustardColor,
onPressed: onStepContinue,
child: complete ? const Text('REGISTRAR') : const Text('SIGUIENTE'),
),
FlatButton(
color: GoldColor,
onPressed: onStepCancel,
child: const Text('CANCELAR'),
),
],
);
},
)),
])))
],)
);
}
}
Future _buildErrorDialog(BuildContext context, _message) {
return showDialog(
builder: (context) {
return AlertDialog(
title: Text('Error'),
content: Text(_message),
actions: <Widget>[
FlatButton(
child: Text('Cancelar'),
onPressed: () {
Navigator.of(context).pop();
})
],
);
},
context: context,
);
}