|
|
@ -8,6 +8,7 @@ class AssetsManagerState extends Equatable {
|
|
|
|
const AssetsManagerState({
|
|
|
|
const AssetsManagerState({
|
|
|
|
required this.loadables,
|
|
|
|
required this.loadables,
|
|
|
|
required this.loaded,
|
|
|
|
required this.loaded,
|
|
|
|
|
|
|
|
this.error,
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
/// {@macro assets_manager_state}
|
|
|
|
/// {@macro assets_manager_state}
|
|
|
@ -20,22 +21,26 @@ class AssetsManagerState extends Equatable {
|
|
|
|
/// List of loaded futures
|
|
|
|
/// List of loaded futures
|
|
|
|
final List<Future> loaded;
|
|
|
|
final List<Future> loaded;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
final String? error;
|
|
|
|
|
|
|
|
|
|
|
|
/// Returns a value between 0 and 1 to indicate the loading progress
|
|
|
|
/// Returns a value between 0 and 1 to indicate the loading progress
|
|
|
|
double get progress =>
|
|
|
|
double get progress =>
|
|
|
|
loadables.isEmpty ? 0 : loaded.length / loadables.length;
|
|
|
|
loadables.isEmpty ? 0 : loaded.length / loadables.length;
|
|
|
|
|
|
|
|
|
|
|
|
/// Only returns false if all the assets have been loaded
|
|
|
|
/// Only returns false if all the assets have been loaded
|
|
|
|
bool get isLoading => progress != 1;
|
|
|
|
bool get isLoading => progress != 1 && error == null;
|
|
|
|
|
|
|
|
|
|
|
|
/// Returns a copy of this instance with the given parameters
|
|
|
|
/// Returns a copy of this instance with the given parameters
|
|
|
|
/// updated
|
|
|
|
/// updated
|
|
|
|
AssetsManagerState copyWith({
|
|
|
|
AssetsManagerState copyWith({
|
|
|
|
List<Future>? loadables,
|
|
|
|
List<Future>? loadables,
|
|
|
|
List<Future>? loaded,
|
|
|
|
List<Future>? loaded,
|
|
|
|
|
|
|
|
String? error,
|
|
|
|
}) {
|
|
|
|
}) {
|
|
|
|
return AssetsManagerState(
|
|
|
|
return AssetsManagerState(
|
|
|
|
loadables: loadables ?? this.loadables,
|
|
|
|
loadables: loadables ?? this.loadables,
|
|
|
|
loaded: loaded ?? this.loaded,
|
|
|
|
loaded: loaded ?? this.loaded,
|
|
|
|
|
|
|
|
error: error ?? this.error,
|
|
|
|
);
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|