Skip to content

Commit 501fbc2

Browse files
committed
Adopt Riverpod codegen and reorganize models
1 parent 9005fb8 commit 501fbc2

7 files changed

Lines changed: 47 additions & 19 deletions

File tree

lib/providers/dashboard/dashboard_controller.dart

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
1-
import 'package:flutter_riverpod/flutter_riverpod.dart';
1+
import 'package:riverpod_annotation/riverpod_annotation.dart';
22

3-
import 'dashboard_state.dart';
3+
import 'models/dashboard_state.dart';
4+
import 'models/enums/dashboard_list_filter.dart';
5+
6+
part 'dashboard_controller.g.dart';
47

58
/// Single controller for dashboard-related Riverpod state.
6-
class DashboardController extends Notifier<DashboardState> {
9+
@Riverpod(keepAlive: true)
10+
class DashboardController extends _$DashboardController {
711
@override
812
DashboardState build() => const DashboardState();
913

@@ -32,9 +36,3 @@ class DashboardController extends Notifier<DashboardState> {
3236
state = const DashboardState();
3337
}
3438
}
35-
36-
/// Unified dashboard state provider.
37-
final dashboardControllerProvider =
38-
NotifierProvider<DashboardController, DashboardState>(
39-
DashboardController.new,
40-
);

lib/providers/dashboard/dashboard_controller.g.dart

Lines changed: 29 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/providers/dashboard/dashboard_state.dart renamed to lib/providers/dashboard/models/dashboard_state.dart

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,8 @@
11
import 'package:freezed_annotation/freezed_annotation.dart';
22

3-
part 'dashboard_state.freezed.dart';
3+
import 'enums/dashboard_list_filter.dart';
44

5-
/// Filter applied to dashboard lists (tasks, tickets, meetings).
6-
enum DashboardListFilter {
7-
all,
8-
tasks,
9-
tickets,
10-
meetings,
11-
}
5+
part 'dashboard_state.freezed.dart';
126

137
/// Dashboard UI state managed by [DashboardController].
148
///

lib/providers/dashboard/dashboard_state.freezed.dart renamed to lib/providers/dashboard/models/dashboard_state.freezed.dart

File renamed without changes.
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
/// Filter applied to dashboard lists (tasks, tickets, meetings).
2+
enum DashboardListFilter {
3+
all,
4+
tasks,
5+
tickets,
6+
meetings,
7+
}

lib/providers/dashboard_provider.dart

Lines changed: 0 additions & 2 deletions
This file was deleted.

pubspec.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ dependencies:
4343
# State management
4444
provider: ^6.1.2
4545
flutter_riverpod: ^2.6.1
46+
riverpod_annotation: ^2.6.1
4647
freezed_annotation: ^2.4.4
4748

4849
# Local storage
@@ -88,6 +89,7 @@ dev_dependencies:
8889
flutter_lints: ^5.0.0
8990
build_runner: ^2.4.13
9091
freezed: ^2.5.7
92+
riverpod_generator: ^2.6.1
9193

9294
# For information on the generic Dart part of this file, see the
9395
# following page: https://dart.dev/tools/pub/pubspec

0 commit comments

Comments
 (0)