Skip to content

Instantly share code, notes, and snippets.

@AbedElazizShe
Created July 14, 2022 18:25
Show Gist options
  • Save AbedElazizShe/5029b3a0ec5c604b3499441f43391cc4 to your computer and use it in GitHub Desktop.
Save AbedElazizShe/5029b3a0ec5c604b3499441f43391cc4 to your computer and use it in GitHub Desktop.
Configuration Implementation
class CustomConfiguration extends AppConfiguration {
@override
String endpoint() => 'https://api.nytimes.com/svc/';
@override
ThemeData theme() {
const colorScheme = ColorScheme.light(
primary: Colors.cyan,
primaryContainer: Color(0xffcccccc),
onPrimary: Colors.black54,
secondary: Color(0xffef9a9a),
secondaryContainer: Color(0xffba6b6c),
onSecondary: Color(0x9E000000),
);
return ThemeData.from(colorScheme: colorScheme).copyWith(
buttonTheme: const ButtonThemeData(colorScheme: colorScheme),
);
}
@override
Route routeFactory(RouteSettings settings, BaseLocalisation localisation) {
switch (settings.name) {
case landingScreen:
return MaterialPageRoute<LandingScreen>(
builder: (BuildContext context) => const LandingScreen());
default:
throw Exception('This route name does not exit');
}
}
@override
Widget widgetProvider(
String identifier,
BaseLocalisation localisation, {
BuildContext? context,
Function? onEvent,
Map<String, dynamic>? arguments,
}) {
if (identifier == floatingButtonIdentifier) {
/// return your widget
}
return const SizedBox.shrink();
}
@override
List<Locale> supportedLanguages() => <Locale>[
const Locale.fromSubtags(languageCode: 'ar', countryCode: 'MA'),
const Locale.fromSubtags(languageCode: 'en', countryCode: 'US')
];
@override
List<Localization> supportedLocalizations() =>
<Localization>[ArabicLocalization(), EnglishLocalization()];
@override
List blocs() {
return [
BlocProvider(create: (_) => CounterCubit()),
];
}
}
class ArabicLocalization extends BaseLocalisation {
ArabicLocalization() : super(code: 'ar', name: 'Arabic', country: '');
@override
String get labelAppName => 'تطبيق تجريبي';
/// The rest are removed intentionally
}
class EnglishLocalization extends BaseLocalisation {
EnglishLocalization() : super(code: 'en', name: 'English', country: '');
@override
String get labelAppName => "Custom App";
/// The rest are removed intentionally
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment