mirror of https://github.com/flutter/samples.git
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>pull/1675/head
parent
d53a8ee93f
commit
8c06626190
@ -0,0 +1,66 @@
|
|||||||
|
// Copyright 2021, the Flutter project authors. Please see the AUTHORS file
|
||||||
|
// for details. All rights reserved. Use of this source code is governed by a
|
||||||
|
// BSD-style license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
import 'package:flutter/cupertino.dart';
|
||||||
|
|
||||||
|
class FadeTransitionPage<T> extends Page<T> {
|
||||||
|
final Widget child;
|
||||||
|
final Duration duration;
|
||||||
|
|
||||||
|
const FadeTransitionPage({
|
||||||
|
super.key,
|
||||||
|
required this.child,
|
||||||
|
this.duration = const Duration(milliseconds: 300),
|
||||||
|
super.restorationId,
|
||||||
|
});
|
||||||
|
|
||||||
|
@override
|
||||||
|
Route<T> createRoute(BuildContext context) =>
|
||||||
|
PageBasedFadeTransitionRoute<T>(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
class PageBasedFadeTransitionRoute<T> extends PageRoute<T> {
|
||||||
|
PageBasedFadeTransitionRoute(FadeTransitionPage<T> page)
|
||||||
|
: super(settings: page);
|
||||||
|
|
||||||
|
FadeTransitionPage<T> get _page => settings as FadeTransitionPage<T>;
|
||||||
|
|
||||||
|
@override
|
||||||
|
Color? get barrierColor => null;
|
||||||
|
|
||||||
|
@override
|
||||||
|
String? get barrierLabel => null;
|
||||||
|
|
||||||
|
@override
|
||||||
|
Duration get transitionDuration => _page.duration;
|
||||||
|
|
||||||
|
@override
|
||||||
|
Duration get reverseTransitionDuration => _page.duration;
|
||||||
|
|
||||||
|
@override
|
||||||
|
bool get maintainState => true;
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget buildPage(
|
||||||
|
BuildContext context,
|
||||||
|
Animation<double> animation,
|
||||||
|
Animation<double> secondaryAnimation,
|
||||||
|
) {
|
||||||
|
return _page.child;
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget buildTransitions(
|
||||||
|
BuildContext context,
|
||||||
|
Animation<double> animation,
|
||||||
|
Animation<double> secondaryAnimation,
|
||||||
|
Widget child,
|
||||||
|
) {
|
||||||
|
final tween = CurveTween(curve: Curves.easeInOut);
|
||||||
|
return FadeTransition(
|
||||||
|
opacity: animation.drive(tween),
|
||||||
|
child: _page.child,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in new issue