Skip to content

Commit

Permalink
adding ThemeData extension
Browse files Browse the repository at this point in the history
  • Loading branch information
Olivier-plessis committed Sep 2, 2024
1 parent af2bd34 commit 82c07df
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 11 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ New to Mason? Read [the documentation][mason_doc_link] to learn how to spin up t

| Brick | Description| Version |
| - | - | - |
| [scaffold_app](https://github.com/Olivier-plessis/melos_and_mason_bricks/tree/feature/bricks/bricks/scaffold_app)| A brick to generate a new Flutter app with clean architecture and best practices. | 0.0.1
| [scaffold_app](https://github.com/Olivier-plessis/melos_and_mason_bricks/tree/feature/bricks/bricks/scaffold_app)| A brick to generate a new Flutter app with clean architecture and best practices. | 0.2.0
| [feature_brick](https://github.com/Olivier-plessis/melos_and_mason_bricks/tree/feature/bricks/bricks/feature_brick)| A brick to add a new feature to your app with go_router! | 0.0.1
| [feature_brick_go_router_builder](https://github.com/Olivier-plessis/melos_and_mason_bricks/tree/feature/bricks/bricks/feature_brick_go_router_builder)| A brick to add a new feature to your app with go_router_builder! | 0.0.1
|Work in progress...| Another brick to create your feature using best practices and your state management of choice!
Expand Down
6 changes: 4 additions & 2 deletions bricks/scaffold_app/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,9 @@ Follow the instructions in the prompt and **VOILA**, your app is now installed i
│   │   │   ├── custom_appbar_widget.dart // just an exemple
│   │   ├── core
│   │   │   ├── theme
│   │   │   ├── dark_theme.dart
│   │   │   ├── light_theme.dart
│   │   │   ├── app_theme_data.dart // extending ThemeData
│   │   │   ├── dark_theme.dart // using flex_color_scheme
│   │   │   ├── light_theme.dart // using flex_color_scheme
│   │   │   ├── theme_mode_controller.dart
│   │   │   ├── utils
│   │   │   ├── dio_provider.dart
Expand Down Expand Up @@ -118,3 +119,4 @@ analyzer:
- custom_lint
```
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:hooks_riverpod/hooks_riverpod.dart';
import 'package:{{name.snakeCase()}}/src/core/theme/dark_theme.dart';
import 'package:{{name.snakeCase()}}/src/core/theme/light_theme.dart';
import 'package:{{name.snakeCase()}}/src/core/theme/app_theme_data.dart';
import 'package:{{name.snakeCase()}}/src/core/theme/theme_mode_controller.dart';
import 'package:{{name.snakeCase()}}/src/router/app_router.dart';

Expand All @@ -13,8 +12,6 @@ class MainApp extends ConsumerWidget {
Widget build(BuildContext context, WidgetRef ref) {
final ThemeMode themeMode = ref.watch(themeModeControllerProvider);

final theme = themeMode == ThemeMode.light ? lightTheme : darkTheme;

final goRouter = ref.watch(goRouterProvider);
return ScreenUtilInit(
designSize: ScreenUtil.defaultSize,
Expand All @@ -24,10 +21,10 @@ class MainApp extends ConsumerWidget {
routerConfig: goRouter,
debugShowCheckedModeBanner: false,
restorationScopeId: 'app',
theme: theme,
darkTheme: theme,
theme: AppThemeData.light(),
darkTheme: AppThemeData.dark(),
themeMode: themeMode,
onGenerateTitle: (BuildContext context) => 'mason starter',
onGenerateTitle: (BuildContext context) => '${name.sentenceCase()}',
builder: (
BuildContext context,
Widget? child,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import 'package:flex_color_scheme/flex_color_scheme.dart';
import 'package:flutter/material.dart';

extension AppThemeData on ThemeData {
static ThemeData light() =>
lightTheme._customAppTheme();
static ThemeData dark() =>
darkTheme._customAppTheme();

ThemeData _customAppTheme() {
// An updated theme with your own
return copyWith(

);
}
}
2 changes: 1 addition & 1 deletion bricks/scaffold_app/brick.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: scaffold_app
description: A Riverpod clean architecture feature builder based on solid principles for Flutter projects.

version: 0.1.0+1
version: 0.2.0

# The following defines the environment for the current brick.
# It includes the version of mason that the brick requires.
Expand Down

0 comments on commit 82c07df

Please sign in to comment.