Skip to content

Commit 05f848b

Browse files
author
Woosignal
authored
Tweaks and bug fixes for main.dart
1 parent 303655f commit 05f848b

File tree

1 file changed

+85
-92
lines changed

1 file changed

+85
-92
lines changed

LabelStoreMax/lib/main.dart

Lines changed: 85 additions & 92 deletions
Original file line numberDiff line numberDiff line change
@@ -31,101 +31,94 @@ import 'package:label_storemax/helpers/app_themes.dart';
3131
import 'package:label_storemax/helpers/app_localizations.dart';
3232

3333
void main() async {
34-
Widget _defaultHome = new HomePage();
34+
WidgetsFlutterBinding.ensureInitialized();
35+
36+
await SystemChrome.setPreferredOrientations([
37+
DeviceOrientation.portraitUp,
38+
]);
3539

36-
SystemChrome.setPreferredOrientations([DeviceOrientation.portraitUp]).then(
37-
(_) {
38-
_defaultHome = HomePage();
40+
runApp(
41+
new MaterialApp(
42+
title: app_name,
43+
color: Colors.white,
44+
debugShowCheckedModeBanner: false,
45+
initialRoute: "/home",
46+
routes: <String, WidgetBuilder>{
47+
'/home': (BuildContext context) => new HomePage(),
48+
'/cart': (BuildContext context) => new CartPage(),
49+
'/browse-category': (BuildContext context) => new BrowseCategoryPage(),
50+
'/product-search': (BuildContext context) => new BrowseSearchPage(),
51+
'/product-detail': (BuildContext context) => new ProductDetailPage(),
52+
'/checkout': (BuildContext context) => new CheckoutConfirmationPage(),
53+
'/checkout-status': (BuildContext context) => new CheckoutStatusPage(),
54+
},
55+
onGenerateRoute: (settings) {
56+
switch (settings.name) {
57+
case '/home-menu':
58+
return PageTransition(
59+
child: HomeMenuPage(), type: PageTransitionType.leftToRight);
60+
case '/checkout-details':
61+
return PageTransition(
62+
child: CheckoutDetailsPage(),
63+
type: PageTransitionType.downToUp);
64+
case '/about':
65+
return PageTransition(
66+
child: AboutPage(), type: PageTransitionType.leftToRight);
3967

40-
runApp(
41-
new MaterialApp(
42-
title: app_name,
43-
color: Colors.white,
44-
debugShowCheckedModeBanner: false,
45-
routes: <String, WidgetBuilder>{
46-
'/home': (BuildContext context) => new HomePage(),
47-
'/cart': (BuildContext context) => new CartPage(),
48-
'/browse-category': (BuildContext context) =>
49-
new BrowseCategoryPage(),
50-
'/product-search': (BuildContext context) =>
51-
new BrowseSearchPage(),
52-
'/product-detail': (BuildContext context) =>
53-
new ProductDetailPage(),
54-
'/checkout': (BuildContext context) =>
55-
new CheckoutConfirmationPage(),
56-
'/checkout-status': (BuildContext context) =>
57-
new CheckoutStatusPage(),
58-
},
59-
onGenerateRoute: (settings) {
60-
switch (settings.name) {
61-
case '/home-menu':
62-
return PageTransition(
63-
child: HomeMenuPage(),
64-
type: PageTransitionType.leftToRight);
65-
case '/checkout-details':
66-
return PageTransition(
67-
child: CheckoutDetailsPage(),
68-
type: PageTransitionType.downToUp);
69-
case '/about':
70-
return PageTransition(
71-
child: AboutPage(), type: PageTransitionType.leftToRight);
72-
73-
case '/checkout-payment-type':
74-
return PageTransition(
75-
child: CheckoutPaymentTypePage(),
76-
type: PageTransitionType.downToUp);
68+
case '/checkout-payment-type':
69+
return PageTransition(
70+
child: CheckoutPaymentTypePage(),
71+
type: PageTransitionType.downToUp);
7772

78-
case '/checkout-shipping-type':
79-
return PageTransition(
80-
child: CheckoutShippingTypePage(),
81-
type: PageTransitionType.downToUp);
73+
case '/checkout-shipping-type':
74+
return PageTransition(
75+
child: CheckoutShippingTypePage(),
76+
type: PageTransitionType.downToUp);
8277

83-
case '/home-search':
84-
return PageTransition(
85-
child: HomeSearchPage(),
86-
type: PageTransitionType.downToUp);
87-
default:
88-
return null;
89-
}
90-
},
91-
supportedLocales: [Locale('en')],
92-
localizationsDelegates: [
93-
AppLocalizations.delegate,
94-
GlobalWidgetsLocalizations.delegate,
95-
GlobalMaterialLocalizations.delegate
96-
],
97-
localeResolutionCallback:
98-
(Locale locale, Iterable<Locale> supportedLocales) {
99-
return locale;
100-
},
101-
theme: ThemeData(
102-
primaryColor: HexColor("#2f4ffe"),
103-
backgroundColor: Colors.white,
104-
buttonTheme: ButtonThemeData(
105-
hoverColor: Colors.transparent,
106-
buttonColor: HexColor("#529cda"),
107-
colorScheme: colorSchemeButton(),
108-
minWidth: double.infinity,
109-
height: 70,
110-
shape: RoundedRectangleBorder(
111-
borderRadius: new BorderRadius.circular(5.0),
112-
),
113-
),
114-
appBarTheme: AppBarTheme(
115-
color: Colors.white,
116-
textTheme: textThemeAppBar(),
117-
elevation: 0.0,
118-
brightness: Brightness.light,
119-
iconTheme: IconThemeData(color: Colors.black),
120-
actionsIconTheme: IconThemeData(
121-
color: Colors.black,
122-
)),
123-
accentColor: Colors.black,
124-
accentTextTheme: textThemeAccent(),
125-
textTheme: textThemeMain(),
126-
primaryTextTheme: textThemePrimary()),
127-
home: _defaultHome),
128-
);
129-
},
78+
case '/home-search':
79+
return PageTransition(
80+
child: HomeSearchPage(), type: PageTransitionType.downToUp);
81+
default:
82+
return null;
83+
}
84+
},
85+
supportedLocales: [Locale('en')],
86+
localizationsDelegates: [
87+
AppLocalizations.delegate,
88+
GlobalWidgetsLocalizations.delegate,
89+
GlobalMaterialLocalizations.delegate
90+
],
91+
localeResolutionCallback:
92+
(Locale locale, Iterable<Locale> supportedLocales) {
93+
return locale;
94+
},
95+
theme: ThemeData(
96+
primaryColor: HexColor("#2f4ffe"),
97+
backgroundColor: Colors.white,
98+
buttonTheme: ButtonThemeData(
99+
hoverColor: Colors.transparent,
100+
buttonColor: HexColor("#529cda"),
101+
colorScheme: colorSchemeButton(),
102+
minWidth: double.infinity,
103+
height: 70,
104+
shape: RoundedRectangleBorder(
105+
borderRadius: new BorderRadius.circular(5.0),
106+
),
107+
),
108+
appBarTheme: AppBarTheme(
109+
color: Colors.white,
110+
textTheme: textThemeAppBar(),
111+
elevation: 0.0,
112+
brightness: Brightness.light,
113+
iconTheme: IconThemeData(color: Colors.black),
114+
actionsIconTheme: IconThemeData(
115+
color: Colors.black,
116+
)),
117+
accentColor: Colors.black,
118+
accentTextTheme: textThemeAccent(),
119+
textTheme: textThemeMain(),
120+
primaryTextTheme: textThemePrimary(),
121+
),
122+
),
130123
);
131124
}

0 commit comments

Comments
 (0)