network_status_dialog 0.0.2
network_status_dialog: ^0.0.2 copied to clipboard
A Flutter package that shows an offline dialog when the user loses internet connection. Easily customizable with your own colors, text, and Lottie animation.
π Network Status Dialog #
A lightweight Flutter package to automatically detect internet loss (including airplane mode) and show a customizable, non-dismissible dialog β ensuring users never interact with the app while offline.
Features #
- Auto-detects no internet or airplane mode
- Persistent dialog until connectivity is restored
- Fully customizable: title, description, colors
- Open Wi-Fi / Mobile Data settings directly from the dialog
- Easy plug & play integration
Getting Started #
1. Add to pubspec.yaml
#
dependencies:
network_status_dialog: 0.0.2
2. Import and Use #
import 'package:flutter/material.dart';
import 'package:network_status_dialog/network_status_dialog.dart';
void main() {
runApp(const MyApp());
}
/// Root widget of the app
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
Widget build(BuildContext context) {
return MaterialApp(
// Wrap the screen (or the whole app) with NetworkStatusListener
// This widget listens for network changes and automatically shows a dialog when offline
home: NetworkStatusListener(
config: NetworkDialogConfig(
// Customize the dialog title
title: "Oops!",
// Message shown when offline
description: "You're offline. Please check your internet connection.",
// Primary color used for the button and accents
primaryColor: Colors.red,
),
child: const HomeScreen(), // Your actual app screen goes here
),
);
}
}
/// Example home screen widget
class HomeScreen extends StatelessWidget {
const HomeScreen({super.key});
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text("Network Dialog Example"),
),
body: const Center(
child: Text("You're online."),
),
);
}
}