Skip to content

Commit

Permalink
Simplify the codebase by using the single line functions style or new…
Browse files Browse the repository at this point in the history
… switch statement
  • Loading branch information
imaNNeo committed Oct 20, 2024
1 parent d1e7e66 commit d1d2754
Show file tree
Hide file tree
Showing 25 changed files with 782 additions and 914 deletions.
4 changes: 2 additions & 2 deletions example/lib/presentation/menu/app_menu.dart
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@ class AppMenu extends StatefulWidget {
final VoidCallback? onBannerClicked;

const AppMenu({
Key? key,
super.key,
required this.menuItems,
required this.currentSelectedIndex,
required this.onItemSelected,
required this.onBannerClicked,
}) : super(key: key);
});

@override
AppMenuState createState() => AppMenuState();
Expand Down
2 changes: 1 addition & 1 deletion example/lib/presentation/menu/fl_chart_banner.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import 'package:flutter/material.dart';
import 'package:flutter_svg/flutter_svg.dart';

class FlChartBanner extends StatelessWidget {
const FlChartBanner({Key? key}) : super(key: key);
const FlChartBanner({super.key});

@override
Widget build(BuildContext context) {
Expand Down
7 changes: 3 additions & 4 deletions example/lib/presentation/menu/menu_row.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ class MenuRow extends StatefulWidget {
final VoidCallback onDocumentsTap;

const MenuRow({
Key? key,
super.key,
required this.text,
required this.svgPath,
required this.isSelected,
required this.onTap,
required this.onDocumentsTap,
}) : super(key: key);
});

@override
State<MenuRow> createState() => _MenuRowState();
Expand Down Expand Up @@ -77,9 +77,8 @@ class _MenuRowState extends State<MenuRow> {

class _DocumentationIcon extends StatelessWidget {
const _DocumentationIcon({
Key? key,
required this.onTap,
}) : super(key: key);
});
final VoidCallback onTap;

@override
Expand Down
4 changes: 2 additions & 2 deletions example/lib/presentation/pages/chart_samples_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ class ChartSamplesPage extends StatelessWidget {
final samples = ChartSamples.samples;

ChartSamplesPage({
Key? key,
super.key,
required this.chartType,
}) : super(key: key);
});

@override
Widget build(BuildContext context) {
Expand Down
4 changes: 2 additions & 2 deletions example/lib/presentation/pages/home_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ import 'chart_samples_page.dart';

class HomePage extends StatelessWidget {
HomePage({
Key? key,
super.key,
required this.showingChartType,
}) : super(key: key) {
}) {
_initMenuItems();
}

Expand Down
26 changes: 12 additions & 14 deletions example/lib/presentation/router/app_router.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,18 @@ final appRouterConfig = GoRouter(
return '/${ChartType.values.first.name}';
},
),
...ChartType.values
.map(
(ChartType chartType) => GoRoute(
path: '/${chartType.name}',
pageBuilder: (BuildContext context, GoRouterState state) =>
MaterialPage<void>(
/// We set a key for HomePage to prevent recreate it
/// when user choose a new chart type to show
key: const ValueKey('home_page'),
child: HomePage(showingChartType: chartType),
),
),
)
.toList(),
...ChartType.values.map(
(ChartType chartType) => GoRoute(
path: '/${chartType.name}',
pageBuilder: (BuildContext context, GoRouterState state) =>
MaterialPage<void>(
/// We set a key for HomePage to prevent recreate it
/// when user choose a new chart type to show
key: const ValueKey('home_page'),
child: HomePage(showingChartType: chartType),
),
),
),
GoRoute(
path: '/:any',
builder: (context, state) => Container(color: AppColors.pageBackground),
Expand Down
4 changes: 2 additions & 2 deletions example/lib/presentation/widgets/chart_holder.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ class ChartHolder extends StatelessWidget {
final ChartSample chartSample;

const ChartHolder({
Key? key,
super.key,
required this.chartSample,
}) : super(key: key);
});

@override
Widget build(BuildContext context) {
Expand Down
Loading

0 comments on commit d1d2754

Please sign in to comment.