no_internet_check 1.0.0 copy "no_internet_check: ^1.0.0" to clipboard
no_internet_check: ^1.0.0 copied to clipboard

Automatically show no internet screen on top of your current screen and when there is internet it automatically pop the no internet screen.

example/lib/main.dart

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

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

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      debugShowCheckedModeBanner: false,
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      navigatorKey: NavigationService.navigationKey, //TODO: ADD THIS LINE
      home: MyHomePage(title: 'Flutter Demo Home Page'),
    );
  }
}

class MyHomePage extends StatefulWidget {
  MyHomePage({Key? key, required this.title}) : super(key: key);

  final String title;

  @override
  _MyHomePageState createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  int _counter = 0;
  @override
  void initState() {
    InternetChecker(); //TODO: ADD THIS LINE
    super.initState();
  }

  void _incrementCounter() {
    setState(() {
      _counter++;
    });
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text(widget.title),
      ),
      body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: <Widget>[
            Text(
              'You have pushed the button this many times:',
            ),
            Text(
              '$_counter',
              style: Theme.of(context).textTheme.headline4,
            ),
          ],
        ),
      ),
      floatingActionButton: FloatingActionButton(
        onPressed: _incrementCounter,
        tooltip: 'Increment',
        child: Icon(Icons.add),
      ),
    );
  }
}
14
likes
130
points
52
downloads

Publisher

unverified uploader

Weekly Downloads

Automatically show no internet screen on top of your current screen and when there is internet it automatically pop the no internet screen.

Repository (GitLab)
View/report issues

Documentation

API reference

License

MIT (license)

Dependencies

flutter, flutter_toastr, internet_connection_checker

More

Packages that depend on no_internet_check