|
|
@ -6,6 +6,7 @@
|
|
|
|
/// transition animations are shown. (For example, [when two routes are popped
|
|
|
|
/// transition animations are shown. (For example, [when two routes are popped
|
|
|
|
/// off the stack](https://github.com/flutter/flutter/issues/12146), however the
|
|
|
|
/// off the stack](https://github.com/flutter/flutter/issues/12146), however the
|
|
|
|
/// default TransitionDelegate will handle this if you are using Router)
|
|
|
|
/// default TransitionDelegate will handle this if you are using Router)
|
|
|
|
|
|
|
|
import 'package:flutter/foundation.dart';
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
|
|
|
|
|
|
|
|
void main() {
|
|
|
|
void main() {
|
|
|
@ -27,7 +28,7 @@ class BooksApp extends StatefulWidget {
|
|
|
|
class _BooksAppState extends State<BooksApp> {
|
|
|
|
class _BooksAppState extends State<BooksApp> {
|
|
|
|
BookRouterDelegate _routerDelegate = BookRouterDelegate();
|
|
|
|
BookRouterDelegate _routerDelegate = BookRouterDelegate();
|
|
|
|
BookRouteInformationParser _routeInformationParser =
|
|
|
|
BookRouteInformationParser _routeInformationParser =
|
|
|
|
BookRouteInformationParser();
|
|
|
|
BookRouteInformationParser();
|
|
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
Widget build(BuildContext context) {
|
|
|
@ -42,14 +43,15 @@ class _BooksAppState extends State<BooksApp> {
|
|
|
|
class BookRouteInformationParser extends RouteInformationParser<BookRoutePath> {
|
|
|
|
class BookRouteInformationParser extends RouteInformationParser<BookRoutePath> {
|
|
|
|
@override
|
|
|
|
@override
|
|
|
|
Future<BookRoutePath> parseRouteInformation(
|
|
|
|
Future<BookRoutePath> parseRouteInformation(
|
|
|
|
RouteInformation routeInformation) async {
|
|
|
|
RouteInformation routeInformation,
|
|
|
|
|
|
|
|
) {
|
|
|
|
final uri = Uri.parse(routeInformation.location);
|
|
|
|
final uri = Uri.parse(routeInformation.location);
|
|
|
|
|
|
|
|
|
|
|
|
if (uri.pathSegments.length >= 2) {
|
|
|
|
if (uri.pathSegments.length >= 2) {
|
|
|
|
var remaining = uri.pathSegments[1];
|
|
|
|
var remaining = uri.pathSegments[1];
|
|
|
|
return BookRoutePath.details(int.tryParse(remaining));
|
|
|
|
return SynchronousFuture(BookRoutePath.details(int.tryParse(remaining)));
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
return BookRoutePath.home();
|
|
|
|
return SynchronousFuture(BookRoutePath.home());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -113,10 +115,11 @@ class BookRouterDelegate extends RouterDelegate<BookRoutePath>
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
@override
|
|
|
|
Future<void> setNewRoutePath(BookRoutePath path) async {
|
|
|
|
Future<void> setNewRoutePath(BookRoutePath path) {
|
|
|
|
if (path.isDetailsPage) {
|
|
|
|
if (path.isDetailsPage) {
|
|
|
|
_selectedBook = books[path.id];
|
|
|
|
_selectedBook = books[path.id];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return SynchronousFuture<void>(null);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void _handleBookTapped(Book book) {
|
|
|
|
void _handleBookTapped(Book book) {
|
|
|
@ -213,9 +216,9 @@ class NoAnimationTransitionDelegate extends TransitionDelegate<void> {
|
|
|
|
Iterable<RouteTransitionRecord> resolve({
|
|
|
|
Iterable<RouteTransitionRecord> resolve({
|
|
|
|
List<RouteTransitionRecord> newPageRouteHistory,
|
|
|
|
List<RouteTransitionRecord> newPageRouteHistory,
|
|
|
|
Map<RouteTransitionRecord, RouteTransitionRecord>
|
|
|
|
Map<RouteTransitionRecord, RouteTransitionRecord>
|
|
|
|
locationToExitingPageRoute,
|
|
|
|
locationToExitingPageRoute,
|
|
|
|
Map<RouteTransitionRecord, List<RouteTransitionRecord>>
|
|
|
|
Map<RouteTransitionRecord, List<RouteTransitionRecord>>
|
|
|
|
pageRouteToPagelessRoutes,
|
|
|
|
pageRouteToPagelessRoutes,
|
|
|
|
}) {
|
|
|
|
}) {
|
|
|
|
final results = <RouteTransitionRecord>[];
|
|
|
|
final results = <RouteTransitionRecord>[];
|
|
|
|
|
|
|
|
|
|
|
|