bloc_network 1.0.1 bloc_network: ^1.0.1 copied to clipboard
A dart package to bootstrap using bloc state management for network requests.
// ignore_for_file: avoid_print
import 'package:bloc_network/bloc_network.dart';
void main() {
final cubit = CostCubit();
cubit.stream.listen((state) => print('state changed to: $state'));
cubit.fetchData();
}
class CostCubit extends QueryCubit<int> {
@override
Future<int> repositoryCallback(Object? extra) async {
// Simulate an asynchronous operation. Typically this would be the place
// to do something like an HTTP GET request.
await Future<void>.delayed(const Duration(seconds: 1));
return 5;
}
}