From 18375cd45f521bbce7f321f02103e5932022bef0 Mon Sep 17 00:00:00 2001 From: Aditya Shinde Date: Fri, 29 Sep 2023 16:00:15 +0530 Subject: [PATCH] Day 6 : Stateful, Animated Container, Future Delay --- flutter_catalog/lib/pages/login_page.dart | 56 ++++++++++++++++++++--- 1 file changed, 50 insertions(+), 6 deletions(-) diff --git a/flutter_catalog/lib/pages/login_page.dart b/flutter_catalog/lib/pages/login_page.dart index f9c90ac..27bea60 100644 --- a/flutter_catalog/lib/pages/login_page.dart +++ b/flutter_catalog/lib/pages/login_page.dart @@ -1,7 +1,15 @@ import 'package:flutter/material.dart'; import 'package:flutter_catalog/utils/routes.dart'; -class LoginPage extends StatelessWidget { +class LoginPage extends StatefulWidget { + @override + State createState() => _LoginPageState(); +} + +class _LoginPageState extends State { + String name = ""; + bool changedButton = false; + @override Widget build(BuildContext context) { return Material( @@ -18,7 +26,7 @@ class LoginPage extends StatelessWidget { height: 20.0, ), Text( - "Login Page", + "Wel-Come", style: TextStyle( fontSize: 22, fontWeight: FontWeight.bold, @@ -37,6 +45,10 @@ class LoginPage extends StatelessWidget { hintText: "Enter Username", labelText: "Username", ), + onChanged: (value) { + name = value; + setState(() {}); + }, ), TextFormField( obscureText: true, @@ -48,12 +60,44 @@ class LoginPage extends StatelessWidget { SizedBox( height: 20.0, ), - ElevatedButton( - child: Text("Login"), - onPressed: () { + + InkWell( + onTap: () async { + setState(() { + changedButton = true; + }); + await Future.delayed(Duration(seconds: 1)); Navigator.pushNamed(context, MyRoutes.homeRoute); }, - ) + child: AnimatedContainer( + duration: Duration(seconds: 1), + width: changedButton ? 50 : 150, + height: 50, + alignment: Alignment.center, + child: changedButton + ? Icon( + Icons.done, + color: Colors.white, + ) + : Text( + "Login", + style: TextStyle( + color: Colors.white, + fontWeight: FontWeight.bold, + fontSize: 18), + ), + decoration: BoxDecoration( + color: Colors.deepPurple, + borderRadius: BorderRadius.circular(8)), + ), + ), + + // ElevatedButton( + // child: Text("Login"), + // onPressed: () { + // Navigator.pushNamed(context, MyRoutes.homeRoute); + // }, + // ) ], ), )