diff --git a/navigation_and_routing/lib/src/app.dart b/navigation_and_routing/lib/src/app.dart index 4419264bf..1269d8846 100644 --- a/navigation_and_routing/lib/src/app.dart +++ b/navigation_and_routing/lib/src/app.dart @@ -18,12 +18,11 @@ class Bookstore extends StatefulWidget { } class _BookstoreState extends State { - final auth = BookstoreAuth(); - late final BookstoreRouteGuard guard; - late final RouteState routeState; - late final SimpleRouterDelegate routerDelegate; - late final TemplateRouteParser routeParser; - final GlobalKey navigatorKey = GlobalKey(); + final _auth = BookstoreAuth(); + final _navigatorKey = GlobalKey(); + late final RouteState _routeState; + late final SimpleRouterDelegate _routerDelegate; + late final TemplateRouteParser _routeParser; final library = Library() ..addBook( @@ -49,10 +48,10 @@ class _BookstoreState extends State { @override void initState() { - guard = BookstoreRouteGuard(auth: auth); + final guard = BookstoreRouteGuard(auth: _auth); /// Configure the parser with all of the app's allowed path templates. - routeParser = TemplateRouteParser( + _routeParser = TemplateRouteParser( allowedPaths: [ '/signin', '/authors', @@ -67,50 +66,48 @@ class _BookstoreState extends State { initialRoute: '/signin', ); - routeState = RouteState(routeParser); + _routeState = RouteState(_routeParser); - routerDelegate = SimpleRouterDelegate( - routeState: routeState, - navigatorKey: navigatorKey, + _routerDelegate = SimpleRouterDelegate( + routeState: _routeState, + navigatorKey: _navigatorKey, builder: (context) => BookstoreNavigator( - navigatorKey: navigatorKey, + navigatorKey: _navigatorKey, ), ); // Listen for when the user logs out and display the signin screen. - auth.addListener(_handleAuthStateChanged); + _auth.addListener(_handleAuthStateChanged); super.initState(); } @override - Widget build(BuildContext context) { - return RouteStateScope( - notifier: routeState, - child: BookstoreAuthScope( - notifier: auth, - child: LibraryScope( - library: library, - child: MaterialApp.router( - routerDelegate: routerDelegate, - routeInformationParser: routeParser, + Widget build(BuildContext context) => RouteStateScope( + notifier: _routeState, + child: BookstoreAuthScope( + notifier: _auth, + child: LibraryScope( + library: library, + child: MaterialApp.router( + routerDelegate: _routerDelegate, + routeInformationParser: _routeParser, + ), ), ), - ), - ); - } + ); void _handleAuthStateChanged() { - if (!auth.signedIn) { - routeState.go('/signin'); + if (!_auth.signedIn) { + _routeState.go('/signin'); } } @override void dispose() { - auth.removeListener(_handleAuthStateChanged); - routeState.dispose(); - routerDelegate.dispose(); + _auth.removeListener(_handleAuthStateChanged); + _routeState.dispose(); + _routerDelegate.dispose(); super.dispose(); } } diff --git a/navigation_and_routing/lib/src/auth/auth.dart b/navigation_and_routing/lib/src/auth/auth.dart index 7247c8fdb..70f73433d 100644 --- a/navigation_and_routing/lib/src/auth/auth.dart +++ b/navigation_and_routing/lib/src/auth/auth.dart @@ -9,9 +9,7 @@ import 'package:flutter/widgets.dart'; class BookstoreAuth extends ChangeNotifier { bool _signedIn = false; - bool get signedIn { - return _signedIn; - } + bool get signedIn => _signedIn; Future signOut() async { await Future.delayed(const Duration(milliseconds: 200)); @@ -30,9 +28,8 @@ class BookstoreAuth extends ChangeNotifier { } @override - bool operator ==(Object other) { - return other is BookstoreAuth && other._signedIn == _signedIn; - } + bool operator ==(Object other) => + other is BookstoreAuth && other._signedIn == _signedIn; @override int get hashCode => _signedIn.hashCode; @@ -45,9 +42,7 @@ class BookstoreAuthScope extends InheritedNotifier { Key? key, }) : super(key: key, notifier: notifier, child: child); - static BookstoreAuth? of(BuildContext context) { - return context - .dependOnInheritedWidgetOfExactType() - ?.notifier; - } + static BookstoreAuth? of(BuildContext context) => context + .dependOnInheritedWidgetOfExactType() + ?.notifier; } diff --git a/navigation_and_routing/lib/src/auth/auth_guard.dart b/navigation_and_routing/lib/src/auth/auth_guard.dart index aa28b9ca2..6ecbcd470 100644 --- a/navigation_and_routing/lib/src/auth/auth_guard.dart +++ b/navigation_and_routing/lib/src/auth/auth_guard.dart @@ -7,7 +7,7 @@ import 'auth.dart'; /// An implementation of [RouteGuard] that redirects to /signIn class BookstoreRouteGuard implements RouteGuard { - BookstoreAuth auth; + final BookstoreAuth auth; BookstoreRouteGuard({ required this.auth, diff --git a/navigation_and_routing/lib/src/data/library.dart b/navigation_and_routing/lib/src/data/library.dart index 8ae2c485e..72f74e2f2 100644 --- a/navigation_and_routing/lib/src/data/library.dart +++ b/navigation_and_routing/lib/src/data/library.dart @@ -32,15 +32,11 @@ class Library { allBooks.add(book); } - List get popularBooks { - return [ - ...allBooks.where((book) => book.isPopular), - ]; - } + List get popularBooks => [ + ...allBooks.where((book) => book.isPopular), + ]; - List get newBooks { - return [ - ...allBooks.where((book) => book.isNew), - ]; - } + List get newBooks => [ + ...allBooks.where((book) => book.isNew), + ]; } diff --git a/navigation_and_routing/lib/src/routing/delegate.dart b/navigation_and_routing/lib/src/routing/delegate.dart index 63be2aa2e..eb0e66987 100644 --- a/navigation_and_routing/lib/src/routing/delegate.dart +++ b/navigation_and_routing/lib/src/routing/delegate.dart @@ -28,9 +28,7 @@ class SimpleRouterDelegate extends RouterDelegate } @override - Widget build(BuildContext context) { - return builder(context); - } + Widget build(BuildContext context) => builder(context); @override Future setNewRoutePath(ParsedRoute configuration) async { @@ -39,9 +37,7 @@ class SimpleRouterDelegate extends RouterDelegate } @override - ParsedRoute get currentConfiguration { - return routeState.route; - } + ParsedRoute get currentConfiguration => routeState.route; @override void dispose() { diff --git a/navigation_and_routing/lib/src/routing/parsed_route.dart b/navigation_and_routing/lib/src/routing/parsed_route.dart index 3cca9372a..9a40ac759 100644 --- a/navigation_and_routing/lib/src/routing/parsed_route.dart +++ b/navigation_and_routing/lib/src/routing/parsed_route.dart @@ -27,13 +27,12 @@ class ParsedRoute { this.path, this.pathTemplate, this.parameters, this.queryParameters); @override - bool operator ==(Object other) { - return other is ParsedRoute && - other.pathTemplate == pathTemplate && - other.path == path && - _mapEquality.equals(parameters, other.parameters) && - _mapEquality.equals(queryParameters, other.queryParameters); - } + bool operator ==(Object other) => + other is ParsedRoute && + other.pathTemplate == pathTemplate && + other.path == path && + _mapEquality.equals(parameters, other.parameters) && + _mapEquality.equals(queryParameters, other.queryParameters); @override int get hashCode => hash4( diff --git a/navigation_and_routing/lib/src/routing/parser.dart b/navigation_and_routing/lib/src/routing/parser.dart index 17d7cf35d..1953e3428 100644 --- a/navigation_and_routing/lib/src/routing/parser.dart +++ b/navigation_and_routing/lib/src/routing/parser.dart @@ -44,9 +44,8 @@ class TemplateRouteParser extends RouteInformationParser { @override Future parseRouteInformation( - RouteInformation routeInformation) async { - return await _parse(routeInformation); - } + RouteInformation routeInformation) async => + await _parse(routeInformation); Future _parse(RouteInformation routeInformation) async { final path = routeInformation.location!; @@ -74,7 +73,6 @@ class TemplateRouteParser extends RouteInformationParser { } @override - RouteInformation restoreRouteInformation(ParsedRoute configuration) { - return RouteInformation(location: configuration.path); - } + RouteInformation restoreRouteInformation(ParsedRoute configuration) => + RouteInformation(location: configuration.path); } diff --git a/navigation_and_routing/lib/src/routing/route_state.dart b/navigation_and_routing/lib/src/routing/route_state.dart index 3c8149070..7c4de181e 100644 --- a/navigation_and_routing/lib/src/routing/route_state.dart +++ b/navigation_and_routing/lib/src/routing/route_state.dart @@ -44,9 +44,6 @@ class RouteStateScope extends InheritedNotifier { Key? key, }) : super(key: key, notifier: notifier, child: child); - static RouteState? of(BuildContext context) { - return context - .dependOnInheritedWidgetOfExactType() - ?.notifier; - } + static RouteState? of(BuildContext context) => + context.dependOnInheritedWidgetOfExactType()?.notifier; } diff --git a/navigation_and_routing/lib/src/screens/author_details.dart b/navigation_and_routing/lib/src/screens/author_details.dart index b7916bb03..abf411db1 100644 --- a/navigation_and_routing/lib/src/screens/author_details.dart +++ b/navigation_and_routing/lib/src/screens/author_details.dart @@ -17,25 +17,23 @@ class AuthorDetailsScreen extends StatelessWidget { }) : super(key: key); @override - Widget build(BuildContext context) { - return Scaffold( - appBar: AppBar( - title: Text(author.name), - ), - body: Center( - child: Column( - children: [ - Expanded( - child: BookList( - books: author.books, - onTap: (book) { - RouteStateScope.of(context)!.go('/book/${book.id}'); - }, + Widget build(BuildContext context) => Scaffold( + appBar: AppBar( + title: Text(author.name), + ), + body: Center( + child: Column( + children: [ + Expanded( + child: BookList( + books: author.books, + onTap: (book) { + RouteStateScope.of(context)!.go('/book/${book.id}'); + }, + ), ), - ), - ], + ], + ), ), - ), - ); - } + ); } diff --git a/navigation_and_routing/lib/src/screens/authors.dart b/navigation_and_routing/lib/src/screens/authors.dart index bfaff2350..94fe80780 100644 --- a/navigation_and_routing/lib/src/screens/authors.dart +++ b/navigation_and_routing/lib/src/screens/authors.dart @@ -14,17 +14,15 @@ class AuthorsScreen extends StatelessWidget { const AuthorsScreen({Key? key}) : super(key: key); @override - Widget build(BuildContext context) { - return Scaffold( - appBar: AppBar( - title: Text(title), - ), - body: AuthorList( - authors: LibraryScope.of(context).allAuthors, - onTap: (author) { - RouteStateScope.of(context)!.go('/author/${author.id}'); - }, - ), - ); - } + Widget build(BuildContext context) => Scaffold( + appBar: AppBar( + title: Text(title), + ), + body: AuthorList( + authors: LibraryScope.of(context).allAuthors, + onTap: (author) { + RouteStateScope.of(context)!.go('/author/${author.id}'); + }, + ), + ); } diff --git a/navigation_and_routing/lib/src/screens/book_details.dart b/navigation_and_routing/lib/src/screens/book_details.dart index 4b6aeb1c1..961edf8f7 100644 --- a/navigation_and_routing/lib/src/screens/book_details.dart +++ b/navigation_and_routing/lib/src/screens/book_details.dart @@ -45,21 +45,18 @@ class BookDetailsScreen extends StatelessWidget { onPressed: () { Navigator.of(context).push( MaterialPageRoute( - builder: (context) { - return AuthorDetailsScreen(author: book!.author); - }, + builder: (context) => + AuthorDetailsScreen(author: book!.author), ), ); }, ), Link( uri: Uri.parse('/author/${book!.author.id}'), - builder: (context, followLink) { - return TextButton( - onPressed: followLink, - child: const Text('View author (Link)'), - ); - }, + builder: (context, followLink) => TextButton( + onPressed: followLink, + child: const Text('View author (Link)'), + ), ), ], ), diff --git a/navigation_and_routing/lib/src/screens/books.dart b/navigation_and_routing/lib/src/screens/books.dart index 32bd8c50e..4d654a7c5 100644 --- a/navigation_and_routing/lib/src/screens/books.dart +++ b/navigation_and_routing/lib/src/screens/books.dart @@ -10,11 +10,8 @@ import '../widgets/book_list.dart'; import '../widgets/library_scope.dart'; class BooksScreen extends StatefulWidget { - final ParsedRoute currentRoute; - const BooksScreen({ Key? key, - required this.currentRoute, }) : super(key: key); @override @@ -36,7 +33,7 @@ class _BooksScreenState extends State void didChangeDependencies() { super.didChangeDependencies(); - final newPath = routeState.route.pathTemplate; + final newPath = _routeState.route.pathTemplate; if (newPath.startsWith('/books/popular')) { _tabController.index = 0; } else if (newPath.startsWith('/books/new')) { @@ -96,35 +93,23 @@ class _BooksScreenState extends State ); } - String get title { - switch (_tabController.index) { - case 1: - return 'New'; - case 2: - return 'All'; - case 0: - default: - return 'Popular'; - } - } - - RouteState get routeState => RouteStateScope.of(context)!; + RouteState get _routeState => RouteStateScope.of(context)!; void _handleBookTapped(Book book) { - routeState.go('/book/${book.id}'); + _routeState.go('/book/${book.id}'); } void _handleTabIndexChanged() { switch (_tabController.index) { case 1: - routeState.go('/books/new'); + _routeState.go('/books/new'); break; case 2: - routeState.go('/books/all'); + _routeState.go('/books/all'); break; case 0: default: - routeState.go('/books/popular'); + _routeState.go('/books/popular'); break; } } diff --git a/navigation_and_routing/lib/src/screens/navigator.dart b/navigation_and_routing/lib/src/screens/navigator.dart index 458435788..442b816da 100644 --- a/navigation_and_routing/lib/src/screens/navigator.dart +++ b/navigation_and_routing/lib/src/screens/navigator.dart @@ -30,10 +30,10 @@ class BookstoreNavigator extends StatefulWidget { } class _BookstoreNavigatorState extends State { - final signInKey = const ValueKey('Sign in'); - final scaffoldKey = const ValueKey('App scaffold'); - final bookDetailsKey = const ValueKey('Book details screen'); - final authorDetailsKey = const ValueKey('Author details screen'); + final _signInKey = const ValueKey('Sign in'); + final _scaffoldKey = const ValueKey('App scaffold'); + final _bookDetailsKey = const ValueKey('Book details screen'); + final _authorDetailsKey = const ValueKey('Author details screen'); @override Widget build(BuildContext context) { @@ -60,12 +60,12 @@ class _BookstoreNavigatorState extends State { // When a page that is stacked on top of the scaffold is popped, display // the /books or /authors tab in BookstoreScaffold. if (route.settings is Page && - (route.settings as Page).key == bookDetailsKey) { + (route.settings as Page).key == _bookDetailsKey) { routeState.go('/books/popular'); } if (route.settings is Page && - (route.settings as Page).key == authorDetailsKey) { + (route.settings as Page).key == _authorDetailsKey) { routeState.go('/authors'); } @@ -75,7 +75,7 @@ class _BookstoreNavigatorState extends State { if (routeState.route.pathTemplate == '/signin') // Display the sign in screen. FadeTransitionPage( - key: signInKey, + key: _signInKey, child: SignInScreen( onSignIn: (credentials) async { var signedIn = await authState.signIn( @@ -89,21 +89,21 @@ class _BookstoreNavigatorState extends State { else ...[ // Display the app FadeTransitionPage( - key: scaffoldKey, + key: _scaffoldKey, child: const BookstoreScaffold(), ), // Add an additional page to the stack if the user is viewing a book // or an author if (selectedBook != null) MaterialPage( - key: bookDetailsKey, + key: _bookDetailsKey, child: BookDetailsScreen( book: selectedBook, ), ) else if (selectedAuthor != null) MaterialPage( - key: authorDetailsKey, + key: _authorDetailsKey, child: AuthorDetailsScreen( author: selectedAuthor, ), diff --git a/navigation_and_routing/lib/src/screens/scaffold_body.dart b/navigation_and_routing/lib/src/screens/scaffold_body.dart index bc44a0378..b222fabf0 100644 --- a/navigation_and_routing/lib/src/screens/scaffold_body.dart +++ b/navigation_and_routing/lib/src/screens/scaffold_body.dart @@ -41,9 +41,9 @@ class BookstoreScaffoldBody extends StatelessWidget { ) else if (currentRoute.pathTemplate.startsWith('/books') || currentRoute.pathTemplate == '/') - FadeTransitionPage( - key: const ValueKey('books'), - child: BooksScreen(currentRoute: currentRoute), + const FadeTransitionPage( + key: ValueKey('books'), + child: BooksScreen(), ) // Avoid building a Navigator with an empty `pages` list when the diff --git a/navigation_and_routing/lib/src/screens/settings.dart b/navigation_and_routing/lib/src/screens/settings.dart index c0ad7d647..9927e9a46 100644 --- a/navigation_and_routing/lib/src/screens/settings.dart +++ b/navigation_and_routing/lib/src/screens/settings.dart @@ -17,26 +17,24 @@ class SettingsScreen extends StatefulWidget { class _SettingsScreenState extends State { @override - Widget build(BuildContext context) { - return Scaffold( - body: SafeArea( - child: SingleChildScrollView( - child: Align( - alignment: Alignment.topCenter, - child: ConstrainedBox( - constraints: const BoxConstraints(maxWidth: 400), - child: const Card( - child: Padding( - padding: EdgeInsets.symmetric(vertical: 18, horizontal: 12), - child: SettingsContent(), + Widget build(BuildContext context) => Scaffold( + body: SafeArea( + child: SingleChildScrollView( + child: Align( + alignment: Alignment.topCenter, + child: ConstrainedBox( + constraints: const BoxConstraints(maxWidth: 400), + child: const Card( + child: Padding( + padding: EdgeInsets.symmetric(vertical: 18, horizontal: 12), + child: SettingsContent(), + ), ), ), ), ), ), - ), - ); - } + ); } class SettingsContent extends StatelessWidget { @@ -45,57 +43,53 @@ class SettingsContent extends StatelessWidget { }) : super(key: key); @override - Widget build(BuildContext context) { - return Column( - children: [ - ...[ - Text( - 'Settings', - style: Theme.of(context).textTheme.headline4, - ), - ElevatedButton( - onPressed: () { - BookstoreAuthScope.of(context)!.signOut(); - }, - child: const Text('Sign out'), - ), - Link( - uri: Uri.parse('/book/0'), - builder: (context, followLink) { - return TextButton( + Widget build(BuildContext context) => Column( + children: [ + ...[ + Text( + 'Settings', + style: Theme.of(context).textTheme.headline4, + ), + ElevatedButton( + onPressed: () { + BookstoreAuthScope.of(context)!.signOut(); + }, + child: const Text('Sign out'), + ), + Link( + uri: Uri.parse('/book/0'), + builder: (context, followLink) => TextButton( onPressed: followLink, child: const Text('Go directly to /book/0 (Link)'), - ); - }, - ), + ), + ), + TextButton( + child: const Text('Go directly to /book/0 (RouteState)'), + onPressed: () { + RouteStateScope.of(context)!.go('/book/0'); + }, + ), + ].map((w) => Padding(padding: const EdgeInsets.all(8), child: w)), TextButton( - child: const Text('Go directly to /book/0 (RouteState)'), - onPressed: () { - RouteStateScope.of(context)!.go('/book/0'); - }, - ), - ].map((w) => Padding(padding: const EdgeInsets.all(8), child: w)), - TextButton( - onPressed: () => showDialog( - context: context, - builder: (context) => AlertDialog( - title: const Text('Alert!'), - content: const Text('The alert description goes here.'), - actions: [ - TextButton( - onPressed: () => Navigator.pop(context, 'Cancel'), - child: const Text('Cancel'), - ), - TextButton( - onPressed: () => Navigator.pop(context, 'OK'), - child: const Text('OK'), - ), - ], + onPressed: () => showDialog( + context: context, + builder: (context) => AlertDialog( + title: const Text('Alert!'), + content: const Text('The alert description goes here.'), + actions: [ + TextButton( + onPressed: () => Navigator.pop(context, 'Cancel'), + child: const Text('Cancel'), + ), + TextButton( + onPressed: () => Navigator.pop(context, 'OK'), + child: const Text('OK'), + ), + ], + ), ), - ), - child: const Text('Show Dialog'), - ) - ], - ); - } + child: const Text('Show Dialog'), + ) + ], + ); } diff --git a/navigation_and_routing/lib/src/screens/sign_in.dart b/navigation_and_routing/lib/src/screens/sign_in.dart index e66bf1895..e12017665 100644 --- a/navigation_and_routing/lib/src/screens/sign_in.dart +++ b/navigation_and_routing/lib/src/screens/sign_in.dart @@ -29,43 +29,41 @@ class _SignInScreenState extends State { final _passwordController = TextEditingController(); @override - Widget build(BuildContext context) { - return Scaffold( - body: Center( - child: Card( - child: Container( - constraints: BoxConstraints.loose(const Size(600, 600)), - padding: const EdgeInsets.all(8), - child: Column( - mainAxisAlignment: MainAxisAlignment.center, - mainAxisSize: MainAxisSize.min, - children: [ - Text('Sign in', style: Theme.of(context).textTheme.headline4), - TextField( - decoration: const InputDecoration(labelText: 'Username'), - controller: _usernameController, - ), - TextField( - decoration: const InputDecoration(labelText: 'Password'), - obscureText: true, - controller: _passwordController, - ), - Padding( - padding: const EdgeInsets.all(16), - child: TextButton( - onPressed: () async { - widget.onSignIn(Credentials( - _usernameController.value.text, - _passwordController.value.text)); - }, - child: const Text('Sign in'), + Widget build(BuildContext context) => Scaffold( + body: Center( + child: Card( + child: Container( + constraints: BoxConstraints.loose(const Size(600, 600)), + padding: const EdgeInsets.all(8), + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + mainAxisSize: MainAxisSize.min, + children: [ + Text('Sign in', style: Theme.of(context).textTheme.headline4), + TextField( + decoration: const InputDecoration(labelText: 'Username'), + controller: _usernameController, ), - ), - ], + TextField( + decoration: const InputDecoration(labelText: 'Password'), + obscureText: true, + controller: _passwordController, + ), + Padding( + padding: const EdgeInsets.all(16), + child: TextButton( + onPressed: () async { + widget.onSignIn(Credentials( + _usernameController.value.text, + _passwordController.value.text)); + }, + child: const Text('Sign in'), + ), + ), + ], + ), ), ), ), - ), - ); - } + ); } diff --git a/navigation_and_routing/lib/src/widgets/author_list.dart b/navigation_and_routing/lib/src/widgets/author_list.dart index bb5321e0b..82d4c7cc9 100644 --- a/navigation_and_routing/lib/src/widgets/author_list.dart +++ b/navigation_and_routing/lib/src/widgets/author_list.dart @@ -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, - ); - }, - ); - } + ), + ); } diff --git a/navigation_and_routing/lib/src/widgets/book_list.dart b/navigation_and_routing/lib/src/widgets/book_list.dart index 50cfc8805..a267a14de 100644 --- a/navigation_and_routing/lib/src/widgets/book_list.dart +++ b/navigation_and_routing/lib/src/widgets/book_list.dart @@ -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, - ); - }, - ); - } + ), + ); } diff --git a/navigation_and_routing/lib/src/widgets/fade_transition_page.dart b/navigation_and_routing/lib/src/widgets/fade_transition_page.dart index cdb4d565e..52df8d04c 100644 --- a/navigation_and_routing/lib/src/widgets/fade_transition_page.dart +++ b/navigation_and_routing/lib/src/widgets/fade_transition_page.dart @@ -15,15 +15,14 @@ class FadeTransitionPage extends Page { }) : super(key: key); @override - Route createRoute(BuildContext context) { - return PageBasedFadeTransitionRoute(this); - } + Route createRoute(BuildContext context) => + PageBasedFadeTransitionRoute(this); } class PageBasedFadeTransitionRoute extends PageRoute { - final FadeTransitionPage page; + final FadeTransitionPage _page; - PageBasedFadeTransitionRoute(this.page) : super(settings: page); + PageBasedFadeTransitionRoute(this._page) : super(settings: _page); @override Color? get barrierColor => null; @@ -32,7 +31,7 @@ class PageBasedFadeTransitionRoute extends PageRoute { 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 extends PageRoute { @override Widget buildTransitions(BuildContext context, Animation animation, - Animation secondaryAnimation, Widget child) { - return child; - } + Animation secondaryAnimation, Widget child) => + child; } diff --git a/navigation_and_routing/lib/src/widgets/library_scope.dart b/navigation_and_routing/lib/src/widgets/library_scope.dart index 4841dcdff..8d8b5dcde 100644 --- a/navigation_and_routing/lib/src/widgets/library_scope.dart +++ b/navigation_and_routing/lib/src/widgets/library_scope.dart @@ -19,7 +19,6 @@ class LibraryScope extends InheritedWidget { bool updateShouldNotify(LibraryScope oldWidget) => library != oldWidget.library; - static Library of(BuildContext context) { - return context.dependOnInheritedWidgetOfExactType()!.library; - } + static Library of(BuildContext context) => + context.dependOnInheritedWidgetOfExactType()!.library; }