Skip to content

Commit 5c9869a

Browse files
committed
Refactor expressions
1 parent 56ec9fe commit 5c9869a

21 files changed

+384
-429
lines changed

lib/app/app.dart

Lines changed: 54 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -13,73 +13,70 @@ class MyApp extends StatelessWidget {
1313
});
1414

1515
@override
16-
Widget build(BuildContext context) {
17-
return MultiRepositoryProvider(
18-
providers: [
19-
RepositoryProvider<EmailListRepository>(
20-
create: (context) => EmailListRepository(),
21-
),
22-
RepositoryProvider<NavigationService>(
23-
create: (context) => NavigationService(),
24-
),
25-
],
26-
child: MultiBlocProvider(
16+
Widget build(BuildContext context) => MultiRepositoryProvider(
2717
providers: [
28-
BlocProvider(
29-
create: (context) => ThemeCubit(diContainer.get())..loadTheme(),
18+
RepositoryProvider<EmailListRepository>(
19+
create: (context) => EmailListRepository(),
3020
),
31-
BlocProvider(
32-
create: (context) => EmailListBloc(
33-
messagesRepository:
34-
RepositoryProvider.of<EmailListRepository>(context),
35-
)..add(
36-
EmailListFetched(),
37-
),
38-
),
39-
BlocProvider<InitBloc>(
40-
create: (_) => InitBloc()
41-
..add(
42-
StartAppEvent(),
43-
),
21+
RepositoryProvider<NavigationService>(
22+
create: (context) => NavigationService(),
4423
),
4524
],
46-
child: Builder(
47-
builder: (context) {
48-
final navigator = NavigationService.of(context);
25+
child: MultiBlocProvider(
26+
providers: [
27+
BlocProvider(
28+
create: (context) => ThemeCubit(diContainer.get())..loadTheme(),
29+
),
30+
BlocProvider(
31+
create: (context) => EmailListBloc(
32+
messagesRepository:
33+
RepositoryProvider.of<EmailListRepository>(context),
34+
)..add(
35+
EmailListFetched(),
36+
),
37+
),
38+
BlocProvider<InitBloc>(
39+
create: (_) => InitBloc()
40+
..add(
41+
StartAppEvent(),
42+
),
43+
),
44+
],
45+
child: Builder(
46+
builder: (context) {
47+
final navigator = NavigationService.of(context);
4948

50-
return MaterialApp(
51-
debugShowCheckedModeBanner: kDebugMode,
52-
restorationScopeId: 'app',
53-
localizationsDelegates: const [
54-
S.delegate,
55-
GlobalMaterialLocalizations.delegate,
56-
GlobalWidgetsLocalizations.delegate,
57-
GlobalCupertinoLocalizations.delegate,
58-
],
59-
supportedLocales: const [
60-
Locale('en', ''), // English, no country code
61-
Locale('de', ''), // Ukraine, no country code
62-
],
63-
onGenerateTitle: (BuildContext context) => S.of(context).appTitle,
64-
theme: context.watch<ThemeCubit>().getDefaultTheme(),
65-
darkTheme: context.watch<ThemeCubit>().darkTheme,
66-
themeMode: context.watch<ThemeCubit>().themeMode,
67-
navigatorKey: appNavigatorKey,
68-
onGenerateRoute: navigator.onGenerateRoute,
69-
builder: (_, child) {
70-
return BlocListener<InitBloc, InitState>(
49+
return MaterialApp(
50+
debugShowCheckedModeBanner: kDebugMode,
51+
restorationScopeId: 'app',
52+
localizationsDelegates: const [
53+
S.delegate,
54+
GlobalMaterialLocalizations.delegate,
55+
GlobalWidgetsLocalizations.delegate,
56+
GlobalCupertinoLocalizations.delegate,
57+
],
58+
supportedLocales: const [
59+
Locale('en', ''), // English, no country code
60+
Locale('de', ''), // Ukraine, no country code
61+
],
62+
onGenerateTitle: (BuildContext context) =>
63+
S.of(context).appTitle,
64+
theme: context.watch<ThemeCubit>().getDefaultTheme(),
65+
darkTheme: context.watch<ThemeCubit>().darkTheme,
66+
themeMode: context.watch<ThemeCubit>().themeMode,
67+
navigatorKey: appNavigatorKey,
68+
onGenerateRoute: navigator.onGenerateRoute,
69+
builder: (_, child) => BlocListener<InitBloc, InitState>(
7170
listener: (_, state) {
7271
if (state is OpenApp) {
7372
navigator.pushAndRemoveAll(Routes.app);
7473
}
7574
},
7675
child: child,
77-
);
78-
},
79-
);
80-
},
76+
),
77+
);
78+
},
79+
),
8180
),
82-
),
83-
);
84-
}
81+
);
8582
}

lib/di/di_repository_module.dart

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import 'package:injectable/injectable.dart';
55
@module
66
abstract class RepositoryModule {
77
@factoryMethod
8-
ThemeRepository provideAccidentsRepository(ThemeStorage themeStorage) {
9-
return ThemeRepositoryImpl(themeStorage);
10-
}
8+
ThemeRepository provideAccidentsRepository(ThemeStorage themeStorage) =>
9+
ThemeRepositoryImpl(themeStorage);
1110
}

lib/features/contacts/contacts_screen.dart

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,5 @@ class ContactsScreen extends StatelessWidget {
44
const ContactsScreen({super.key});
55

66
@override
7-
Widget build(BuildContext context) {
8-
return const Placeholder();
9-
}
7+
Widget build(BuildContext context) => const Placeholder();
108
}

lib/features/email_list/email_list_screen.dart

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -10,20 +10,18 @@ class EmailListScreen extends StatelessWidget {
1010
static const routeName = '/';
1111

1212
@override
13-
Widget build(BuildContext context) {
14-
return Scaffold(
15-
appBar: AppBar(
16-
title: Text(S.of(context).messagesTitle),
17-
),
18-
body: RefreshIndicator(
19-
onRefresh: () async {
20-
await Future<void>.delayed(const Duration(seconds: 1));
21-
},
22-
child: SizedBox(
23-
height: MediaQuery.of(context).size.height,
24-
child: EmailListView(),
13+
Widget build(BuildContext context) => Scaffold(
14+
appBar: AppBar(
15+
title: Text(S.of(context).messagesTitle),
2516
),
26-
),
27-
);
28-
}
17+
body: RefreshIndicator(
18+
onRefresh: () async {
19+
await Future<void>.delayed(const Duration(seconds: 1));
20+
},
21+
child: SizedBox(
22+
height: MediaQuery.of(context).size.height,
23+
child: EmailListView(),
24+
),
25+
),
26+
);
2927
}

lib/features/email_list/view/attachment_icon.dart

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,7 @@ class AttachmentIcon extends StatelessWidget {
88
final VoidCallback? onTap;
99

1010
@override
11-
Widget build(BuildContext context) {
12-
return attachment.type == AttachmentType.doc
13-
? AppIcons.attachmentDoc
14-
: AppIcons.attachmentPdf;
15-
}
11+
Widget build(BuildContext context) => attachment.type == AttachmentType.doc
12+
? AppIcons.attachmentDoc
13+
: AppIcons.attachmentPdf;
1614
}

0 commit comments

Comments
 (0)