flutter_network_status 0.0.3 copy "flutter_network_status: ^0.0.3" to clipboard
flutter_network_status: ^0.0.3 copied to clipboard

This is a network connectivity state listenable provider and service.

example/lib/main.dart

import 'package:flutter/material.dart';
import 'package:flutter_network_status/network_status.dart';

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

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
    /// Step - 1:
    /// NetworkProvider use to live observation connectivity
    return NetworkProvider(
      child: const MaterialApp(
        debugShowCheckedModeBanner: false,
        title: 'Network Provider',
        home: HomePage(),
      ),
    );
  }
}

class HomePage extends StatelessWidget {
  const HomePage({
    super.key,
  });

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      backgroundColor: Colors.white,
      appBar: AppBar(
        title: const Text('Home'),
        centerTitle: true,
      ),
      body: Center(
        /// Step - 2:
        /// NetworkListener use to listener network status when network connection turn on or off
        child: NetworkListener(
          builder: (context, isConnected) {
            return Text(
              'Network is ${isConnected ? "Available" : "Unavailable"}',
              style: const TextStyle(fontSize: 20),
            );
          },
        ),
      ),
    );
  }
}
3
likes
130
points
149
downloads

Publisher

unverified uploader

Weekly Downloads

This is a network connectivity state listenable provider and service.

Repository (GitHub)
View/report issues

Documentation

API reference

License

Apache-2.0 (license)

Dependencies

connectivity_plus, flutter

More

Packages that depend on flutter_network_status