Created
January 20, 2023 14:30
-
-
Save TarunNagaSai/af0c463fcafc487c1ddb699d2f8b8702 to your computer and use it in GitHub Desktop.
this widget is warped aroud the
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/instance_manager.dart'; | |
| import 'package:no_internet_configuration/UI/screens/no_internet_screen.dart'; | |
| import 'package:no_internet_configuration/controller/internet_service_controller.dart'; | |
| class CheckInternet extends StatelessWidget { | |
| /// CheckInternet accept the [page] widget and check with internet | |
| /// if available returns page or no internet screen | |
| const CheckInternet({required this.page, required this.routeName, super.key}); | |
| final Widget Function() page; | |
| final String routeName; | |
| /// we are using dependence injuction here instad of Getx widgets is to avoid | |
| /// replace with page with the no internet screen instantly | |
| static NetworkServicesController get networkController => Get.find(); | |
| @override | |
| Widget build(BuildContext context) { | |
| if (networkController.connectedToNetwork) { | |
| return page(); | |
| } else { | |
| return NoInternetScreen( | |
| routeName: routeName, | |
| ); | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment