Skip to content

Instantly share code, notes, and snippets.

@sigmapie8
Created June 13, 2021 15:03
Show Gist options
  • Save sigmapie8/82721079748e3d445d8b61fe25a1378d to your computer and use it in GitHub Desktop.
Save sigmapie8/82721079748e3d445d8b61fe25a1378d to your computer and use it in GitHub Desktop.
import 'package:connectivity_plus/connectivity_plus.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
class ConnectionType extends StatefulWidget {
@override
_ConnectionTypeState createState() => _ConnectionTypeState();
}
class _ConnectionTypeState extends State<ConnectionType> {
@override
Widget build(BuildContext context) {
return FutureBuilder(
future: Connectivity().checkConnectivity(),
builder: (BuildContext context,
AsyncSnapshot<ConnectivityResult> connectionType) {
if (!connectionType.hasData) {
return ListTile(
title: CircularProgressIndicator(),
);
} else {
return ListTile(
title: Text('${connectionType.data}'),
);
}
},
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment