1
0
mirror of https://github.com/flutter/samples.git synced 2026-03-31 08:44:26 +00:00

Cleanup to navigation_and_routing sample (#881)

- make more things private and final, where possible
- remove unused members
- used expression bodies, where possible
This commit is contained in:
Kevin Moore
2021-08-26 09:16:27 -07:00
committed by GitHub
parent 410e43fbc1
commit fa7dec1475
20 changed files with 221 additions and 284 deletions

View File

@@ -17,11 +17,9 @@ class AuthorList extends StatelessWidget {
}) : super(key: key);
@override
Widget build(BuildContext context) {
return ListView.builder(
itemCount: authors.length,
itemBuilder: (context, index) {
return ListTile(
Widget build(BuildContext context) => ListView.builder(
itemCount: authors.length,
itemBuilder: (context, index) => ListTile(
title: Text(
authors[index].name,
),
@@ -29,8 +27,6 @@ class AuthorList extends StatelessWidget {
'${authors[index].books.length} books',
),
onTap: onTap != null ? () => onTap!(authors[index]) : null,
);
},
);
}
),
);
}

View File

@@ -17,11 +17,9 @@ class BookList extends StatelessWidget {
}) : super(key: key);
@override
Widget build(BuildContext context) {
return ListView.builder(
itemCount: books.length,
itemBuilder: (context, index) {
return ListTile(
Widget build(BuildContext context) => ListView.builder(
itemCount: books.length,
itemBuilder: (context, index) => ListTile(
title: Text(
books[index].title,
),
@@ -29,8 +27,6 @@ class BookList extends StatelessWidget {
books[index].author.name,
),
onTap: onTap != null ? () => onTap!(books[index]) : null,
);
},
);
}
),
);
}

View File

@@ -15,15 +15,14 @@ class FadeTransitionPage<T> extends Page<T> {
}) : super(key: key);
@override
Route<T> createRoute(BuildContext context) {
return PageBasedFadeTransitionRoute<T>(this);
}
Route<T> createRoute(BuildContext context) =>
PageBasedFadeTransitionRoute<T>(this);
}
class PageBasedFadeTransitionRoute<T> extends PageRoute<T> {
final FadeTransitionPage<T> page;
final FadeTransitionPage<T> _page;
PageBasedFadeTransitionRoute(this.page) : super(settings: page);
PageBasedFadeTransitionRoute(this._page) : super(settings: _page);
@override
Color? get barrierColor => null;
@@ -32,7 +31,7 @@ class PageBasedFadeTransitionRoute<T> extends PageRoute<T> {
String? get barrierLabel => null;
@override
Duration get transitionDuration => page.duration;
Duration get transitionDuration => _page.duration;
@override
bool get maintainState => true;
@@ -49,7 +48,6 @@ class PageBasedFadeTransitionRoute<T> extends PageRoute<T> {
@override
Widget buildTransitions(BuildContext context, Animation<double> animation,
Animation<double> secondaryAnimation, Widget child) {
return child;
}
Animation<double> secondaryAnimation, Widget child) =>
child;
}

View File

@@ -19,7 +19,6 @@ class LibraryScope extends InheritedWidget {
bool updateShouldNotify(LibraryScope oldWidget) =>
library != oldWidget.library;
static Library of(BuildContext context) {
return context.dependOnInheritedWidgetOfExactType<LibraryScope>()!.library;
}
static Library of(BuildContext context) =>
context.dependOnInheritedWidgetOfExactType<LibraryScope>()!.library;
}