Created
May 24, 2018 18:11
-
-
Save HansMuller/101ab5a797c5121f1e16d5eb0ddf1282 to your computer and use it in GitHub Desktop.
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
// Should pass the Locale from Localizations to Text/RichText/etc to painting.TextStyle to ui.TextStyle | |
// https://github.com/flutter/flutter/issues/16408 | |
import 'package:flutter/material.dart'; | |
import 'package:flutter_localizations/flutter_localizations.dart'; | |
// See also: | |
// problem description - https://medium.com/@najeira/flutter-and-cjk-font-selection-5dbc6a6164ba | |
// problem character - http://unicode.org/cldr/utility/character.jsp?a=6B21 | |
class LocalizedFont extends StatelessWidget{ | |
@override | |
Widget build(BuildContext context) { | |
final TextStyle style = Theme.of(context).textTheme.display3.copyWith( | |
fontFamily: 'NotoSerifCJKjp', | |
); | |
//final String character = '次'; // http://unicode.org/cldr/utility/character.jsp?a=6B21 | |
final String character = '骨'; | |
return new Scaffold( | |
body: new Container( | |
padding: const EdgeInsets.all(48.0), | |
alignment: Alignment.center, | |
child: new Row( | |
mainAxisAlignment: MainAxisAlignment.spaceEvenly, | |
children: <Widget>[ | |
new Localizations.override( | |
context: context, | |
locale: const Locale('ja'), | |
child: new Text(character, style: style), | |
), | |
new Localizations.override( | |
context: context, | |
locale: const Locale('zh'), | |
child: new Text(character, style: style), | |
), | |
], | |
), | |
), | |
); | |
} | |
} | |
void main() { | |
runApp( | |
new MaterialApp( | |
localizationsDelegates: GlobalMaterialLocalizations.delegates, | |
supportedLocales: [ | |
const Locale('en', 'US'), | |
const Locale('ja'), | |
const Locale('zh'), | |
], | |
home: new LocalizedFont() | |
), | |
); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment