Created
March 5, 2018 21:49
-
-
Save anilcancakir/81730c3f3acafb092f453545448835e2 to your computer and use it in GitHub Desktop.
How to use dynamic home page in Flutter? - LoginPage
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import 'package:app/main.dart'; | |
| import 'package:flutter/material.dart'; | |
| class LoginPage extends StatefulWidget { | |
| @override | |
| State<StatefulWidget> createState() => new _LoginPageState(); | |
| } | |
| class _LoginPageState extends State<LoginPage> { | |
| String _status = 'no-action'; | |
| @override | |
| Widget build(BuildContext context) => new Scaffold( | |
| appBar: new AppBar( | |
| title: new Text('Login'), | |
| ), | |
| body: new Container( | |
| child: new Center( | |
| child: new RaisedButton( | |
| child: new Text( | |
| 'Login for App (${this._status})' | |
| ), | |
| onPressed: () { | |
| setState(() => this._status = 'loading'); | |
| appAuth.login().then((result) { | |
| if (result) { | |
| Navigator.of(context).pushReplacementNamed('/home'); | |
| } else { | |
| setState(() => this._status = 'rejected'); | |
| } | |
| }); | |
| } | |
| ), | |
| ), | |
| ), | |
| ); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment