fix unmounted exception
This commit is contained in:
@@ -706,7 +706,7 @@ final class FilteredTabPreviewsProvider
|
||||
}
|
||||
|
||||
String _$filteredTabPreviewsHash() =>
|
||||
r'f2958369b4270f4c8165526c0ffad22f41ec0491';
|
||||
r'9fbf6774433e62ce9b63ef66f6db3446e6182109';
|
||||
|
||||
final class FilteredTabPreviewsFamily extends $Family
|
||||
with
|
||||
|
||||
@@ -164,14 +164,18 @@ Stream<ContainerData?> selectedContainerData(Ref ref) {
|
||||
}
|
||||
|
||||
@Riverpod()
|
||||
AsyncValue<int> selectedContainerTabCount(Ref ref) {
|
||||
Future<int> selectedContainerTabCount(Ref ref) async {
|
||||
final selectedContainer = ref.watch(selectedContainerProvider);
|
||||
final tabCount = ref.watch(
|
||||
containerTabCountProvider(
|
||||
|
||||
if (selectedContainer == null) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Use selectAsync to avoid UnmountedRefException when container changes
|
||||
return ref.watch(
|
||||
watchContainerTabIdsProvider(
|
||||
// ignore: provider_parameters
|
||||
ContainerFilterById(containerId: selectedContainer),
|
||||
),
|
||||
).selectAsync((tabs) => tabs.length),
|
||||
);
|
||||
|
||||
return tabCount;
|
||||
}
|
||||
|
||||
+6
-15
@@ -106,9 +106,8 @@ String _$selectedContainerDataHash() =>
|
||||
const selectedContainerTabCountProvider = SelectedContainerTabCountProvider._();
|
||||
|
||||
final class SelectedContainerTabCountProvider
|
||||
extends
|
||||
$FunctionalProvider<AsyncValue<int>, AsyncValue<int>, AsyncValue<int>>
|
||||
with $Provider<AsyncValue<int>> {
|
||||
extends $FunctionalProvider<AsyncValue<int>, int, FutureOr<int>>
|
||||
with $FutureModifier<int>, $FutureProvider<int> {
|
||||
const SelectedContainerTabCountProvider._()
|
||||
: super(
|
||||
from: null,
|
||||
@@ -125,22 +124,14 @@ final class SelectedContainerTabCountProvider
|
||||
|
||||
@$internal
|
||||
@override
|
||||
$ProviderElement<AsyncValue<int>> $createElement($ProviderPointer pointer) =>
|
||||
$ProviderElement(pointer);
|
||||
$FutureProviderElement<int> $createElement($ProviderPointer pointer) =>
|
||||
$FutureProviderElement(pointer);
|
||||
|
||||
@override
|
||||
AsyncValue<int> create(Ref ref) {
|
||||
FutureOr<int> create(Ref ref) {
|
||||
return selectedContainerTabCount(ref);
|
||||
}
|
||||
|
||||
/// {@macro riverpod.override_with_value}
|
||||
Override overrideWithValue(AsyncValue<int> value) {
|
||||
return $ProviderOverride(
|
||||
origin: this,
|
||||
providerOverride: $SyncValueProvider<AsyncValue<int>>(value),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
String _$selectedContainerTabCountHash() =>
|
||||
r'0fd457793f7870050f81c54d2fbcc81aca60f394';
|
||||
r'36efadeaa356e34cfdb6c07dbba73eed6d2ad6ca';
|
||||
|
||||
Reference in New Issue
Block a user