Skip to content

Commit

Permalink
remove kHomeRouteName
Browse files Browse the repository at this point in the history
use Navigator.defaultRouteName as home route's name
  • Loading branch information
X-Wei committed Jan 13, 2019
1 parent 5530048 commit 2b875c6
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 9 deletions.
5 changes: 2 additions & 3 deletions lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,8 @@ void main() => runApp(
MaterialApp(
title: 'Flutter Catalog',
theme: ThemeData(primarySwatch: Colors.blue),
initialRoute: my_app_meta.kHomeRouteName,
// No need to set `home` because `routes` is set, in which initialRoute
// and Navigator.defaultRouteName has an entry.
// No need to set `home` because `routes` is set to a routing table, and
// Navigator.defaultRouteName ('/') has an entry in it.
routes: my_app_meta.kRoutingTable,
),
);
2 changes: 0 additions & 2 deletions lib/my_app_meta.dart
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ const GOOGLEPLAY_URL =
const GITHUB_URL = 'https://github.com/X-Wei/flutter_catalog';
const AUTHOR_SITE = 'http://x-wei.github.io';

const kHomeRouteName = '/Home';
const kHomeRoute = MyHomeRoute();
const kAboutRoute = MyAboutRoute();

Expand Down Expand Up @@ -247,7 +246,6 @@ final kRoutenameToRouteMap = Map<String, MyRoute>.fromIterable(
{
// By default go to home screen. (Navigator.defaultRouteName is just '/')
Navigator.defaultRouteName: kHomeRoute,
kHomeRouteName: kHomeRoute,
kAboutRoute.routeName: kAboutRoute,
},
);
Expand Down
4 changes: 2 additions & 2 deletions lib/my_route.dart
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ class _MyRouteState extends State<MyRoute> with SingleTickerProviderStateMixin {
);
}),
// Only home route has drawer:
drawer: this.widget.routeName == my_app_meta.kHomeRouteName
drawer: this.widget.routeName == Navigator.defaultRouteName
? Drawer(
child: my_app_meta.getNavDrawerItems(this, context),
)
Expand All @@ -142,7 +142,7 @@ class _MyRouteState extends State<MyRoute> with SingleTickerProviderStateMixin {
List<Widget> _getAppbarActions() {
// final state = MyRouteState.of(context);
final appbarActions = <Widget>[];
if (this.widget.routeName != my_app_meta.kHomeRouteName) {
if (this.widget.routeName != Navigator.defaultRouteName) {
appbarActions.add(starStatusOfRoute(this.widget));
}
if (this.widget.links.isNotEmpty) {
Expand Down
3 changes: 1 addition & 2 deletions lib/routes/home.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import '../my_app_meta.dart'
show
BookmarkManager,
kAboutRoute,
kHomeRouteName,
kMyAppRoutesStructure,
kRoutenameToRouteMap,
kSharedPreferences,
Expand All @@ -19,7 +18,7 @@ class MyHomeRoute extends MyRoute {
get title => 'Flutter Catalog';

@override
get routeName => kHomeRouteName;
get routeName => Navigator.defaultRouteName;

@override
Widget buildMyRouteContent(BuildContext context) {
Expand Down

0 comments on commit 2b875c6

Please sign in to comment.