flutter
off/online connectivity
a tidy flutter utility to handle offline/online connectivity like a boss. it provides support for both ios and android platforms (of course).
![[2025] Offline/Online Connectivity (2OS) offline/online connectivity (2os)](https://i0.wp.com/flutterawesome.com/content/images/2018/11/demo_1.gif?w=770&ssl=1)
![[2025] Offline/Online Connectivity (2OS) demo_2](https://i0.wp.com/flutterawesome.com/content/images/2018/11/demo_2.gif?w=770&ssl=1)
![[2025] Offline/Online Connectivity (2OS) demo_3](https://i0.wp.com/flutterawesome.com/content/images/2018/11/demo_3.gif?w=770&ssl=1)
installing
dependencies:
flutter_offline: "^0.2.2"
import
import 'package:flutter_offline/flutter_offline.dart';
how to use
import 'package:flutter/material.dart';
import 'package:flutter_offline/flutter_offline.dart';
class demopage extends statelesswidget {
@override
widget build(buildcontext context) {
return new scaffold(
appbar: new appbar(
title: new text("offline demo"),
),
body: offlinebuilder(
connectivitybuilder: (
buildcontext context,
conectivityresult cnct,
widget child,
) {
final bool connected = cnct != conectivityresult.none;
return new stack(
fit: stackfit.expand,
children: [
positioned(
height: 24.0,
left: 0.0,
right: 0.0,
child: container(
color: connected ? color(0xff00ee44) : color(0xffee4400),
child: center(
child: text("${connected ? 'online' : 'offline'}"),
),
),
),
center(
child: new text(
'yay!',
),
),
],
);
},
child: column(
mainaxisalignment: mainaxisalignment.center,
children: <widget>[
new text(
'there are no bottons to push :)',
),
new text(
'just turn off your internet.',
),
],
),
),
);
}
}
for more info, please, refer to the main.dart
in the example.
Comments are closed.