-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
6 changed files
with
37 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,32 @@ | ||
// SPDX-FileCopyrightText: 2024 Benoit Rolandeau <[email protected]> | ||
// | ||
// SPDX-License-Identifier: MIT | ||
|
||
import 'package:equatable/equatable.dart'; | ||
|
||
/// A simple model with a name and an age to be parsed as config | ||
class AModel extends Equatable { | ||
/// The key for the name in the json | ||
static const nameKey = 'name'; | ||
|
||
/// The key for the age in the json | ||
static const ageKey = 'age'; | ||
|
||
/// The name of the model | ||
final String name; | ||
|
||
/// The age of the model | ||
final int age; | ||
|
||
/// Creates a new AModel | ||
const AModel({ | ||
required this.name, | ||
required this.age, | ||
}); | ||
|
||
/// Creates a new AModel from a json | ||
// The type is dynamic because we can parse the model from a json object or array | ||
// ignore: avoid_annotating_with_dynamic | ||
static AModel? fromJson(dynamic json) { | ||
if (json is! Map<String, dynamic>) { | ||
return null; | ||
|
@@ -30,6 +45,7 @@ class AModel extends Equatable { | |
); | ||
} | ||
|
||
/// Model properties | ||
@override | ||
List<Object?> get props => [name, age]; | ||
} |
6 changes: 6 additions & 0 deletions
6
bro_global_manager/lib/src/models/global_manager_not_created_error.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,10 @@ | ||
// SPDX-FileCopyrightText: 2024 Benoit Rolandeau <[email protected]> | ||
// | ||
// SPDX-License-Identifier: MIT | ||
|
||
/// Error thrown when the global manager was not created and we try to access it. | ||
class GlobalManagerNotCreatedError extends Error { | ||
/// Returns a string representation of this error. | ||
@override | ||
String toString() => "The global manager was not created."; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,7 @@ | ||
# SPDX-FileCopyrightText: 2024 Benoit Rolandeau <[email protected]> | ||
# | ||
# SPDX-License-Identifier: MIT | ||
|
||
# Miscellaneous | ||
*.class | ||
*.log | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters