bloc_connectivity 0.0.2 bloc_connectivity: ^0.0.2 copied to clipboard
This is a Flutter package used to wrap your application with the NetworkChecker Widget to continously check the network connectivity using Bloc.
Example for bloc_connectivity #
This example demonstrates the usage of the NetworkChecker
widget from the bloc_connectivity
package.
Getting Started #
- Install the package by adding it to your
pubspec.yaml
file:
dependencies:
bloc_connectivity: ^1.0.0
- Import the package in your Dart code:
import 'package:bloc_connectivity/bloc_connectivity.dart';
Use the NetworkChecker widget to handle network connectivity in your app:
dart
Copy code
import 'package:flutter/material.dart';
import 'package:bloc_connectivity/bloc_connectivity.dart';
void main() {
runApp(
NetworkChecker(
child: MyApp(),
networkOffDialog: AlertDialog(
title: Text('Network Offline'),
content: Text('Please check your internet connection.'),
actions: [
TextButton(
onPressed: () {
// Handle retry action
},
child: Text('Retry'),
),
],
),
),
);
}
// ... rest of your code ...
- Feel free to adjust the structure based on your preferences and the complexity of your documentation and example.