File tree Expand file tree Collapse file tree 10 files changed +39
-17
lines changed
Expand file tree Collapse file tree 10 files changed +39
-17
lines changed Original file line number Diff line number Diff line change @@ -6,4 +6,5 @@ import 'package:injectable/injectable.dart';
66final getIt = GetIt .instance;
77
88@InjectableInit ()
9- Future <void > configureDependencies () async => getIt.init (environment: kDebugMode ? dev.name : prod.name);
9+ Future <void > configureDependencies () async =>
10+ getIt.init (environment: kDebugMode ? dev.name : prod.name);
Original file line number Diff line number Diff line change @@ -36,15 +36,21 @@ class MyHomePage extends StatelessWidget {
3636 ElevatedButton (
3737 onPressed: () => Navigator .of (context).push (
3838 MaterialPageRoute (
39- builder: (context) => UserPage (onCreateCubit: (context) => getIt <UserCubit >()..getRandomUser ()),
39+ builder: (context) => UserPage (
40+ onCreateCubit: (context) =>
41+ getIt <UserCubit >()..getRandomUser (),
42+ ),
4043 ),
4144 ),
4245 child: const Text ('Get user succesfully' ),
4346 ),
4447 ElevatedButton (
4548 onPressed: () => Navigator .of (context).push (
4649 MaterialPageRoute (
47- builder: (context) => UserPage (onCreateCubit: (context) => getIt <UserCubit >()..getRandomUserFails ()),
50+ builder: (context) => UserPage (
51+ onCreateCubit: (context) =>
52+ getIt <UserCubit >()..getRandomUserFails (),
53+ ),
4854 ),
4955 ),
5056 child: const Text ('Get user fails' ),
Original file line number Diff line number Diff line change @@ -11,5 +11,6 @@ class ApiUserResponse with _$ApiUserResponse {
1111 required List <User > results,
1212 }) = _ApiUserResponse ;
1313
14- factory ApiUserResponse .fromJson (Map <String , dynamic > json) => _$ApiUserResponseFromJson (json);
15- }
14+ factory ApiUserResponse .fromJson (Map <String , dynamic > json) =>
15+ _$ApiUserResponseFromJson (json);
16+ }
Original file line number Diff line number Diff line change @@ -14,5 +14,6 @@ class Location with _$Location {
1414 required String country,
1515 }) = _Location ;
1616
17- factory Location .fromJson (Map <String , dynamic > json) => _$LocationFromJson (json);
18- }
17+ factory Location .fromJson (Map <String , dynamic > json) =>
18+ _$LocationFromJson (json);
19+ }
Original file line number Diff line number Diff line change @@ -12,4 +12,4 @@ class Name with _$Name {
1212 }) = _Name ;
1313
1414 factory Name .fromJson (Map <String , dynamic > json) => _$NameFromJson (json);
15- }
15+ }
Original file line number Diff line number Diff line change @@ -11,5 +11,6 @@ class Picture with _$Picture {
1111 required String thumbnail,
1212 }) = _Picture ;
1313
14- factory Picture .fromJson (Map <String , dynamic > json) => _$PictureFromJson (json);
15- }
14+ factory Picture .fromJson (Map <String , dynamic > json) =>
15+ _$PictureFromJson (json);
16+ }
Original file line number Diff line number Diff line change @@ -11,4 +11,4 @@ class Street with _$Street {
1111 }) = _Street ;
1212
1313 factory Street .fromJson (Map <String , dynamic > json) => _$StreetFromJson (json);
14- }
14+ }
Original file line number Diff line number Diff line change @@ -10,7 +10,8 @@ part 'user_cubit.freezed.dart';
1010part 'user_state.dart' ;
1111
1212@injectable
13- class UserCubit extends Cubit <UserState > with BlocPresentationMixin <UserState , UserEvent > {
13+ class UserCubit extends Cubit <UserState >
14+ with BlocPresentationMixin <UserState , UserEvent > {
1415 UserCubit (this ._userRepo) : super (const UserState (user: null ));
1516
1617 final UserRepository _userRepo;
Original file line number Diff line number Diff line change @@ -4,14 +4,14 @@ sealed class UserEvent {
44
55class UserLoaded implements UserEvent {
66 const UserLoaded ();
7-
7+
88 @override
99 String get reason => 'User loaded' ;
1010}
1111
1212class UserFetchFailed implements UserEvent {
1313 const UserFetchFailed ();
14-
14+
1515 @override
1616 String get reason => 'User fetch failed' ;
1717}
Original file line number Diff line number Diff line change @@ -4,19 +4,30 @@ import 'package:example/profile/presentation/cubit/user_event.dart';
44import 'package:flutter/material.dart' ;
55
66class UserPage extends BlocfulWidget <UserCubit , UserState , UserEvent > {
7- const UserPage ({required this .onCreateCubit, super .key}) : super (onCreateBloc: onCreateCubit);
7+ const UserPage ({required this .onCreateCubit, super .key})
8+ : super (onCreateBloc: onCreateCubit);
89
910 final UserCubit Function (BuildContext )? onCreateCubit;
1011
1112 @override
1213 void onPresentationEvent (BuildContext context, UserEvent event) {
13- ScaffoldMessenger .of (context).showSnackBar (SnackBar (content: Text (event.reason)));
14+ ScaffoldMessenger .of (context)
15+ .showSnackBar (SnackBar (content: Text (event.reason)));
1416 }
1517
1618 @override
1719 Widget builder (BuildContext context, UserCubit bloc, UserState state) {
1820 return Scaffold (
19- body: Center (child: Text (state.user? .email ?? '' )),
21+ body: SafeArea (
22+ child: Center (
23+ child: Column (
24+ mainAxisAlignment: MainAxisAlignment .center,
25+ children: [
26+ Text (state.user? .email ?? '' ),
27+ Text (state.user? .phone ?? '' ),
28+ ],
29+ )),
30+ ),
2031 );
2132 }
2233}
You can’t perform that action at this time.
0 commit comments