Open xiangkesi opened 2 years ago
can you give more information about issue?
abstract class Routes { //第一个页面 static const initial = '/'; //文本 static const initialTextPage = '/TextPage';
static const initActiveListPage = '/ActiveListPage'; static const initPublishPage = '/PublishPage'; // ActiveDetailPage static const initActiveDetailPage = '/ActiveDetailPage';
static const initShortVideoPage = '/ShortVideoPage'; }
abstract class AppPages { static final pages = [ GetPage( name: Routes.initial, page: () => const MainPage(), ), GetPage( name: Routes.initialTextPage, page: () => const TextPage(), ), GetPage( name: Routes.initActiveListPage, page: () => const ActiveListPage(), ), GetPage( name: Routes.initActiveDetailPage, page: () => const ActiveDetailPage(), ), GetPage( name: Routes.initPublishPage, popGesture: false, fullscreenDialog: true, page: () => const PublishPage(), ), GetPage( name: Routes.initShortVideoPage, page: () => const ShortVideoPage(), ), ];
static void addGetPage(GetPage page) { if (!pages.contains(page)) { pages.add(page); } } }
abstract class AppPageManager { //打开新的页面 static void pushName( String pageName, { dynamic arguments, int? id, bool preventDuplicates = true, Map<String, String>? parameters, }) { Get.toNamed( pageName, arguments: arguments, id: id, preventDuplicates: preventDuplicates, parameters: parameters, ); }
//跳到下一个然后删除以前所有的 static void pushAndRemoveAllPages( String pageName, { RoutePredicate? predicate, dynamic arguments, int? id, Map<String, String>? parameters, }) { Get.offAllNamed( pageName, predicate: predicate, arguments: arguments, id: id, parameters: parameters, ); }
//返回上一个界面
static void pop
//导航到下一个页面并删除前一个页面: static pushAndRemoveCurrentPage( String page, { dynamic arguments, int? id, bool preventDuplicates = true, Map<String, String>? parameters, }) { Get.offNamed( page, arguments: arguments, id: id, preventDuplicates: preventDuplicates, parameters: parameters, ); } }
class MyApp extends StatelessWidget { const MyApp({Key? key}) : super(key: key);
@override Widget build(BuildContext context) { ZSSizeFit.initialize(); return GetMaterialApp( debugShowCheckedModeBanner: false, initialRoute: Routes.initial, theme: ThemeData( primarySwatch: HexColor.newWhite, highlightColor: Colors.transparent, splashColor: Colors.transparent, shadowColor: Colors.transparent, appBarTheme: const AppBarTheme( backgroundColor: Colors.white, shadowColor: Colors.transparent, ), scaffoldBackgroundColor: const Color.fromRGBO(255, 255, 255, 1.0), ), defaultTransition: Transition.cupertino, routingCallback: (routing) { // print(routing); }, // navigatorObservers: [routeObserver],
getPages: AppPages.pages,
);
} }
Version get: ^4.6.1, I encapsulated it like this, when I Get.toNamed a new page, and then Get.back() returns, occasionally the page will not return, but the CLOSE TO ROUTE in print is printed . This doesn't happen every time, sometimes it's good and sometimes it's not good, I don't know if it's a problem with my use or a problem with the framework itself.