jonataslaw / getx

Open screens/snackbars/dialogs/bottomSheets without context, manage states and inject dependencies easily with Get.
MIT License
10.21k stars 1.6k forks source link

Get.back The interface cannot be returned #2209

Open xiangkesi opened 2 years ago

xiangkesi commented 2 years ago

image image image

maliksenpai commented 2 years ago

can you give more information about issue?

xiangkesi commented 2 years ago

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({ T? result, bool closeOverlays = false, bool canPop = true, int? id, }) { Get.back( result: result, closeOverlays: closeOverlays, canPop: canPop, id: id, ); }

//导航到下一个页面并删除前一个页面: 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,
);

} }

https://user-images.githubusercontent.com/21052641/155447671-d8c1c014-d4d5-4f61-80a8-8d64d76b9103.mp4

123

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.