Skip to content

Commit 087f402

Browse files
committed
fix: comply to lint rules
1 parent d77e906 commit 087f402

23 files changed

+240
-162
lines changed

analysis_options.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ plugins:
88
ignorable: true
99
abstract_classes_should_set_log_group: true
1010
concrete_classes_should_set_log_tag: true
11+
base_class:
12+
ignorable: true
13+
enabled: true
1114
analyzer:
1215
exclude:
1316
- "**/*.g.dart"

lib/src/domain/datasources/datasource.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import 'package:get_it/get_it.dart' hide Disposable;
2+
import 'package:grumpy_annotations/grumpy_annotations.dart';
23
import 'package:logging/logging.dart';
34
import 'package:meta/meta.dart';
45
import 'package:grumpy/grumpy.dart';
@@ -7,6 +8,7 @@ import 'package:grumpy/grumpy.dart';
78
// ignore: datasources_must_extend_datasource
89
/// A datasource is responsible for providing data from a specific source,
910
/// such as a database, API, or local storage.
11+
@BaseClass(allowedLayers: {.domain, .infra})
1012
abstract class Datasource with LogMixin, Disposable, TelemetryMixin {
1113
/// A datasource is responsible for providing data from a specific source,
1214
/// such as a database, API, or local storage.

lib/src/domain/domain.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
export 'models/models.dart';
22
export 'datasources/datasources.dart';
33
export 'services/services.dart';
4+
export 'errors/errors.dart';

lib/src/domain/errors/errors.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
export 'repo_state_error.dart';
2+
export 'no_repo_data_error.dart';
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import 'package:grumpy/grumpy.dart';
2+
3+
/// An error indicating that no data is available in a [RepoState].
4+
///
5+
/// Thrown when attempting to access data from a state that does not contain data.
6+
class NoRepoDataError extends RepoStateError {
7+
/// Creates a [NoRepoDataError] for the given [state].
8+
NoRepoDataError(RepoState state)
9+
: super(state, 'No data available in RepoState. Current state: $state');
10+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import 'package:grumpy/grumpy.dart';
2+
import 'package:grumpy/src/domain/models/repo_state.dart';
3+
4+
/// An error indicating an invalid state in a [RepoState].
5+
///
6+
/// Thrown when attempting to access data or error information
7+
/// that is not available in the current state.
8+
class RepoStateError extends StateError {
9+
/// The [RepoState] that caused this error.
10+
final RepoState state;
11+
12+
/// Creates a [RepoStateError] for the given [state] with an optional [message].
13+
RepoStateError(this.state, super.message);
14+
}

lib/src/domain/models/leaf.dart

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import 'dart:async';
2+
3+
import 'package:grumpy/grumpy.dart';
4+
5+
// this is the base class for views.
6+
// ignore: views_must_extend_view, views_must_have_view_suffix
7+
/// The presentation of a route of type [T].
8+
abstract class Leaf<T> extends Model {
9+
/// Creates a [Leaf].
10+
const Leaf();
11+
12+
/// Builds a preview presentation of [T] while the route is being validated.
13+
///
14+
/// This can be used to show a loading indicator or a placeholder while
15+
/// a guard is being checked.
16+
///
17+
/// Note: It is unsafe to perform navigation actions or to use
18+
/// any module-dependent resources in this method, as the module
19+
/// may not have been fully initialized yet when this method is called.
20+
T preview(RouteContext ctx);
21+
22+
/// Builds the final presentation of [T] once the route has been validated.
23+
FutureOr<T> content(RouteContext ctx);
24+
}
25+
26+
// this is an extension of Route and not a view.
27+
// ignore: views_must_extend_view, views_must_have_view_suffix
Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,5 @@
1-
import 'dart:async';
2-
31
import 'package:grumpy/grumpy.dart';
42

5-
// this is the base class for views.
6-
// ignore: views_must_extend_view, views_must_have_view_suffix
7-
/// The presentation of a route of type [T].
8-
abstract class Leaf<T> {
9-
/// Creates a [Leaf].
10-
const Leaf();
11-
12-
/// Builds a preview presentation of [T] while the route is being validated.
13-
///
14-
/// This can be used to show a loading indicator or a placeholder while
15-
/// a guard is being checked.
16-
///
17-
/// Note: It is unsafe to perform navigation actions or to use
18-
/// any module-dependent resources in this method, as the module
19-
/// may not have been fully initialized yet when this method is called.
20-
T preview(RouteContext ctx);
21-
22-
/// Builds the final presentation of [T] once the route has been validated.
23-
FutureOr<T> content(RouteContext ctx);
24-
}
25-
26-
// this is an extension of Route and not a view.
27-
// ignore: views_must_extend_view, views_must_have_view_suffix
283
/// A route that directly renders a [Leaf] when matched.
294
///
305
/// Use [LeafRoute] for leaf routes that don't require their own [Module]

lib/src/domain/models/model.dart

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
// this is the base class.
22
// ignore: models_must_extend_model
3+
import 'package:grumpy_annotations/grumpy_annotations.dart';
4+
35
/// Marker class for all models used in the grumpy.
6+
@BaseClass(allowedLayers: {.domain}, forceSuffix: false)
47
abstract class Model {
58
/// Marker class for all models used in the grumpy.
69
const Model();

lib/src/domain/models/models.dart

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,9 @@ export 'optimistic_policy.dart';
55
export 'retry_policy.dart';
66
export 'route.dart';
77
export 'route_context.dart';
8+
export 'repo_loading_state.dart';
9+
export 'repo_data_state.dart';
10+
export 'repo_error_state.dart';
11+
export 'module_route.dart';
12+
export 'leaf_route.dart';
13+
export 'leaf.dart';

0 commit comments

Comments
 (0)