Open PackRuble opened 1 year ago
At this point, I've come to the conclusion that it's best to leave it up to the user) I do it this way myself:
enum CardImpl<T> implements Card<T> {
myColor<Color>(DataType.int, Color(0xFF00BFFD)),
mySleepDuration<Duration>(DataType.int, Duration(hours: 7)),
;
const CardImpl(this.type, this.defaultValue);
// ...type, defaultValue, key
static const converters = {
myColor: Converters.colorAsInt,
mySleepDuration: Converters.durationAsInt,
};
}
// ... and then
CardConfig(
name: '$CardImpl',
cards: CardImpl.values,
converters: CardImpl.converters,
),
This eliminates boilerplate in converters (not writing CardImpl
unnecessarily) and still allows the config to be dynamic and live wherever it wants)
There are probably other interesting mechanics and therefore this issue remains open for discussion
Important clarification: CardConfig
has been renamed to CardotekaConfig
0c77651bd6def492e7206744924b7621758a6011
It will be extremely convenient, as for me. Related things in one place