Skip to content

Commit 1cd20b3

Browse files
committed
VoidAction
1 parent 3ec528f commit 1cd20b3

File tree

4 files changed

+9
-3
lines changed

4 files changed

+9
-3
lines changed

example/lib/bloc_with_deps.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ class Dependencies {
2222
}
2323

2424
class Bloc1 extends DisposeCallbackBaseBloc {
25-
final Func0<void> load;
25+
final VoidAction load;
2626

2727
final DistinctValueStream<String?> string$;
2828

example/lib/counter_bloc.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import 'package:rxdart_ext/rxdart_ext.dart';
66

77
class CounterBloc extends DisposeCallbackBaseBloc {
88
/// Inputs
9-
final Func0<void> increment;
9+
final VoidAction increment;
1010

1111
/// Outputs
1212
final DistinctValueStream<int> state;

lib/src/base.dart

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@ class DisposeCallbackBaseBloc implements BaseBloc {
1919

2020
// Function types
2121

22+
/// Represents a function that have no arguments and return no data.
23+
typedef VoidAction<R> = void Function();
24+
2225
/// Represents a function with zero arguments: `() -> R`.
2326
typedef Func0<R> = R Function();
2427

test/flutter_bloc_pattern_test.dart

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,9 @@ class BlocCaptor<T extends BaseBloc> extends StatelessWidget {
4747
void main() {
4848
group('Base and Error', () {
4949
test('Function types', () {
50+
// ignore: omit_local_variable_types
51+
final VoidAction a = () {};
52+
5053
// ignore: omit_local_variable_types
5154
final Func0<void> f0 = () {};
5255

@@ -82,7 +85,7 @@ void main() {
8285
final Func9<int, String, double, int, List<int>, Map<int, int>, void,
8386
bool, bool, bool> f9 = (i, s, d, i2, li, map, _, b, b2) => b && b2;
8487

85-
[f0, f1, f2, f3, f4, f5, f6, f7, f8, f9].forEach(print);
88+
[a, f0, f1, f2, f3, f4, f5, f6, f7, f8, f9].forEach(print);
8689
});
8790

8891
test('DisposeCallbackBaseBloc', () {

0 commit comments

Comments
 (0)