Skip to content

Instantly share code, notes, and snippets.

@najeira
Last active May 25, 2018 02:17
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 najeira/41c8e43df8304f9c2544aae83b36b3f1 to your computer and use it in GitHub Desktop.
Save najeira/41c8e43df8304f9c2544aae83b36b3f1 to your computer and use it in GitHub Desktop.
Test for Flutter font selection
// A test for https://github.com/flutter/flutter/pull/17879
import 'package:flutter/material.dart';
import 'package:flutter_localizations/flutter_localizations.dart';
void main() {
runApp(new MaterialApp(
localizationsDelegates: GlobalMaterialLocalizations.delegates,
locale: const Locale("ja", "JP"),
supportedLocales: [
const Locale("ja", "JP"),
const Locale("zh", "CN"),
const Locale("zh", "TW"),
const Locale("ko", "KR"),
const Locale("vi", "VN"),
],
home: new FooPage(),
));
}
class FooPage extends StatefulWidget {
@override
State<StatefulWidget> createState() {
return new FooPageState();
}
}
class FooPageState extends State<FooPage> {
@override
Widget build(BuildContext context) {
return new Scaffold(
appBar: new AppBar(title: new Text("Locale test")),
body: new Center(
child: new Column(
children: <Widget>[
_buildRow(context, const Locale("ja", "JP")),
_buildRow(context, const Locale("zh", "CN")),
_buildRow(context, const Locale("zh", "TW")),
_buildRow(context, const Locale("ko", "KR")),
_buildRow(context, const Locale("vi", "VN")),
],
),
),
);
}
Widget _buildRow(BuildContext context, Locale locale) {
return new Container(
padding: const EdgeInsets.all(8.0),
child: new Localizations.override(
context: context,
locale: locale,
child: new Text("${locale}: 累令直刃漢"),
),
);
}
}
@najeira
Copy link
Author

najeira commented May 25, 2018

on Android emulator API 26:

2018-05-25 10 49 15

OK!

@najeira
Copy link
Author

najeira commented May 25, 2018

on Galaxy S7 edge (Android 7.0):

screenshot_20180525-105234

All texts are in Japanese font.

@najeira
Copy link
Author

najeira commented May 25, 2018

I changed the language of the device to Chinese and tested it, but it is the same result.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment