enum_string_extension 0.0.2 enum_string_extension: ^0.0.2 copied to clipboard
Annotation for generating `enumString` extensions code using `enum_string_extension_gen`.
import 'dart:ui' show Locale;
import 'package:enum_string_extension/enum_string_extension.dart';
import 'package:flutter/cupertino.dart' show Localizations, BuildContext;
import 'package:meta/meta.dart' show immutable;
part 'basic_class.g.dart';
// The localizations delagate must be called AppLocalizations and implement each field of the enum
class AppLocalizations {
AppLocalizations(this.locale) : labels = languages[locale];
final Locale locale;
static final Map<Locale, AppLocalizationsLabels> languages = <Locale, AppLocalizationsLabels>{
const Locale.fromSubtags(languageCode: 'en', countryCode: 'US'): const AppLocalizationsLabels(
value1: 'Value 1 in english',
value2: 'Value 2 in english',
value3: 'Value 3 in english',
)
};
final AppLocalizationsLabels labels;
static AppLocalizationsLabels of(BuildContext context) =>
Localizations.of<AppLocalizations>(context, AppLocalizations)?.labels;
}
class AppLocalizationsLabels {
const AppLocalizationsLabels({
this.value1,
this.value2,
this.value3,
});
final String value1;
final String value2;
final String value3;
}
enum TestEnum3 {
value1,
value3,
}
enum TestEnum2 {
value1,
value2,
value3,
}
enum TestEnum {
value1,
value2,
}
@immutable
@enumString
class BasicClass {
const BasicClass({
this.test,
this.test2,
this.test3,
});
final TestEnum test;
final TestEnum2 test2;
final List<TestEnum3> test3;
}