import 'package:flutter/material.dart'; import 'package:page_transition/page_transition.dart'; import '../about/internal/application/NavigatorType.dart'; /// Every transition in the app funnels through here. Destinations are widget /// instances, not named routes, and the single choke point is what lets a /// device-integrity check gate all routing. class GroundedNavigation { void navigateToPage(NavigatorType type, dynamic path, BuildContext context) { _runSec(context, type, path); } Future _runSec(BuildContext context, NavigatorType type, dynamic path) async { switch (type) { case NavigatorType.openFully: Navigator.of(context).pushReplacement( MaterialPageRoute(builder: (BuildContext context) => path)); break; case NavigatorType.justOpen: Navigator.push( context, PageTransition( type: PageTransitionType.size, alignment: Alignment.center, child: path)); break; case NavigatorType.replaceCurrent: Navigator.pushReplacement( context, PageTransition( type: PageTransitionType.scale, alignment: Alignment.center, curve: Curves.ease, duration: const Duration(microseconds: 9000), child: path)); break; case NavigatorType.makeNewMain: Navigator.pushAndRemoveUntil( context, PageTransition( type: PageTransitionType.fade, alignment: Alignment.center, child: path), ModalRoute.withName('/')); break; } } /// The reload-on-return channel: the child pops with a result and the parent /// refreshes on it. Future navigateToPageWithData( dynamic path, BuildContext context) async { return await Navigator.push( context, MaterialPageRoute( builder: (context) => path, ), ); } }