0 purchases
connectivity service
Features #
Coneectivity Service is for checking the internet connection using provider.
Installation #
Add the latest version of package to your pubspec.yaml (and rundart pub get):
dependencies:
connectivity_service: ^0.0.3
copied to clipboard
Import the package and use it in your Flutter App.
import 'package:connectivity_service/connectivity_service.dart';
copied to clipboard
Example #
Add the provider in mateerial app
import 'package:flutter/material.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({Key? key}) : super(key: key);
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
return MultiProvider(
providers: [
StreamProvider<ConnectivitySatus>(
create: (context) =>
ConeectivityService().connectionStatusController.stream,
initialData: ConnectivitySatus.offline)
],
child: MaterialApp(
title: 'Flutter Application',
theme: ThemeData(
primarySwatch: Colors.blue,
),
home: const Homepage(),
),
);
}
}
copied to clipboard
Then add 'NetworkSensitive' where you need.
import 'package:connectivity_service/enum/network_sensitivity.dart';
import 'package:flutter/material.dart';
class Homepage extends StatefulWidget {
const Homepage({Key? key}) : super(key: key);
@override
State<Homepage> createState() => _HomepageState();
}
class _HomepageState extends State<Homepage> {
@override
Widget build(BuildContext context) {
return Scaffold(
body: SafeArea(
child: NetworkSensitive(
child:Text('Your design here'),
),
),
);
}
}
copied to clipboard
In 'NetworkSensitive' page you can create your own design on the offline section. For now it is a simple text 'No Internet!' but you can design here anything.
For personal and professional use. You cannot resell or redistribute these repositories in their original state.
There are no reviews.