-
-
Save tariqhamid/1419baa9da8710a1fe4dfc984e5bae19 to your computer and use it in GitHub Desktop.
multi lingual support file
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'dart:async'; | |
import 'package:flutter/material.dart'; | |
import 'package:flutter/foundation.dart' show SynchronousFuture; | |
class UnicomputeLocalizations { | |
UnicomputeLocalizations(this.locale); | |
final Locale locale; | |
static UnicomputeLocalizations of(BuildContext context) { | |
return Localizations.of<UnicomputeLocalizations>(context, UnicomputeLocalizations); | |
} | |
String operator [](String label) => _localizedValues[locale.languageCode][label]; | |
static Map<String, Map<String, String>> get localizedValues => _localizedValues; | |
static Map<String, Map<String, String>> _localizedValues = {}; | |
} | |
class UnicomputeLocalizationsDelegate extends LocalizationsDelegate<UnicomputeLocalizations> { | |
const UnicomputeLocalizationsDelegate(); | |
@override | |
bool isSupported(Locale locale) => UnicomputeLocalizations._localizedValues.keys.contains(locale.languageCode); | |
@override | |
Future<UnicomputeLocalizations> load(Locale locale) { | |
return SynchronousFuture<UnicomputeLocalizations>(UnicomputeLocalizations(locale)); | |
} | |
@override | |
bool shouldReload(UnicomputeLocalizationsDelegate old) => false; | |
Iterable<Locale> get supportedLocales => UnicomputeLocalizations.localizedValues.keys.map((lang) => Locale(lang)); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment