i am using the Navigator 2.0 from Flutter but there arent any page transitions showing up when navigating to a new page. Only when using the old navigator there were easy transitions
class AppRouterDelegate extends RouterDelegate<CustomPage>
with ChangeNotifier, PopNavigatorRouterDelegateMixin<CustomPage> {
bool _onPopPage(Route _route, dynamic _result) {
bool _res = _route.didPop(_result);
if (_res) _pages.removeLast();
return _res;
}
List<CustomPage> _pages = [];
@override
Widget build(BuildContext context) {
print("rebuilt with pagestack " + _pages.toString());
return Navigator(
key: navigatorKey,
pages: List.of(_pages),
onPopPage: _onPopPage,
// transitionDelegate: ,
);
}
@override
CustomPage? get currentConfiguration => _pages.last;
@override
Future<bool> popRoute() {
return SynchronousFuture<bool>(true);
}
@override
Future<void> setNewRoutePath(CustomPage _page) {
_pages.add(_page);
notifyListeners();
return SynchronousFuture<void>(null);
}
void push(CustomPage _page) {
_pages.add(_page);
notifyListeners();
}
@override
GlobalKey<NavigatorState> get navigatorKey => GlobalKey<NavigatorState>();
}
and I am using the RouterDelegate via this piece of code (i injected it with riverpod dont wonder)
BuildContextX(context).read(appRouterDelegate).push(
CustomPage(
builder: (_, animation, ___) => FadeTransition(
opacity: animation,
child: Scaffold(
backgroundColor: Colors.blue,
),
),
pageName: '/some',
localKey: ValueKey('/some'),
),
);