Last active
January 20, 2023 18:27
-
-
Save TarunNagaSai/f90e6817d2bb4f2b4489a5cf43e37307 to your computer and use it in GitHub Desktop.
This file has all the routes of the screen and the main configuraiton for all the screen in the app
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import 'package:flutter/material.dart'; | |
| import 'package:get/get_instance/get_instance.dart'; | |
| import 'package:get/get_navigation/get_navigation.dart'; | |
| import 'package:no_internet_configuration/UI/screens/home_screen.dart'; | |
| import 'package:no_internet_configuration/UI/screens/second_screen.dart'; | |
| import 'package:no_internet_configuration/UI/widgets/no_internet_helper.dart'; | |
| class GetRoutes { | |
| /// route names | |
| static const home = '/', secondScreen = '/secondScreen'; | |
| /// list of screens | |
| static List<GetPage> routes = [ | |
| checkWithNetworkThenShoot( | |
| name: home, | |
| page: () => const HomeScreen(), | |
| checkWithNetwork: false, | |
| ), | |
| checkWithNetworkThenShoot( | |
| name: secondScreen, | |
| page: () => const SecondScreen(), | |
| ), | |
| ]; | |
| /// should pass properties of the [GetPage] into this method as named perameters | |
| /// it workes just like [GetPage] and with an additional functionality for no internet screen. | |
| static GetPage checkWithNetworkThenShoot({ | |
| required String name, | |
| required Widget Function() page, | |
| Bindings? binding, | |
| /// passing this as false make the page directly navigate to the page | |
| /// without checking with internet | |
| bool checkWithNetwork = true, | |
| }) { | |
| if (!checkWithNetwork) { | |
| return GetPage( | |
| name: name, | |
| page: () => page(), | |
| binding: binding, | |
| ); | |
| } | |
| return GetPage( | |
| name: name, | |
| page: () => CheckInternet( | |
| routeName: name, | |
| page: page, | |
| ), | |
| binding: binding, | |
| ); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment