Skip to content

Commit d1d2754

Browse files
committed
Simplify the codebase by using the single line functions style or new switch statement
1 parent d1e7e66 commit d1d2754

25 files changed

+782
-914
lines changed

example/lib/presentation/menu/app_menu.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,12 @@ class AppMenu extends StatefulWidget {
1919
final VoidCallback? onBannerClicked;
2020

2121
const AppMenu({
22-
Key? key,
22+
super.key,
2323
required this.menuItems,
2424
required this.currentSelectedIndex,
2525
required this.onItemSelected,
2626
required this.onBannerClicked,
27-
}) : super(key: key);
27+
});
2828

2929
@override
3030
AppMenuState createState() => AppMenuState();

example/lib/presentation/menu/fl_chart_banner.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import 'package:flutter/material.dart';
33
import 'package:flutter_svg/flutter_svg.dart';
44

55
class FlChartBanner extends StatelessWidget {
6-
const FlChartBanner({Key? key}) : super(key: key);
6+
const FlChartBanner({super.key});
77

88
@override
99
Widget build(BuildContext context) {

example/lib/presentation/menu/menu_row.dart

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,13 @@ class MenuRow extends StatefulWidget {
1010
final VoidCallback onDocumentsTap;
1111

1212
const MenuRow({
13-
Key? key,
13+
super.key,
1414
required this.text,
1515
required this.svgPath,
1616
required this.isSelected,
1717
required this.onTap,
1818
required this.onDocumentsTap,
19-
}) : super(key: key);
19+
});
2020

2121
@override
2222
State<MenuRow> createState() => _MenuRowState();
@@ -77,9 +77,8 @@ class _MenuRowState extends State<MenuRow> {
7777

7878
class _DocumentationIcon extends StatelessWidget {
7979
const _DocumentationIcon({
80-
Key? key,
8180
required this.onTap,
82-
}) : super(key: key);
81+
});
8382
final VoidCallback onTap;
8483

8584
@override

example/lib/presentation/pages/chart_samples_page.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@ class ChartSamplesPage extends StatelessWidget {
1111
final samples = ChartSamples.samples;
1212

1313
ChartSamplesPage({
14-
Key? key,
14+
super.key,
1515
required this.chartType,
16-
}) : super(key: key);
16+
});
1717

1818
@override
1919
Widget build(BuildContext context) {

example/lib/presentation/pages/home_page.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@ import 'chart_samples_page.dart';
1111

1212
class HomePage extends StatelessWidget {
1313
HomePage({
14-
Key? key,
14+
super.key,
1515
required this.showingChartType,
16-
}) : super(key: key) {
16+
}) {
1717
_initMenuItems();
1818
}
1919

example/lib/presentation/router/app_router.dart

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -13,20 +13,18 @@ final appRouterConfig = GoRouter(
1313
return '/${ChartType.values.first.name}';
1414
},
1515
),
16-
...ChartType.values
17-
.map(
18-
(ChartType chartType) => GoRoute(
19-
path: '/${chartType.name}',
20-
pageBuilder: (BuildContext context, GoRouterState state) =>
21-
MaterialPage<void>(
22-
/// We set a key for HomePage to prevent recreate it
23-
/// when user choose a new chart type to show
24-
key: const ValueKey('home_page'),
25-
child: HomePage(showingChartType: chartType),
26-
),
27-
),
28-
)
29-
.toList(),
16+
...ChartType.values.map(
17+
(ChartType chartType) => GoRoute(
18+
path: '/${chartType.name}',
19+
pageBuilder: (BuildContext context, GoRouterState state) =>
20+
MaterialPage<void>(
21+
/// We set a key for HomePage to prevent recreate it
22+
/// when user choose a new chart type to show
23+
key: const ValueKey('home_page'),
24+
child: HomePage(showingChartType: chartType),
25+
),
26+
),
27+
),
3028
GoRoute(
3129
path: '/:any',
3230
builder: (context, state) => Container(color: AppColors.pageBackground),

example/lib/presentation/widgets/chart_holder.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ class ChartHolder extends StatelessWidget {
77
final ChartSample chartSample;
88

99
const ChartHolder({
10-
Key? key,
10+
super.key,
1111
required this.chartSample,
12-
}) : super(key: key);
12+
});
1313

1414
@override
1515
Widget build(BuildContext context) {

0 commit comments

Comments
 (0)