Skip to content

Instantly share code, notes, and snippets.

@anilcancakir
Created March 5, 2018 21:49
Show Gist options
  • Select an option

  • Save anilcancakir/81730c3f3acafb092f453545448835e2 to your computer and use it in GitHub Desktop.

Select an option

Save anilcancakir/81730c3f3acafb092f453545448835e2 to your computer and use it in GitHub Desktop.
How to use dynamic home page in Flutter? - LoginPage
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