no_bloc_flutter 0.3.3

  • Readme
  • Changelog
  • Example
  • Installing
  • new71

Helper widgets to work with no_bloc library

Bloc Builder #

Keeps your UI in sync with the State of your app. It's StatelessWidget widget which only rebuilds the relative child, instead of rebuilding entire page.

BlocBuilder<BlocType, BlocStateType>(
  bloc: bloc
  onUpdate: (context, data) => Text(data.toString()),
  onBusy: (_) => Text('Working'),
  onError: (_, e) => Text('Error Occurred'),
)

Or a simpler version (extension method sugar):

bloc.builder(
  onUpdate: (context, data) => Text(data.toString()),
  onError: (_, e) => Text('Error Occurred: $e'),
)

for details see example

Bloc Container #

A container where you can store all your blocs on app startup, and then access them anywhere in your app independently of the widget tree.

void main() {
  BlocContainer.add((context, args) => CounterBloc(args));
  final counterBloc = BlocContainer.get(arg: 0);
}

see example

Bloc List Builder #

A builder which builds a ListView widget backed by a data source e.g. an infinite scrollable list backed by a rest api example coming soon

Contribution ❤ #

Issues and pull requests are welcome

Please file feature requests and bugs at the issue tracker.

0.3.3 #

  • remove import of dart:io, to keep compatible with web

0.3.2 #

  • bug fix

0.3.1 #

  • add a check for running on web

0.3.0 #

  • add a default onBusy function
  • update documentation

0.2.3 #

  • major bug fix

0.2.2 #

  • minor changes

0.2.1 #

  • update no_bloc

0.2.0 #

  • update no_bloc

0.1.2 #

  • add bloc extension

0.1.1 #

  • add documentation

0.1.0 #

  • Initial release

example/main.dart

import 'package:no_bloc_flutter/no_bloc_flutter.dart';
import 'package:flutter/material.dart';

class CounterBloc extends AutoPersistedBloc<CounterBloc, int> {
  final int counterNumber;

  CounterBloc({this.counterNumber}) : super(initialState: 0);

  void increment() => setState(value + 1, event: 'increment');

  void decrement() => setState(value - 1, event: 'decrement');
}

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    final bloc = BlocContainer.get<CounterBloc, int>();

    return MaterialApp(
      home: Scaffold(
        body: Center(
          child: Column(
            mainAxisAlignment: MainAxisAlignment.center,
            children: [
              Text('You have pushed the button this many times:'),
              bloc.builder(
                onUpdate: (context, data) => Text(data.toString(), style: Theme.of(context).textTheme.headline4),
                onBusy: (_) => Text('Working'),
                onError: (_, e) => Text('Error Occurred'),
              ),
            ],
          ),
        ),
        floatingActionButton: FloatingActionButton(
          child: Icon(Icons.add),
          onPressed: BlocContainer.get<CounterBloc, int>().increment,
        ),
      ),
    );
  }
}

void main() {
  BlocContainer.add<CounterBloc>((context, arg) => CounterBloc(counterNumber: arg ?? 0));
  runApp(MyApp());
}

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  no_bloc_flutter: ^0.3.3

2. Install it

You can install packages from the command line:

with Flutter:


$ flutter pub get

Alternatively, your editor might support flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:no_bloc_flutter/no_bloc_flutter.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
43
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
100
Overall:
Weighted score of the above. [more]
71
Learn more about scoring.

We analyzed this package on Jul 4, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.8.4
  • pana: 0.13.13
  • Flutter: 1.17.5

Analysis suggestions

Package not compatible with SDK dart

because of import path [no_bloc_flutter] that is in a package requiring null.

Health suggestions

Format lib/src/bloc_builder.dart.

Run flutter format to format lib/src/bloc_builder.dart.

Format lib/src/bloc_container.dart.

Run flutter format to format lib/src/bloc_container.dart.

Format lib/src/bloc_extensions.dart.

Run flutter format to format lib/src/bloc_extensions.dart.

Format lib/src/bloc_list_builder.dart.

Run flutter format to format lib/src/bloc_list_builder.dart.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.7.0 <3.0.0
flutter 0.0.0
hive ^1.0.0 1.4.1+1
no_bloc ^0.3.0 0.3.0
path ^1.0.0 1.7.0
path_provider ^1.0.0 1.6.11
rxdart ^0.24.1 0.24.1
synchronized ^2.0.0 2.2.0+1
Transitive dependencies
_fe_analyzer_shared 5.0.0
analyzer 0.39.11
args 1.6.0
async 2.4.1
boolean_selector 2.0.0
built_collection 4.3.2
built_value 7.1.0
charcode 1.1.3
collection 1.14.12 1.14.13
convert 2.1.1
coverage 0.14.0
crypto 2.1.5
csslib 0.16.1
equatable 1.2.0
file 5.2.1
fixnum 0.10.11
glob 1.2.0
html 0.14.0+3
http 0.12.1
http_multi_server 2.2.0
http_parser 3.1.4
intl 0.16.1
io 0.3.4
js 0.6.2
logging 0.11.4
matcher 0.12.8
meta 1.1.8
mime 0.9.6+3
node_interop 1.1.1
node_io 1.1.1
node_preamble 1.4.12
package_config 1.9.3
path_provider_linux 0.0.1+2
path_provider_macos 0.0.4+3
path_provider_platform_interface 1.0.2
pedantic 1.9.0 1.9.1
platform 2.2.1
plugin_platform_interface 1.0.2
pool 1.4.0
process 3.0.13
pub_semver 1.4.4
quiver 2.1.3
shelf 0.7.7
shelf_packages_handler 2.0.0
shelf_static 0.2.8
shelf_web_socket 0.2.3
sky_engine 0.0.99
source_map_stack_trace 2.0.0
source_maps 0.10.9
source_span 1.7.0
stack_trace 1.9.5
stream_channel 2.0.0
string_scanner 1.0.5
term_glyph 1.1.0
test_api 0.2.17
test_core 0.3.9
typed_data 1.1.6 1.2.0
vector_math 2.0.8
vm_service 4.1.0
watcher 0.9.7+15
web_socket_channel 1.1.0
webkit_inspection_protocol 0.7.3
xdg_directories 0.1.0
yaml 2.2.1
Dev dependencies
flutter_test
test ^1.6.0 1.15.1