Skip to content

Instantly share code, notes, and snippets.

@freedive-cebu30
Created May 21, 2020 16:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save freedive-cebu30/3bf369b53e58db7f9a8295fd50fcaf88 to your computer and use it in GitHub Desktop.
Save freedive-cebu30/3bf369b53e58db7f9a8295fd50fcaf88 to your computer and use it in GitHub Desktop.
flutter_localizations_3
import 'package:flutter/material.dart';
class I18n {
I18n(this.locale);
final Locale locale;
static I18n of(BuildContext context) {
return Localizations.of<I18n>(context, I18n);
}
static Map<String, Map<String, String>> _localizedValues = {
'en': {
'title': 'Exchange Shop in Cebu',
},
'ja': {
'title': 'セブの両替所',
},
};
String get title {
return _localizedValues[locale.languageCode]['title'];
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment