mirror of
https://github.com/flutter/samples.git
synced 2026-07-24 09:51:50 +00:00
Migrate veggieseasons to go_router (#1544)
* add go_router * wip migration to go_router * small fixes * home screen cleanup * remove unused * small fixes * details should be fullscreen dialog * remove comment * fix navigation outside the shell by using the correct navigation keys * add restoration id to all pages * test passing, but parts are commented out, wip * uncommented more test code * Add TODOs * fix lint issues * fix tests * use FadeTransitionPage * remove unnecessary builders * FadeTransitionPage same as CustomTransitionPage * add comments regarding relative routes * add missing pageKey * add missing const --------- Co-authored-by: Brett Morgan <brettmorgan@google.com>
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
// found in the LICENSE file.
|
||||
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:veggieseasons/data/app_state.dart';
|
||||
import 'package:veggieseasons/data/preferences.dart';
|
||||
@@ -240,19 +241,6 @@ class DetailsScreen extends StatefulWidget {
|
||||
|
||||
const DetailsScreen({this.id, this.restorationId, super.key});
|
||||
|
||||
static String show(NavigatorState navigator, int veggieId) {
|
||||
return navigator.restorablePush<void>(_routeBuilder, arguments: veggieId);
|
||||
}
|
||||
|
||||
static Route<void> _routeBuilder(BuildContext context, Object? arguments) {
|
||||
final veggieId = arguments as int?;
|
||||
return CupertinoPageRoute(
|
||||
builder: (context) =>
|
||||
DetailsScreen(id: veggieId, restorationId: 'details'),
|
||||
fullscreenDialog: true,
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
State<DetailsScreen> createState() => _DetailsScreenState();
|
||||
}
|
||||
@@ -295,7 +283,7 @@ class _DetailsScreenState extends State<DetailsScreen> with RestorationMixin {
|
||||
left: 16,
|
||||
child: SafeArea(
|
||||
child: CloseButton(() {
|
||||
Navigator.of(context).pop();
|
||||
context.pop();
|
||||
}),
|
||||
),
|
||||
),
|
||||
|
||||
Reference in New Issue
Block a user