Coneectivity Service is for checking the internet connection using provider

Features

Coneectivity Service is for checking the internet connection using provider.

Installation

  1. Add the latest version of package to your pubspec.yaml (and rundart pub get):

dependencies:
  connectivity_service: ^0.0.3
  1. Import the package and use it in your Flutter App.

import 'package:connectivity_service/connectivity_service.dart';

Example

  1. Add the provider in mateerial app

import 'package:flutter/material.dart';
void main() {
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({Key? key}) : super(key: key);

  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return MultiProvider(
      providers: [
        StreamProvider<ConnectivitySatus>(
            create: (context) =>
                ConeectivityService().connectionStatusController.stream,
            initialData: ConnectivitySatus.offline)
      ],
      child: MaterialApp(
        title: 'Flutter Application',
        theme: ThemeData(
          primarySwatch: Colors.blue,
        ),
        home: const Homepage(),
      ),
    );
  }
}
  1. Then add ‘NetworkSensitive’ where you need.

import 'package:connectivity_service/enum/network_sensitivity.dart';
import 'package:flutter/material.dart';

class Homepage extends StatefulWidget {
  const Homepage({Key? key}) : super(key: key);

  @override
  State<Homepage> createState() => _HomepageState();
}

class _HomepageState extends State<Homepage> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: SafeArea(
        child: NetworkSensitive(
          child:Text('Your design here'),
        ),
      ),
    );
  }
}
  1. In ‘NetworkSensitive’ page you can create your own design on the offline section. For now it is a simple text ‘No Internet!’ but you can design here anything.

GitHub

View Github