connectivity_service 0.0.4 copy "connectivity_service: ^0.0.4" to clipboard
connectivity_service: ^0.0.4 copied to clipboard

Network Service Checker.

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.
2
likes
90
pub points
58%
popularity

Publisher

unverified uploader

Network Service Checker.

Repository (GitHub)
View/report issues

Documentation

API reference

License

BSD-3-Clause (LICENSE)

Dependencies

connectivity, flutter, http, path_provider, provider

More

Packages that depend on connectivity_service