Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 80bd360

Browse files
Merge pull request #1 from noxware/master
upgraded flutter_bloc to ^7.0.0
2 parents d3e7dcc + b84410f commit 80bd360

File tree

9 files changed

+76
-67
lines changed

9 files changed

+76
-67
lines changed

‎.flutter-plugins-dependencies‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"info":"This is a generated file; do not edit or check into version control.","plugins":{"ios":[{"name":"path_provider","path":"C:\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\path_provider-0.5.0+1\\\\","dependencies":[]},{"name":"sqflite","path":"C:\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\sqflite-1.1.7+1\\\\","dependencies":[]}],"android":[{"name":"path_provider","path":"C:\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\path_provider-0.5.0+1\\\\","dependencies":[]},{"name":"sqflite","path":"C:\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\sqflite-1.1.7+1\\\\","dependencies":[]}],"macos":[],"linux":[],"windows":[],"web":[]},"dependencyGraph":[{"name":"path_provider","dependencies":[]},{"name":"sqflite","dependencies":[]}],"date_created":"2021年04月03日 13:49:24.788518","version":"2.0.3"}

‎lib/bloc/bloc_delegate.dart‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import 'package:bloc/bloc.dart';
22

3-
class SimpleBlocDelegate extends BlocDelegate {
3+
class SimpleBlocObserver extends BlocObserver {
44
@override
55
void onEvent(Bloc bloc, Object event) {
66
super.onEvent(bloc, event);
@@ -14,8 +14,8 @@ class SimpleBlocDelegate extends BlocDelegate {
1414
}
1515

1616
@override
17-
void onError(Bloc bloc, Object error, StackTrace stacktrace) {
17+
void onError(BlocBase bloc, Object error, StackTrace stacktrace) {
1818
super.onError(bloc, error, stacktrace);
1919
print('$error $stacktrace');
2020
}
21-
}
21+
}

‎lib/bloc/user_form/user_form_bloc.dart‎

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,19 @@ import './bloc.dart';
66

77
class UserFormBloc extends Bloc<UserFormEvent, UserFormState> {
88
final _userRepository = UserRepository();
9-
10-
@override
11-
UserFormState get initialState => InitialUserFormState();
9+
10+
UserFormBloc() : super(InitialUserFormState());
1211

1312
@override
1413
Stream<UserFormState> mapEventToState(UserFormEvent event) async* {
1514
yield Loading();
1615
if (event is GetUser) {
1716
try {
18-
yield Loaded(user: event.user?.id == null ? User() : await _userRepository.getUser(event.user?.id));
19-
} catch(e) {
17+
yield Loaded(
18+
user: event.user?.id == null
19+
? User()
20+
: await _userRepository.getUser(event.user?.id));
21+
} catch (e) {
2022
yield Error(errorMessage: e.toString());
2123
}
2224
} else if (event is BackEvent) {
@@ -25,14 +27,14 @@ class UserFormBloc extends Bloc<UserFormEvent, UserFormState> {
2527
try {
2628
await _userRepository.createUser(event.user);
2729
yield Success(successMessage: event.user.name + ' created');
28-
} catch(e) {
30+
} catch(e) {
2931
yield Error(errorMessage: e.toString());
3032
}
3133
} else if (event is UpdateUser) {
3234
try {
3335
await _userRepository.updateUser(event.user);
34-
yield Success(successMessage: event.user.name + ' updated');
35-
} catch(e) {
36+
yield Success(successMessage: event.user.name + ' updated');
37+
} catch(e) {
3638
yield Error(errorMessage: e.toString());
3739
}
3840
}

‎lib/bloc/user_list/user_list_bloc.dart‎

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,8 @@ import './bloc.dart';
66

77
class UserListBloc extends Bloc<UserListEvent, UserListState> {
88
final _userRepository = UserRepository();
9-
10-
@override
11-
UserListState get initialState => InitialUserListState();
9+
10+
UserListBloc() : super(InitialUserListState());
1211

1312
@override
1413
Stream<UserListState> mapEventToState(UserListEvent event) async* {
@@ -17,14 +16,14 @@ class UserListBloc extends Bloc<UserListEvent, UserListState> {
1716
try {
1817
List<User> users = await _userRepository.getUsers(query: event.query);
1918
yield Loaded(users: users);
20-
} catch(e) {
19+
} catch(e) {
2120
yield Error(errorMessage: e.toString());
2221
}
2322
} else if (event is DeleteUser) {
2423
try {
2524
await _userRepository.deleteUser(event.user.id);
2625
yield Loaded(users: await _userRepository.getUsers(query: event.query));
27-
} catch(e) {
26+
} catch(e) {
2827
yield Error(errorMessage: e.toString());
2928
}
3029
}

‎lib/main.dart‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ import 'package:flutter_crud_with_bloc_library/bloc/user_list/bloc.dart';
88
import 'package:flutter_crud_with_bloc_library/ui/view/user/list.dart';
99

1010
void main() {
11-
BlocSupervisor.delegate = SimpleBlocDelegate();
11+
WidgetsFlutterBinding.ensureInitialized();
12+
Bloc.observer = SimpleBlocObserver();
1213
SystemChrome.setEnabledSystemUIOverlays([]);
1314
SystemChrome.setPreferredOrientations([DeviceOrientation.portraitUp])
1415
.then((_) {
@@ -24,10 +25,10 @@ class MyApp extends StatelessWidget {
2425
theme: ThemeData(brightness: Brightness.dark),
2526
home: MultiBlocProvider(providers: [
2627
BlocProvider<UserListBloc>(
27-
builder: (context) => UserListBloc()..add(GetUsers()),
28+
create: (context) => UserListBloc()..add(GetUsers()),
2829
),
2930
BlocProvider<UserFormBloc>(
30-
builder: (context) => UserFormBloc(),
31+
create: (context) => UserFormBloc(),
3132
),
3233
], child: UserListScreen()),
3334
);

‎lib/ui/view/user/form.dart‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ class _UserFormScreenState extends State<UserFormScreen> {
4242
child: Center(
4343
child: SingleChildScrollView(
4444
child: BlocListener<UserFormBloc, UserFormState>(
45-
condition: (previousState, state) {
45+
listenWhen: (previousState, state) {
4646
return state is Success;
4747
},
4848
listener: (context, state) {
@@ -74,7 +74,6 @@ class _UserFormScreenState extends State<UserFormScreen> {
7474
}),
7575
TextFormField(
7676
keyboardType: TextInputType.emailAddress,
77-
7877
decoration: InputDecoration(
7978
labelText: 'Username',
8079
),

‎lib/ui/view/user/list.dart‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -68,13 +68,13 @@ class UserListScreen extends StatelessWidget {
6868
},
6969
child: BlocListener<_UserFormBloc.UserFormBloc,
7070
_UserFormBloc.UserFormState>(
71-
condition: (previousState, state) {
71+
listenWhen: (previousState, state) {
7272
return state is _UserFormBloc.Success;
7373
},
7474
listener: (context, state) {
75-
if (state.message.isNotEmpty) {
76-
_scaffoldKey.currentState
77-
.showSnackBar(snackBar(state.message));
75+
if (state.message.isNotEmpty) {
76+
_scaffoldKey.currentState
77+
.showSnackBar(snackBar(state.message));
7878
}
7979
},
8080
child: BlocBuilder<UserListBloc, UserListState>(

‎pubspec.lock‎

Lines changed: 48 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -7,42 +7,63 @@ packages:
77
name: async
88
url: "https://pub.dartlang.org"
99
source: hosted
10-
version: "2.3.0"
10+
version: "2.5.0"
1111
bloc:
1212
dependency: transitive
1313
description:
1414
name: bloc
1515
url: "https://pub.dartlang.org"
1616
source: hosted
17-
version: "1.0.0"
17+
version: "7.0.0"
1818
boolean_selector:
1919
dependency: transitive
2020
description:
2121
name: boolean_selector
2222
url: "https://pub.dartlang.org"
2323
source: hosted
24-
version: "1.0.5"
24+
version: "2.1.0"
25+
characters:
26+
dependency: transitive
27+
description:
28+
name: characters
29+
url: "https://pub.dartlang.org"
30+
source: hosted
31+
version: "1.1.0"
2532
charcode:
2633
dependency: transitive
2734
description:
2835
name: charcode
2936
url: "https://pub.dartlang.org"
3037
source: hosted
31-
version: "1.1.2"
38+
version: "1.2.0"
39+
clock:
40+
dependency: transitive
41+
description:
42+
name: clock
43+
url: "https://pub.dartlang.org"
44+
source: hosted
45+
version: "1.1.0"
3246
collection:
3347
dependency: transitive
3448
description:
3549
name: collection
3650
url: "https://pub.dartlang.org"
3751
source: hosted
38-
version: "1.14.11"
52+
version: "1.15.0"
3953
cupertino_icons:
4054
dependency: "direct main"
4155
description:
4256
name: cupertino_icons
4357
url: "https://pub.dartlang.org"
4458
source: hosted
4559
version: "0.1.2"
60+
fake_async:
61+
dependency: transitive
62+
description:
63+
name: fake_async
64+
url: "https://pub.dartlang.org"
65+
source: hosted
66+
version: "1.2.0"
4667
flutter:
4768
dependency: "direct main"
4869
description: flutter
@@ -54,7 +75,7 @@ packages:
5475
name: flutter_bloc
5576
url: "https://pub.dartlang.org"
5677
source: hosted
57-
version: "1.0.0"
78+
version: "7.0.0"
5879
flutter_test:
5980
dependency: "direct dev"
6081
description: flutter
@@ -66,56 +87,42 @@ packages:
6687
name: matcher
6788
url: "https://pub.dartlang.org"
6889
source: hosted
69-
version: "0.12.5"
90+
version: "0.12.10"
7091
meta:
7192
dependency: transitive
7293
description:
7394
name: meta
7495
url: "https://pub.dartlang.org"
7596
source: hosted
76-
version: "1.1.7"
97+
version: "1.3.0"
98+
nested:
99+
dependency: transitive
100+
description:
101+
name: nested
102+
url: "https://pub.dartlang.org"
103+
source: hosted
104+
version: "1.0.0"
77105
path:
78106
dependency: transitive
79107
description:
80108
name: path
81109
url: "https://pub.dartlang.org"
82110
source: hosted
83-
version: "1.6.4"
111+
version: "1.8.0"
84112
path_provider:
85113
dependency: "direct main"
86114
description:
87115
name: path_provider
88116
url: "https://pub.dartlang.org"
89117
source: hosted
90118
version: "0.5.0+1"
91-
pedantic:
92-
dependency: transitive
93-
description:
94-
name: pedantic
95-
url: "https://pub.dartlang.org"
96-
source: hosted
97-
version: "1.8.0+1"
98119
provider:
99120
dependency: transitive
100121
description:
101122
name: provider
102123
url: "https://pub.dartlang.org"
103124
source: hosted
104-
version: "3.1.0+1"
105-
quiver:
106-
dependency: transitive
107-
description:
108-
name: quiver
109-
url: "https://pub.dartlang.org"
110-
source: hosted
111-
version: "2.0.5"
112-
rxdart:
113-
dependency: transitive
114-
description:
115-
name: rxdart
116-
url: "https://pub.dartlang.org"
117-
source: hosted
118-
version: "0.22.4"
125+
version: "5.0.0"
119126
sky_engine:
120127
dependency: transitive
121128
description: flutter
@@ -127,7 +134,7 @@ packages:
127134
name: source_span
128135
url: "https://pub.dartlang.org"
129136
source: hosted
130-
version: "1.5.5"
137+
version: "1.8.0"
131138
sqflite:
132139
dependency: "direct main"
133140
description:
@@ -141,21 +148,21 @@ packages:
141148
name: stack_trace
142149
url: "https://pub.dartlang.org"
143150
source: hosted
144-
version: "1.9.3"
151+
version: "1.10.0"
145152
stream_channel:
146153
dependency: transitive
147154
description:
148155
name: stream_channel
149156
url: "https://pub.dartlang.org"
150157
source: hosted
151-
version: "2.0.0"
158+
version: "2.1.0"
152159
string_scanner:
153160
dependency: transitive
154161
description:
155162
name: string_scanner
156163
url: "https://pub.dartlang.org"
157164
source: hosted
158-
version: "1.0.5"
165+
version: "1.1.0"
159166
synchronized:
160167
dependency: transitive
161168
description:
@@ -169,28 +176,28 @@ packages:
169176
name: term_glyph
170177
url: "https://pub.dartlang.org"
171178
source: hosted
172-
version: "1.1.0"
179+
version: "1.2.0"
173180
test_api:
174181
dependency: transitive
175182
description:
176183
name: test_api
177184
url: "https://pub.dartlang.org"
178185
source: hosted
179-
version: "0.2.5"
186+
version: "0.2.19"
180187
typed_data:
181188
dependency: transitive
182189
description:
183190
name: typed_data
184191
url: "https://pub.dartlang.org"
185192
source: hosted
186-
version: "1.1.6"
193+
version: "1.3.0"
187194
vector_math:
188195
dependency: transitive
189196
description:
190197
name: vector_math
191198
url: "https://pub.dartlang.org"
192199
source: hosted
193-
version: "2.0.8"
200+
version: "2.1.0"
194201
sdks:
195-
dart: ">=2.5.0 <3.0.0"
196-
flutter: ">=1.9.1 <2.0.0"
202+
dart: ">=2.12.0-0.0 <3.0.0"
203+
flutter: ">=1.16.0"

‎pubspec.yaml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ dependencies:
2525
cupertino_icons: ^0.1.2
2626
sqflite: ^1.1.0
2727
path_provider: ^0.5.0+1
28-
flutter_bloc: ^1.0.0
28+
flutter_bloc: ^7.0.0
2929

3030
dev_dependencies:
3131
flutter_test:

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /