Tweaks and bug fixes for main.dart

This commit is contained in:
Woosignal 2020-02-10 12:19:53 +00:00 committed by GitHub
parent 303655f220
commit 05f848b442
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -31,37 +31,32 @@ import 'package:label_storemax/helpers/app_themes.dart';
import 'package:label_storemax/helpers/app_localizations.dart'; import 'package:label_storemax/helpers/app_localizations.dart';
void main() async { void main() async {
Widget _defaultHome = new HomePage(); WidgetsFlutterBinding.ensureInitialized();
SystemChrome.setPreferredOrientations([DeviceOrientation.portraitUp]).then( await SystemChrome.setPreferredOrientations([
(_) { DeviceOrientation.portraitUp,
_defaultHome = HomePage(); ]);
runApp( runApp(
new MaterialApp( new MaterialApp(
title: app_name, title: app_name,
color: Colors.white, color: Colors.white,
debugShowCheckedModeBanner: false, debugShowCheckedModeBanner: false,
initialRoute: "/home",
routes: <String, WidgetBuilder>{ routes: <String, WidgetBuilder>{
'/home': (BuildContext context) => new HomePage(), '/home': (BuildContext context) => new HomePage(),
'/cart': (BuildContext context) => new CartPage(), '/cart': (BuildContext context) => new CartPage(),
'/browse-category': (BuildContext context) => '/browse-category': (BuildContext context) => new BrowseCategoryPage(),
new BrowseCategoryPage(), '/product-search': (BuildContext context) => new BrowseSearchPage(),
'/product-search': (BuildContext context) => '/product-detail': (BuildContext context) => new ProductDetailPage(),
new BrowseSearchPage(), '/checkout': (BuildContext context) => new CheckoutConfirmationPage(),
'/product-detail': (BuildContext context) => '/checkout-status': (BuildContext context) => new CheckoutStatusPage(),
new ProductDetailPage(),
'/checkout': (BuildContext context) =>
new CheckoutConfirmationPage(),
'/checkout-status': (BuildContext context) =>
new CheckoutStatusPage(),
}, },
onGenerateRoute: (settings) { onGenerateRoute: (settings) {
switch (settings.name) { switch (settings.name) {
case '/home-menu': case '/home-menu':
return PageTransition( return PageTransition(
child: HomeMenuPage(), child: HomeMenuPage(), type: PageTransitionType.leftToRight);
type: PageTransitionType.leftToRight);
case '/checkout-details': case '/checkout-details':
return PageTransition( return PageTransition(
child: CheckoutDetailsPage(), child: CheckoutDetailsPage(),
@ -82,8 +77,7 @@ void main() async {
case '/home-search': case '/home-search':
return PageTransition( return PageTransition(
child: HomeSearchPage(), child: HomeSearchPage(), type: PageTransitionType.downToUp);
type: PageTransitionType.downToUp);
default: default:
return null; return null;
} }
@ -123,9 +117,8 @@ void main() async {
accentColor: Colors.black, accentColor: Colors.black,
accentTextTheme: textThemeAccent(), accentTextTheme: textThemeAccent(),
textTheme: textThemeMain(), textTheme: textThemeMain(),
primaryTextTheme: textThemePrimary()), primaryTextTheme: textThemePrimary(),
home: _defaultHome), ),
); ),
},
); );
} }