class LoginPage extends StatefulWidget {
@override
_LoginPageState createState() => _LoginPageState();
}
class _LoginPageState extends State<LoginPage>
with SingleTickerProviderStateMixin {
static TextEditingController user = new TextEditingController();
static TextEditingController pass = new TextEditingController();
Session sesion = new Session();
@override
Widget build(BuildContext context) {
return Scaffold(
body: SafeArea(
child: ListView(
padding: EdgeInsets.symmetric(horizontal: 24.0),
children: <Widget>[
SizedBox(height: 80.0),
Container(
child: Row(children: [
Image.asset(
'assets/ucsm_plata.png',
height: 159.0,
width: 156.0,
fit: BoxFit.cover,
),
Column(
mainAxisSize: MainAxisSize.max,
children: <Widget>[
Text('Universidad Catolica'),
Text("de Santa Maria")
],
)
]),
),
SizedBox(height: 60.0),
PrimaryColorOverride(
color: color_icono,
child: TextField(
controller: user,
maxLength: 8,
decoration: InputDecoration(
hintText: 'Username',
icon: new Icon(
Icons.portrait,
color: Colors.grey,
)),
),
),
SizedBox(height: 12.0),
PrimaryColorOverride(
color: color_icono,
child: TextField(
controller: pass,
maxLength: 32,
decoration: InputDecoration(
hintText: 'Password',
icon: new Icon(
Icons.lock,
color: Colors.grey,
)),
obscureText: true,
),
),
SizedBox(height: 20.0),
Column(
children: <Widget>[
Container(
margin: EdgeInsets.all(16.0),
child: ProgressButton(),
),
FlatButton(
child: Text('Olvide mi clave'),
shape: BeveledRectangleBorder(
borderRadius: BorderRadius.all(Radius.circular(7.0)),
),
onPressed: () {
user.clear();
pass.clear();
},
),
],
),
],
),
),
);
} }
I use this code for an animated flutter button I have a login which uses this button, as this button is defined in another file to be able to reuse it I need to be able to access its onpresedd method to send it a function and when the function finishes finishing the animation
This is the function is a post that is defined in another file
class Session {
String url = "http://10.0.2.2/Class_php/Coneccion.php";
postData(String user, String pass) async {
try {
http.Response response =
await http.post(url, body: {"CNRODNI": user, "CCLAVE": pass});
var data = json.decode(response.body);
String results = data.toString();
if (response.statusCode == 200) {
print(results);
} else {
print("Failed http call.");
}
} catch (exception) {
print(exception.toString());
}
}