connectivity_wall 1.0.6 copy "connectivity_wall: ^1.0.6" to clipboard
connectivity_wall: ^1.0.6 copied to clipboard

Connectivity wall redirect user to a widget when offline and another if online

connectivity_wall #

A Connectivity wall monitor

Getting Started #

Connectivity wall redirect user to a widget when offline and another if online.

We keep the app state using a IndexedStack.

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

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

class MyApp extends StatelessWidget {
  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
        title: 'Flutter Demo',
        theme: ThemeData(
          primarySwatch: Colors.blue,
        ),
        home: ConnectivityWall(
          pingInterval: 120,
          responseCode: 200,
          onPingUrl: Uri.parse("https://pub.dev/"),

          /// Connectedwall
          onConnectedWall: OnlineState(),
          /// User changed from wifi to data or else
          onConnectivityChanged: (result) {
            // ConnectivityResult.mobile
            // ConnectivityResult.wifi
            // ConnectivityResult.none
            print(result);
          },

          /// Disconnected callback
          onDisconnected: () {
            print("Offline, do something");
          },

          /// Disconnected Widget wall
          onDisconnectedWall: OfflineState(),
        ));
  }
}

class OfflineState extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: Container(
        alignment: Alignment.center,
        child: Center(
          child: Text("Not connected to internet"),
        ),
      ),
    );
  }
}


class OnlineState extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: Container(
        alignment: Alignment.center,
        child: Center(
          child: Text("Connected "),
        ),
      ),
    );
  }
}


9
likes
0
pub points
64%
popularity

Publisher

verified publishersharedway.app

Connectivity wall redirect user to a widget when offline and another if online

Homepage
Repository (GitHub)
View/report issues

License

unknown (LICENSE)

Dependencies

connectivity_plus, flutter, http

More

Packages that depend on connectivity_wall