0
I’m doing a project where the user has to choose one of the languages below and then click the "finish" button. However, as I would navigate between screens, if there are three possible screens that the "finish" button can go, according to the user’s choice?
import 'package:flutter/material.dart';
import 'package:projeto_tcc/Tela_Principal.dart';
class Tela_Idioma extends StatefulWidget {
@override
_Tela_IdiomaState createState() => _Tela_IdiomaState();
void _abrirTela_Principal(){
BuildContext context;
Navigator.push(
context,
MaterialPageRoute(builder: (context)=> Tela_Principal() ));
}
}
class _Tela_IdiomaState extends State<Tela_Idioma> {
String _escolhaUsuario;
void _Lingua( String escolha){
setState(() {
_escolhaUsuario = escolha;
print("escolha" + _escolhaUsuario);
switch(_escolhaUsuario){
case "espanhol" :
break;
case "coreano" :
break;
case "ingles" :
break;
}
});
}
@override
Widget build(BuildContext context) {
Size size = MediaQuery.of(context).size;
return Scaffold(
backgroundColor: Colors.white,
body: Container(
child: SingleChildScrollView(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[
Container(
height: 592,
padding: EdgeInsets.fromLTRB(30, 0 , 30, 30),
decoration: BoxDecoration(
image: DecorationImage(
image: AssetImage("Imagens/Fundo login.jpg"),
fit: BoxFit.fill
)
),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[
Padding(
padding: EdgeInsets.fromLTRB(20, 50, 20, 10),
child: Image.asset(
"Imagens/Coreano.jpg",
width: 500,
height: 50,
),
),
Container(
child: Padding(
padding: EdgeInsets.fromLTRB(50, 0, 0, 0),
child: RadioListTile(
title: Text("Coreano"),
activeColor: Color(0xff5CE6B8),
value: "coreano",
groupValue: _escolhaUsuario,
onChanged: _Lingua,
),
),
),
Padding(
padding: EdgeInsets.fromLTRB(20, 0, 20, 10),
child: Image.asset(
"Imagens/Espanhol.jpg",
width: 500,
height: 53,
),
),
Padding(
padding: EdgeInsets.fromLTRB(50, 0, 0, 0),
child: RadioListTile(
title: Text("Espanhol"),
activeColor: Color(0xff5CE6B8),
value: "espanhol",
groupValue: _escolhaUsuario,
onChanged: _Lingua,
),
),
Padding(
padding: EdgeInsets.fromLTRB(20, 0, 20, 10),
child: Image.asset(
"Imagens/Ingles.jpg",
width: 500,
height: 43,
),
),
Padding(
padding: EdgeInsets.fromLTRB(50, 0, 0, 0),
child: RadioListTile(
title: Text("Inglês"),
activeColor: Color(0xff5CE6B8),
value: "ingles",
groupValue: _escolhaUsuario,
onChanged: _Lingua,
),
),
Padding(
padding: EdgeInsets.only(top: 10),
child: RaisedButton(
shape: new RoundedRectangleBorder(borderRadius:
new BorderRadius.circular(30.0)),
color: Color(0xff5CE6B8),
padding: EdgeInsets.all(17),
child: Text(
"Finalizar",
style: TextStyle(
fontSize: 16
),
),
onPressed: (){
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => Tela_Principal()
)
);
}
),
)
],
),
),
],
),
),
),
);
}
}
You already own one
switch-case
within the method_Lingua()
... Just do it the same at the click of the button and each marry you make a push for the related screen.– Matheus Ribeiro