diff --git a/packages/remote_state/example/pubspec.lock b/packages/remote_state/example/pubspec.lock index aef7d4a..b1ffb7b 100644 --- a/packages/remote_state/example/pubspec.lock +++ b/packages/remote_state/example/pubspec.lock @@ -7,7 +7,7 @@ packages: name: async url: "https://pub.dartlang.org" source: hosted - version: "2.5.0" + version: "2.8.1" boolean_selector: dependency: transitive description: @@ -28,7 +28,7 @@ packages: name: charcode url: "https://pub.dartlang.org" source: hosted - version: "1.2.0" + version: "1.3.1" clock: dependency: transitive description: @@ -73,14 +73,14 @@ packages: name: freezed_annotation url: "https://pub.dartlang.org" source: hosted - version: "0.13.0-nullsafety.0" + version: "0.14.3" json_annotation: dependency: transitive description: name: json_annotation url: "https://pub.dartlang.org" source: hosted - version: "4.0.0" + version: "4.3.0" matcher: dependency: transitive description: @@ -94,7 +94,7 @@ packages: name: meta url: "https://pub.dartlang.org" source: hosted - version: "1.3.0" + version: "1.7.0" path: dependency: transitive description: @@ -108,7 +108,7 @@ packages: path: ".." relative: true source: path - version: "1.5.0" + version: "2.0.0" sky_engine: dependency: transitive description: flutter @@ -120,7 +120,7 @@ packages: name: source_span url: "https://pub.dartlang.org" source: hosted - version: "1.8.0" + version: "1.8.1" stack_trace: dependency: transitive description: @@ -155,7 +155,7 @@ packages: name: test_api url: "https://pub.dartlang.org" source: hosted - version: "0.2.19" + version: "0.4.2" typed_data: dependency: transitive description: @@ -171,4 +171,4 @@ packages: source: hosted version: "2.1.0" sdks: - dart: ">=2.12.0 <3.0.0" + dart: ">=2.14.0 <3.0.0" diff --git a/packages/remote_state/lib/remote_state.dart b/packages/remote_state/lib/remote_state.dart index 12905ae..62c5502 100644 --- a/packages/remote_state/lib/remote_state.dart +++ b/packages/remote_state/lib/remote_state.dart @@ -123,19 +123,23 @@ class RemoteState with _$RemoteState { /// State-checking predicate. Returns true if we haven't asked for data yet. /// Returns true only if [RemoteState] is [RemoteState.initial] - late bool isInitial = maybeWhen(initial: () => true, orElse: () => false); + late final bool isInitial = + maybeWhen(initial: () => true, orElse: () => false); /// State-checking predicate. Returns true if we're loading. /// Returns true only if [RemoteState] is [RemoteState.loading] - late bool isLoading = maybeWhen(loading: () => true, orElse: () => false); + late final bool isLoading = + maybeWhen(loading: () => true, orElse: () => false); /// State-checking predicate. Returns true if we've successfully loaded some data. /// Returns true only if [RemoteState] is [RemoteState.success] - late bool isSuccess = maybeWhen(success: (_) => true, orElse: () => false); + late final bool isSuccess = + maybeWhen(success: (_) => true, orElse: () => false); /// State-checking predicate. Returns true if we've failed to load some data. /// Returns true only if [RemoteState] is [RemoteState.error] - late bool isError = maybeWhen(error: (_, __) => true, orElse: () => false); + late final bool isError = + maybeWhen(error: (_, __) => true, orElse: () => false); /// Convert a [Future] to RemoteState. /// Emits [RemoteState.success] if the future completes diff --git a/packages/remote_state/lib/remote_state.freezed.dart b/packages/remote_state/lib/remote_state.freezed.dart index f808d6e..9d130c2 100644 --- a/packages/remote_state/lib/remote_state.freezed.dart +++ b/packages/remote_state/lib/remote_state.freezed.dart @@ -1,5 +1,6 @@ +// coverage:ignore-file // GENERATED CODE - DO NOT MODIFY BY HAND -// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides +// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target part of remote_state; @@ -52,6 +53,14 @@ mixin _$RemoteState { }) => throw _privateConstructorUsedError; @optionalTypeArgs + TResult? whenOrNull({ + TResult Function()? initial, + TResult Function()? loading, + TResult Function(T value)? success, + TResult Function(Object? error, StackTrace? stackTrace)? error, + }) => + throw _privateConstructorUsedError; + @optionalTypeArgs TResult maybeWhen({ TResult Function()? initial, TResult Function()? loading, @@ -69,6 +78,14 @@ mixin _$RemoteState { }) => throw _privateConstructorUsedError; @optionalTypeArgs + TResult? mapOrNull({ + TResult Function(_Initial value)? initial, + TResult Function(_Loading value)? loading, + TResult Function(_Success value)? success, + TResult Function(_Error value)? error, + }) => + throw _privateConstructorUsedError; + @optionalTypeArgs TResult maybeMap({ TResult Function(_Initial value)? initial, TResult Function(_Loading value)? loading, @@ -114,6 +131,7 @@ class __$InitialCopyWithImpl extends _$RemoteStateCopyWithImpl } /// @nodoc + class _$_Initial extends _Initial { _$_Initial() : super._(); @@ -124,7 +142,8 @@ class _$_Initial extends _Initial { @override bool operator ==(dynamic other) { - return identical(this, other) || (other is _Initial); + return identical(this, other) || + (other.runtimeType == runtimeType && other is _Initial); } @override @@ -141,6 +160,17 @@ class _$_Initial extends _Initial { return initial(); } + @override + @optionalTypeArgs + TResult? whenOrNull({ + TResult Function()? initial, + TResult Function()? loading, + TResult Function(T value)? success, + TResult Function(Object? error, StackTrace? stackTrace)? error, + }) { + return initial?.call(); + } + @override @optionalTypeArgs TResult maybeWhen({ @@ -167,6 +197,17 @@ class _$_Initial extends _Initial { return initial(this); } + @override + @optionalTypeArgs + TResult? mapOrNull({ + TResult Function(_Initial value)? initial, + TResult Function(_Loading value)? loading, + TResult Function(_Success value)? success, + TResult Function(_Error value)? error, + }) { + return initial?.call(this); + } + @override @optionalTypeArgs TResult maybeMap({ @@ -184,8 +225,8 @@ class _$_Initial extends _Initial { } abstract class _Initial extends RemoteState { - _Initial._() : super._(); factory _Initial() = _$_Initial; + _Initial._() : super._(); } /// @nodoc @@ -206,6 +247,7 @@ class __$LoadingCopyWithImpl extends _$RemoteStateCopyWithImpl } /// @nodoc + class _$_Loading extends _Loading { _$_Loading() : super._(); @@ -216,7 +258,8 @@ class _$_Loading extends _Loading { @override bool operator ==(dynamic other) { - return identical(this, other) || (other is _Loading); + return identical(this, other) || + (other.runtimeType == runtimeType && other is _Loading); } @override @@ -233,6 +276,17 @@ class _$_Loading extends _Loading { return loading(); } + @override + @optionalTypeArgs + TResult? whenOrNull({ + TResult Function()? initial, + TResult Function()? loading, + TResult Function(T value)? success, + TResult Function(Object? error, StackTrace? stackTrace)? error, + }) { + return loading?.call(); + } + @override @optionalTypeArgs TResult maybeWhen({ @@ -259,6 +313,17 @@ class _$_Loading extends _Loading { return loading(this); } + @override + @optionalTypeArgs + TResult? mapOrNull({ + TResult Function(_Initial value)? initial, + TResult Function(_Loading value)? loading, + TResult Function(_Success value)? success, + TResult Function(_Error value)? error, + }) { + return loading?.call(this); + } + @override @optionalTypeArgs TResult maybeMap({ @@ -276,8 +341,8 @@ class _$_Loading extends _Loading { } abstract class _Loading extends RemoteState { - _Loading._() : super._(); factory _Loading() = _$_Loading; + _Loading._() : super._(); } /// @nodoc @@ -302,12 +367,16 @@ class __$SuccessCopyWithImpl extends _$RemoteStateCopyWithImpl Object? value = freezed, }) { return _then(_Success( - value == freezed ? _value.value : value as T, + value == freezed + ? _value.value + : value // ignore: cast_nullable_to_non_nullable + as T, )); } } /// @nodoc + class _$_Success extends _Success { _$_Success(this.value) : super._(); @@ -322,14 +391,14 @@ class _$_Success extends _Success { @override bool operator ==(dynamic other) { return identical(this, other) || - (other is _Success && - (identical(other.value, value) || - const DeepCollectionEquality().equals(other.value, value))); + (other.runtimeType == runtimeType && + other is _Success && + const DeepCollectionEquality().equals(other.value, value)); } @override int get hashCode => - runtimeType.hashCode ^ const DeepCollectionEquality().hash(value); + Object.hash(runtimeType, const DeepCollectionEquality().hash(value)); @JsonKey(ignore: true) @override @@ -347,6 +416,17 @@ class _$_Success extends _Success { return success(value); } + @override + @optionalTypeArgs + TResult? whenOrNull({ + TResult Function()? initial, + TResult Function()? loading, + TResult Function(T value)? success, + TResult Function(Object? error, StackTrace? stackTrace)? error, + }) { + return success?.call(value); + } + @override @optionalTypeArgs TResult maybeWhen({ @@ -373,6 +453,17 @@ class _$_Success extends _Success { return success(this); } + @override + @optionalTypeArgs + TResult? mapOrNull({ + TResult Function(_Initial value)? initial, + TResult Function(_Loading value)? loading, + TResult Function(_Success value)? success, + TResult Function(_Error value)? error, + }) { + return success?.call(this); + } + @override @optionalTypeArgs TResult maybeMap({ @@ -390,10 +481,10 @@ class _$_Success extends _Success { } abstract class _Success extends RemoteState { - _Success._() : super._(); factory _Success(T value) = _$_Success; + _Success._() : super._(); - T get value => throw _privateConstructorUsedError; + T get value; @JsonKey(ignore: true) _$SuccessCopyWith> get copyWith => throw _privateConstructorUsedError; @@ -422,12 +513,16 @@ class __$ErrorCopyWithImpl extends _$RemoteStateCopyWithImpl }) { return _then(_Error( error == freezed ? _value.error : error, - stackTrace == freezed ? _value.stackTrace : stackTrace as StackTrace?, + stackTrace == freezed + ? _value.stackTrace + : stackTrace // ignore: cast_nullable_to_non_nullable + as StackTrace?, )); } } /// @nodoc + class _$_Error extends _Error { _$_Error([this.error, this.stackTrace]) : super._(); @@ -444,19 +539,16 @@ class _$_Error extends _Error { @override bool operator ==(dynamic other) { return identical(this, other) || - (other is _Error && - (identical(other.error, error) || - const DeepCollectionEquality().equals(other.error, error)) && + (other.runtimeType == runtimeType && + other is _Error && + const DeepCollectionEquality().equals(other.error, error) && (identical(other.stackTrace, stackTrace) || - const DeepCollectionEquality() - .equals(other.stackTrace, stackTrace))); + other.stackTrace == stackTrace)); } @override - int get hashCode => - runtimeType.hashCode ^ - const DeepCollectionEquality().hash(error) ^ - const DeepCollectionEquality().hash(stackTrace); + int get hashCode => Object.hash( + runtimeType, const DeepCollectionEquality().hash(error), stackTrace); @JsonKey(ignore: true) @override @@ -474,6 +566,17 @@ class _$_Error extends _Error { return error(this.error, stackTrace); } + @override + @optionalTypeArgs + TResult? whenOrNull({ + TResult Function()? initial, + TResult Function()? loading, + TResult Function(T value)? success, + TResult Function(Object? error, StackTrace? stackTrace)? error, + }) { + return error?.call(this.error, stackTrace); + } + @override @optionalTypeArgs TResult maybeWhen({ @@ -500,6 +603,17 @@ class _$_Error extends _Error { return error(this); } + @override + @optionalTypeArgs + TResult? mapOrNull({ + TResult Function(_Initial value)? initial, + TResult Function(_Loading value)? loading, + TResult Function(_Success value)? success, + TResult Function(_Error value)? error, + }) { + return error?.call(this); + } + @override @optionalTypeArgs TResult maybeMap({ @@ -517,11 +631,11 @@ class _$_Error extends _Error { } abstract class _Error extends RemoteState { - _Error._() : super._(); factory _Error([Object? error, StackTrace? stackTrace]) = _$_Error; + _Error._() : super._(); - Object? get error => throw _privateConstructorUsedError; - StackTrace? get stackTrace => throw _privateConstructorUsedError; + Object? get error; + StackTrace? get stackTrace; @JsonKey(ignore: true) _$ErrorCopyWith> get copyWith => throw _privateConstructorUsedError; diff --git a/packages/remote_state/pubspec.lock b/packages/remote_state/pubspec.lock index c51f9d4..4a4727f 100644 --- a/packages/remote_state/pubspec.lock +++ b/packages/remote_state/pubspec.lock @@ -7,28 +7,28 @@ packages: name: _fe_analyzer_shared url: "https://pub.dartlang.org" source: hosted - version: "14.0.0" + version: "30.0.0" analyzer: dependency: transitive description: name: analyzer url: "https://pub.dartlang.org" source: hosted - version: "0.41.2" + version: "2.7.0" args: dependency: transitive description: name: args url: "https://pub.dartlang.org" source: hosted - version: "2.0.0" + version: "2.3.0" async: dependency: transitive description: name: async url: "https://pub.dartlang.org" source: hosted - version: "2.5.0" + version: "2.8.2" boolean_selector: dependency: transitive description: @@ -42,84 +42,84 @@ packages: name: build url: "https://pub.dartlang.org" source: hosted - version: "1.6.2" + version: "2.1.1" build_config: dependency: transitive description: name: build_config url: "https://pub.dartlang.org" source: hosted - version: "0.4.6" + version: "1.0.0" build_daemon: dependency: transitive description: name: build_daemon url: "https://pub.dartlang.org" source: hosted - version: "2.1.8" + version: "3.0.1" build_resolvers: dependency: transitive description: name: build_resolvers url: "https://pub.dartlang.org" source: hosted - version: "1.5.3" + version: "2.0.4" build_runner: dependency: "direct dev" description: name: build_runner url: "https://pub.dartlang.org" source: hosted - version: "1.11.5" + version: "2.1.4" build_runner_core: dependency: transitive description: name: build_runner_core url: "https://pub.dartlang.org" source: hosted - version: "6.1.10" + version: "7.2.2" built_collection: dependency: transitive description: name: built_collection url: "https://pub.dartlang.org" source: hosted - version: "5.0.0" + version: "5.1.1" built_value: dependency: transitive description: name: built_value url: "https://pub.dartlang.org" source: hosted - version: "8.0.0" + version: "8.1.3" charcode: dependency: transitive description: name: charcode url: "https://pub.dartlang.org" source: hosted - version: "1.2.0" + version: "1.3.1" checked_yaml: dependency: transitive description: name: checked_yaml url: "https://pub.dartlang.org" source: hosted - version: "1.0.4" + version: "2.0.1" cli_util: dependency: transitive description: name: cli_util url: "https://pub.dartlang.org" source: hosted - version: "0.3.0" + version: "0.3.5" code_builder: dependency: transitive description: name: code_builder url: "https://pub.dartlang.org" source: hosted - version: "3.6.0" + version: "4.1.0" collection: dependency: transitive description: @@ -133,35 +133,35 @@ packages: name: convert url: "https://pub.dartlang.org" source: hosted - version: "3.0.0" + version: "3.0.1" coverage: dependency: "direct dev" description: name: coverage url: "https://pub.dartlang.org" source: hosted - version: "0.15.2" + version: "1.0.3" crypto: dependency: transitive description: name: crypto url: "https://pub.dartlang.org" source: hosted - version: "3.0.0" + version: "3.0.1" dart_style: dependency: transitive description: name: dart_style url: "https://pub.dartlang.org" source: hosted - version: "1.3.12" + version: "2.2.0" file: dependency: transitive description: name: file url: "https://pub.dartlang.org" source: hosted - version: "6.1.0" + version: "6.1.2" fixnum: dependency: transitive description: @@ -175,35 +175,42 @@ packages: name: freezed url: "https://pub.dartlang.org" source: hosted - version: "0.14.0" + version: "0.15.0+1" freezed_annotation: dependency: "direct main" description: name: freezed_annotation url: "https://pub.dartlang.org" source: hosted - version: "0.14.0" + version: "0.15.0" + frontend_server_client: + dependency: transitive + description: + name: frontend_server_client + url: "https://pub.dartlang.org" + source: hosted + version: "2.1.2" glob: dependency: transitive description: name: glob url: "https://pub.dartlang.org" source: hosted - version: "2.0.0" + version: "2.0.2" graphs: dependency: transitive description: name: graphs url: "https://pub.dartlang.org" source: hosted - version: "0.2.0" + version: "2.1.0" http_multi_server: dependency: transitive description: name: http_multi_server url: "https://pub.dartlang.org" source: hosted - version: "2.2.0" + version: "3.0.1" http_parser: dependency: transitive description: @@ -217,7 +224,7 @@ packages: name: io url: "https://pub.dartlang.org" source: hosted - version: "0.3.5" + version: "1.0.3" js: dependency: transitive description: @@ -231,49 +238,49 @@ packages: name: json_annotation url: "https://pub.dartlang.org" source: hosted - version: "4.0.0" + version: "4.3.0" logging: dependency: transitive description: name: logging url: "https://pub.dartlang.org" source: hosted - version: "1.0.0" + version: "1.0.2" matcher: dependency: transitive description: name: matcher url: "https://pub.dartlang.org" source: hosted - version: "0.12.10" + version: "0.12.11" meta: dependency: "direct main" description: name: meta url: "https://pub.dartlang.org" source: hosted - version: "1.3.0" + version: "1.7.0" mime: dependency: transitive description: name: mime url: "https://pub.dartlang.org" source: hosted - version: "1.0.0" + version: "1.0.1" node_preamble: dependency: transitive description: name: node_preamble url: "https://pub.dartlang.org" source: hosted - version: "1.4.13" + version: "2.0.1" package_config: dependency: transitive description: name: package_config url: "https://pub.dartlang.org" source: hosted - version: "1.9.3" + version: "2.0.2" path: dependency: transitive description: @@ -281,13 +288,6 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "1.8.0" - pedantic: - dependency: transitive - description: - name: pedantic - url: "https://pub.dartlang.org" - source: hosted - version: "1.10.0" pool: dependency: transitive description: @@ -301,21 +301,21 @@ packages: name: pub_semver url: "https://pub.dartlang.org" source: hosted - version: "2.0.0" + version: "2.1.0" pubspec_parse: dependency: transitive description: name: pubspec_parse url: "https://pub.dartlang.org" source: hosted - version: "0.1.8" + version: "1.1.0" shelf: dependency: transitive description: name: shelf url: "https://pub.dartlang.org" source: hosted - version: "1.0.0" + version: "1.2.0" shelf_packages_handler: dependency: transitive description: @@ -329,21 +329,21 @@ packages: name: shelf_static url: "https://pub.dartlang.org" source: hosted - version: "1.0.0" + version: "1.1.0" shelf_web_socket: dependency: transitive description: name: shelf_web_socket url: "https://pub.dartlang.org" source: hosted - version: "0.2.4+1" + version: "1.0.1" source_gen: dependency: transitive description: name: source_gen url: "https://pub.dartlang.org" source: hosted - version: "0.9.10+3" + version: "1.1.1" source_map_stack_trace: dependency: transitive description: @@ -406,28 +406,28 @@ packages: name: test url: "https://pub.dartlang.org" source: hosted - version: "1.16.5" + version: "1.19.2" test_api: dependency: transitive description: name: test_api url: "https://pub.dartlang.org" source: hosted - version: "0.2.19" + version: "0.4.6" test_core: dependency: transitive description: name: test_core url: "https://pub.dartlang.org" source: hosted - version: "0.3.15" + version: "0.4.7" timing: dependency: transitive description: name: timing url: "https://pub.dartlang.org" source: hosted - version: "0.1.1+3" + version: "1.0.0" typed_data: dependency: transitive description: @@ -441,21 +441,21 @@ packages: name: vm_service url: "https://pub.dartlang.org" source: hosted - version: "6.1.0+1" + version: "7.3.0" watcher: dependency: transitive description: name: watcher url: "https://pub.dartlang.org" source: hosted - version: "1.0.0" + version: "1.0.1" web_socket_channel: dependency: transitive description: name: web_socket_channel url: "https://pub.dartlang.org" source: hosted - version: "1.2.0" + version: "2.1.0" webkit_inspection_protocol: dependency: transitive description: @@ -471,4 +471,4 @@ packages: source: hosted version: "3.1.0" sdks: - dart: ">=2.12.0 <3.0.0" + dart: ">=2.14.0 <3.0.0" diff --git a/packages/remote_state/pubspec.yaml b/packages/remote_state/pubspec.yaml index 4db5598..11f815f 100644 --- a/packages/remote_state/pubspec.yaml +++ b/packages/remote_state/pubspec.yaml @@ -6,10 +6,10 @@ description: Tools for mapping data from remote sources in Dart, similar to environment: sdk: '>=2.12.0 <3.0.0' dependencies: - freezed_annotation: ^0.14.0 + freezed_annotation: ^0.15.0 meta: '>=1.0.0 <3.0.0' dev_dependencies: - build_runner: ^1.11.5 - coverage: ^0.15.2 - freezed: ^0.14.0 + build_runner: ^2.1.4 + coverage: ^1.0.3 + freezed: ^0.15.0+1 test: ^1.16.5