So I've got a bunch of these setting checkboxes that look like this :
SettingsCheckBox(
value: userSettings.usDateFormat,
onTap: () => userSettings.usDateFormat = !userSettings.usDateFormat,
label: 'US Date format',
),
But of course, this is highly repetitive and error-prone code. How can I make this better ?
Dart doesn't have pointers as far as I'm aware.
I could have a getter/setter on userSettings
taking constants corresponding to each boolean so that all the repetitive code is in one place, but that's just really moving the problem away and making things more complex in favor of readability that would be like :
SettingsCheckBox(
value: SettingsValues.usDateFormatConst,
label: 'US Date format',
),
With SettingsCheckBox
handling the getting/setting of values into userSettings
.