connectivity_watcher 0.0.1 connectivity_watcher: ^0.0.1 copied to clipboard
Discover network connectivity changes throught the app with your own custom no internet widget.
import 'package:connectivity_watcher/NetworkService/Connectivity_Watcher.dart';
import 'package:example/NoInternet.dart';
import 'package:flutter/material.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
return MaterialApp(
navigatorKey: ConnectivityWatcher.contextKey,
title: 'Flutter Demo',
theme: ThemeData(
primarySwatch: Colors.blue,
),
home: RedScreen());
}
}
class RedScreen extends StatefulWidget {
const RedScreen({super.key});
@override
State<RedScreen> createState() => _RedScreenState();
}
class _RedScreenState extends State<RedScreen> {
@override
void initState() {
// TODO: implement initState
ConnectivityWatcher.shared.setup(widgetForNoInternet: CustomNoInternet());
super.initState();
}
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: Colors.red,
);
}
}