custom_bloc 0.0.1 copy "custom_bloc: ^0.0.1" to clipboard
custom_bloc: ^0.0.1 copied to clipboard

outdated

A simple implementation of bloc

A basic custom stream builder.

Features #

This allows easy adding of data from network and disposing of bloc

class Example extends StatefulWidget { const Example({Key? key}) : super(key: key);

@override State

class _ExampleState extends State

@override Widget build(BuildContext context) { return Scaffold( body: Column( children: [ Expanded( child: CustomStreamBuilder<int, String>( stream: counterBloc.behaviorSubject, dataBuilder: (context, data) { return ListView.separated( itemCount: 1, scrollDirection: Axis.horizontal, padding: const EdgeInsets.symmetric(horizontal: 4), itemBuilder: (context, index) { return Padding( padding: const EdgeInsets.symmetric(horizontal: 12), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( '$index', style: const TextStyle(), ), ], )); }, separatorBuilder: (context, index) { return const Padding( padding: EdgeInsets.symmetric(vertical: 10.0), child: VerticalDivider(), ); }, ); }, loadingBuilder: (context) => const Center( child: CircularProgressIndicator(), ), errorBuilder: (context, error) => Text( error, style: const TextStyle(), ), ), ), const SizedBox( height: 34, ), Row( children: [ TextButton( onPressed: () { counterBloc.fetchCurrent(false); }, child: const Text( 'Add Value', style: TextStyle(), )), const SizedBox( width: 34, ), TextButton( onPressed: () { counterBloc.fetchCurrent(true); }, child: const Text( 'Add Error', style: TextStyle(), )), ], ), const SizedBox( height: 34, ) ], ), ); } }