Skip to content

Instantly share code, notes, and snippets.

@maikotrindade
Created October 18, 2018 18:40
Show Gist options
  • Save maikotrindade/11bf4e8c34881f74db35f22ff724ebd2 to your computer and use it in GitHub Desktop.
Save maikotrindade/11bf4e8c34881f74db35f22ff724ebd2 to your computer and use it in GitHub Desktop.
import 'package:flutter/material.dart';
import 'package:flutter_offline/flutter_offline.dart';
class FlutterOffline extends StatelessWidget {
@override
Widget build(BuildContext context) {
return new Scaffold(
appBar: new AppBar(
title: new Text("Flutter Offline Demo"),
),
body: OfflineBuilder(
connectivityBuilder: (
BuildContext context,
ConnectivityResult connectivity,
Widget child,
) {
final bool connected = connectivity != ConnectivityResult.none;
return new Stack(
fit: StackFit.expand,
children: [
Positioned(
height: 16.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(
'Tested',
),
),
],
);
},
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
new Text(
'Change connectivity of your phone.',
),
],
),
),
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment