Skip to content

Commit

Permalink
Merge pull request #108 from surfstudio/fix-dcm-warnings
Browse files Browse the repository at this point in the history
fix: Fixed dcm warnings.
  • Loading branch information
ekinsdrow authored Apr 10, 2024
2 parents ca349c4 + 86896b3 commit 339c48c
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 28 deletions.
8 changes: 4 additions & 4 deletions lib/core/failures/api_failure.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ base class ApiFailure extends Failure<DioException> {
/// Original error status code from [DioException].
final int? responseBodyCode;

/// Message
/// Message.
final String? message;

/// {@macro api_failure.class}
Expand All @@ -24,13 +24,13 @@ base class ApiFailure extends Failure<DioException> {
this.message,
});

// TODO(anyone): add getters for special status codes
// TODO(anyone): Add getters for special status codes.
/// Sample: ExpiredToken - refresh token has expired
// bool get isExpiredRefreshToken => statusCode == 102;
/// bool get isExpiredRefreshToken => statusCode == 102
}

/// {@template timeout_failure.class}
/// TimeoutException
/// TimeoutException.
/// {@endtemplate}
final class TimeoutFailure extends ApiFailure {
/// {@macro timeout_failure.class}
Expand Down
3 changes: 1 addition & 2 deletions lib/runner.dart
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,8 @@ Future<void> run(Environment env) async {
}

// TODO(init-project): Initialize Crashlytics.
// _setupCrashlytics();

// TODO(init-project): change as needed or remove.
// TODO(init-project): Change as needed or remove.
await SystemChrome.setPreferredOrientations([DeviceOrientation.portraitUp]);

await _runApp(env);
Expand Down
40 changes: 24 additions & 16 deletions lib/util/extensions/closures.dart
Original file line number Diff line number Diff line change
@@ -1,41 +1,49 @@
// ignore_for_file: prefer-match-file-name

/// Let extension
/// The closure that is passed as a parameter to extension methods.
typedef Closure<R, T> = R Function(T it);

/// Let extension.
extension LetX<T extends Object> on T {
/// Executes a closure, where the argument is the value itself
R let<R>(R Function(T it) closure) {
/// Executes a closure, where the argument is the value itself.
R let<R>(Closure<R, T> closure) {
return closure(this);
}

/// Executes a closure, where the argument is the value itself
R? run<R>(R? Function(T it) closure) {
/// Executes a closure, where the argument is the value itself.
R? run<R>(Closure<R?, T> closure) {
return closure(this);
}
}

/// Let nullable extension
/// Let nullable extension.
extension LetNullableX<T extends Object> on T? {
/// Executes a closure on a nullable value, where the argument is the value itself
R? let<R>(R Function(T it) closure) {
return this != null ? closure(this!) : null;
/// Executes a closure on a nullable value, where the argument is the value itself.
R? let<R>(Closure<R, T> closure) {
final object = this;

return object == null ? null : closure(object);
}

/// Executes a closure on a nullable value, where the argument is the value itself
R? run<R>(R? Function(T it) closure) {
return this != null ? closure(this!) : null;
/// Executes a closure on a nullable value, where the argument is the value itself.
R? run<R>(Closure<R?, T> closure) {
final object = this;

return object == null ? null : closure(object);
}
}

/// Also extension
/// Also extension.
extension AlsoX<T extends Object?> on T {
/// Additionally executes a closure and returns the value itself
T also(void Function(T it) closure) {
/// Additionally executes a closure and returns the value itself.
T also(Closure<void, T> closure) {
closure(this);

return this;
}
}

/// Repeat extension
/// Repeat extension.
extension RepeatX<T extends Object?> on T {
/// Returns a Iterable<T> containing this object repeated [times] times.
Iterable<T> repeat(int times) {
Expand Down
12 changes: 6 additions & 6 deletions pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -325,10 +325,10 @@ packages:
dependency: transitive
description:
name: firebase_core_web
sha256: d585bdf3c656c3f7821ba1bd44da5f13365d22fcecaf5eb75c4295246aaa83c0
sha256: "5377eaac3b9fe8aaf22638d87f92b62784f23572e132dfc029195e84d6cb37de"
url: "https://pub.dev"
source: hosted
version: "2.10.0"
version: "2.12.0"
firebase_crashlytics:
dependency: "direct main"
description:
Expand Down Expand Up @@ -1014,10 +1014,10 @@ packages:
dependency: transitive
description:
name: sqflite_common
sha256: "28d8c66baee4968519fb8bd6cdbedad982d6e53359091f0b74544a9f32ec72d5"
sha256: "3da423ce7baf868be70e2c0976c28a1bb2f73644268b7ffa7d2e08eab71f16a4"
url: "https://pub.dev"
source: hosted
version: "2.5.3"
version: "2.5.4"
stack_trace:
dependency: transitive
description:
Expand Down Expand Up @@ -1222,10 +1222,10 @@ packages:
dependency: transitive
description:
name: win32
sha256: "464f5674532865248444b4c3daca12bd9bf2d7c47f759ce2617986e7229494a8"
sha256: "8cb58b45c47dcb42ab3651533626161d6b67a2921917d8d429791f76972b3480"
url: "https://pub.dev"
source: hosted
version: "5.2.0"
version: "5.3.0"
xdg_directories:
dependency: transitive
description:
Expand Down

0 comments on commit 339c48c

Please sign in to comment.