network_status_dialog 0.0.11 copy "network_status_dialog: ^0.0.11" to clipboard
network_status_dialog: ^0.0.11 copied to clipboard

A Flutter package that shows an offline dialog when the user loses internet connection. Easily customizable with your own colors, text.

example/lib/main.dart

import 'package:flutter/material.dart';
import 'package:network_status_dialog/network_status_dialog.dart';

void main() {
  runApp(const MyApp());
}

// Create a navigator key to allow the dialog to be shown anywhere in the app
final GlobalKey<NavigatorState> navigatorKey = GlobalKey<NavigatorState>();

/// Main App Widget
class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      navigatorKey: navigatorKey, // Required for dialog navigation
      debugShowCheckedModeBanner: false,
      home: NetworkStatusListener(
        navigatorKey: navigatorKey, // Pass the navigator key here
        config: NetworkDialogConfig(
          dialogBackgroundColor: Colors.black,
          titleColor: Colors.white70,
          descriptionColor: Colors.white54,
          buttonTxtColor: Colors.white,
          title: "Oops!",
          description: "You're offline. Please check your internet connection.",
          primaryColor: Colors.red,
        ),
        child: const HomeScreen(), // Your main screen
      ),
    );
  }
}

/// Example Home Screen
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."),
      ),
    );
  }
}
11
likes
140
points
48
downloads

Publisher

verified publishersquarebits.com

Weekly Downloads

A Flutter package that shows an offline dialog when the user loses internet connection. Easily customizable with your own colors, text.

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (license)

Dependencies

app_settings, connectivity_plus, flutter, internet_connection_checker

More

Packages that depend on network_status_dialog