Google I / O2022用のFlutterとFirebaseで構築されたピンボールゲーム。
今それを試して、それがどのように作られているかを学びましょう。
Googleと提携してVeryGoodVenturesによって構築されました
非常に優れたCLIを使用して作成
目的のプロジェクトを実行するには、VSCode / Android Studioの起動構成を使用するか、次のコマンドを使用します。
$ flutter run -d chrome
* I / O Pinballは、デスクトップおよびモバイル用のWebで動作します。
すべてのユニットテストとウィジェットテストを実行するには、次のコマンドを使用します。
$ flutter test --coverage --test-randomize-ordering-seed random
生成されたカバレッジレポートを表示するには、lcovを使用できます。
# Generate Coverage Report
$ genhtml coverage/lcov.info -o coverage/
# Open Coverage Report
$ open coverage/index.html
このプロジェクトはflutter_localizationsに依存しており、Flutterの公式国際化ガイドに従います。
app_en.arbファイルを開きます
lib/l10n/arb/app_en.arb。
{
"@@locale": "en",
"counterAppBarTitle": "Counter",
"@counterAppBarTitle": {
"description": "Text shown in the AppBar of the Counter Page"
}
}
- 次に、新しいキー/値と説明を追加します
{
"@@locale": "en",
"counterAppBarTitle": "Counter",
"@counterAppBarTitle": {
"description": "Text shown in the AppBar of the Counter Page"
},
"helloWorld": "Hello World",
"@helloWorld": {
"description": "Hello World Text"
}
}
- 新しい文字列を使用する
import 'package:pinball/l10n/l10n.dart';
@override
Widget build(BuildContext context) {
final l10n = context.l10n;
return Text(l10n.helloWorld);
}
翻訳の追加
- サポートされているロケールごとに、に新しいARBファイルを追加します
lib/l10n/arb
。
├── l10n
│ ├── arb
│ │ ├── app_en.arb
│ │ └── app_es.arb
.arb
翻訳された文字列を各ファイルに追加します。
app_en.arb
{
"@@locale": "en",
"counterAppBarTitle": "Counter",
"@counterAppBarTitle": {
"description": "Text shown in the AppBar of the Counter Page"
}
}
app_es.arb
{
"@@locale": "es",
"counterAppBarTitle": "Contador",
"@counterAppBarTitle": {
"description": "Texto mostrado en la AppBar de la página del contador"
}
}