openSelector static method
Implementation
static Future<void> openSelector({required BuildContext context}) async {
final PriceModel model = context.read<PriceModel>();
// With a proof, the currency comes from the proof.
if (model.proof != null) {
return;
}
final UserPreferences preferences = context.read<UserPreferences>();
await Navigator.of(context).push<Currency>(
smoothSelectorRoute<Currency>(
(_) => ChangeNotifierProvider<CurrencySelectorProvider>(
create: (_) => CurrencySelectorProvider(
preferences: preferences,
autoValidate: true,
currentCode: () => model.currency.name,
onSave: (Currency currency) async => model.currency = currency,
),
builder: (BuildContext context, _) => CurrencySelectorScreen(
provider: context.read<CurrencySelectorProvider>(),
),
),
),
);
}