Browse Source

settings: use requireData for AsyncSnapshots

pull/427/head
Nikolas Rimikis 1 year ago
parent
commit
686945431b
No known key found for this signature in database
GPG Key ID: 85ED1DE9786A4FF2
  1. 2
      packages/settings/lib/src/widgets/checkbox_settings_tile.dart
  2. 4
      packages/settings/lib/src/widgets/dropdown_button_settings_tile.dart

2
packages/settings/lib/src/widgets/checkbox_settings_tile.dart

@ -18,7 +18,7 @@ class CheckBoxSettingsTile extends InputSettingsTile<ToggleOption> {
: CheckboxListTile( : CheckboxListTile(
title: Text(option.label(context)), title: Text(option.label(context)),
value: value, value: value,
onChanged: enabledSnapshot.data! onChanged: enabledSnapshot.requireData
? (final value) async { ? (final value) async {
await option.set(value!); await option.set(value!);
} }

4
packages/settings/lib/src/widgets/dropdown_button_settings_tile.dart

@ -42,12 +42,12 @@ class DropdownButtonSettingsTile<T> extends InputSettingsTile<SelectOption<T>> {
child: DropdownButton<T>( child: DropdownButton<T>(
isExpanded: true, isExpanded: true,
value: value, value: value,
items: valuesSnapshot.data!.keys items: valuesSnapshot.requireData.keys
.map( .map(
(final k) => DropdownMenuItem( (final k) => DropdownMenuItem(
value: k, value: k,
child: Text( child: Text(
valuesSnapshot.data![k]!(context), valuesSnapshot.requireData[k]!(context),
overflow: TextOverflow.ellipsis, overflow: TextOverflow.ellipsis,
), ),
), ),

Loading…
Cancel
Save