I need to use datosusuario variable in another file how can I do this?
My main.dart is a Login I need use the query result variable to print that result in my homepage Widget
Main.dart
class LoginStates extends State<Login>{
@override
Widget build(BuildContext context) {
TextEditingController user=new TextEditingController();
TextEditingController pass=new TextEditingController();
Future<List> _login() async{
final response =await
http.post("https://exclinico.com/admin/FlutterClases/login.php", body: {
"correo": user.text,
"password": pass.text,
});
print(response.body);
var datosusuario = json.decode(response.body);
if (datosusuario.length==0) {
//print("$nombre");
}
else{
//print("$nombre");
}
}
I need to use datosusuario variable in the drawer info.
Home.dart
return new Scaffold(
appBar: new AppBar(
centerTitle: true,
title: new Image.asset("assets/LOGO.png"),
backgroundColor: Colors.blue,
),
drawer: new Drawer(
child: new ListView(
children: <Widget>[
new UserAccountsDrawerHeader(
accountName: new Text("Eduardo"),
accountEmail: new Text("eduardo.hernandez@Utacapñulco.edu.mx"),
currentAccountPicture: new CircleAvatar(
backgroundColor: Colors.white,
child: new Text("E"),
),),