Created
March 5, 2018 21:55
-
-
Save anilcancakir/25d7777dde8199fb1a79b1d0c04f56e2 to your computer and use it in GitHub Desktop.
How to use dynamic home page in Flutter? - main
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/pages/home.page.dart'; | |
import 'package:app/pages/login.page.dart'; | |
import 'package:app/services/auth.service.dart'; | |
import 'package:flutter/material.dart'; | |
AuthService appAuth = new AuthService(); | |
void main() async { | |
// Set default home. | |
Widget _defaultHome = new LoginPage(); | |
// Get result of the login function. | |
bool _result = await appAuth.login(); | |
if (_result) { | |
_defaultHome = new HomePage(); | |
} | |
// Run app! | |
runApp(new MaterialApp( | |
title: 'App', | |
home: _defaultHome, | |
routes: <String, WidgetBuilder>{ | |
// Set routes for using the Navigator. | |
'/home': (BuildContext context) => new HomePage(), | |
'/login': (BuildContext context) => new LoginPage() | |
}, | |
)); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment