sukesukejijii

Japanese translation - first draft

@@ -17,21 +17,21 @@ @@ -17,21 +17,21 @@
17 17
18 <div align="center"> 18 <div align="center">
19 19
20 -**Languages:**  
21 -  
22 -  
23 -[![English](https://img.shields.io/badge/Language-English-blueviolet?style=for-the-badge)](README.md)  
24 -[![Vietnamese](https://img.shields.io/badge/Language-Vietnamese-blueviolet?style=for-the-badge)](README-vi.md)  
25 -[![Indonesian](https://img.shields.io/badge/Language-Indonesian-blueviolet?style=for-the-badge)](README.id-ID.md)  
26 -[![Urdu](https://img.shields.io/badge/Language-Urdu-blueviolet?style=for-the-badge)](README.ur-PK.md)  
27 -[![Chinese](https://img.shields.io/badge/Language-Chinese-blueviolet?style=for-the-badge)](README.zh-cn.md)  
28 -[![Portuguese](https://img.shields.io/badge/Language-Portuguese-blueviolet?style=for-the-badge)](README.pt-br.md)  
29 -[![Spanish](https://img.shields.io/badge/Language-Spanish-blueviolet?style=for-the-badge)](README-es.md)  
30 -[![Russian](https://img.shields.io/badge/Language-Russian-blueviolet?style=for-the-badge)](README.ru.md)  
31 -[![Polish](https://img.shields.io/badge/Language-Polish-blueviolet?style=for-the-badge)](README.pl.md)  
32 -[![Korean](https://img.shields.io/badge/Language-Korean-blueviolet?style=for-the-badge)](README.ko-kr.md)  
33 -[![French](https://img.shields.io/badge/Language-French-blueviolet?style=for-the-badge)](README-fr.md)  
34 -[![Japanese](https://img.shields.io/badge/Language-Japanese-blueviolet?style=for-the-badge)](README-ja.md) 20 +**言語**
  21 +
  22 +
  23 +[![英語](https://img.shields.io/badge/Language-English-blueviolet?style=for-the-badge)](README.md)
  24 +[![ベトナム語](https://img.shields.io/badge/Language-Vietnamese-blueviolet?style=for-the-badge)](README-vi.md)
  25 +[![インドネシア語](https://img.shields.io/badge/Language-Indonesian-blueviolet?style=for-the-badge)](README.id-ID.md)
  26 +[![ウルドゥー語](https://img.shields.io/badge/Language-Urdu-blueviolet?style=for-the-badge)](README.ur-PK.md)
  27 +[![中国語](https://img.shields.io/badge/Language-Chinese-blueviolet?style=for-the-badge)](README.zh-cn.md)
  28 +[![ポルトガル語](https://img.shields.io/badge/Language-Portuguese-blueviolet?style=for-the-badge)](README.pt-br.md)
  29 +[![スペイン語](https://img.shields.io/badge/Language-Spanish-blueviolet?style=for-the-badge)](README-es.md)
  30 +[![ロシア語](https://img.shields.io/badge/Language-Russian-blueviolet?style=for-the-badge)](README.ru.md)
  31 +[![ポーランド語](https://img.shields.io/badge/Language-Polish-blueviolet?style=for-the-badge)](README.pl.md)
  32 +[![韓国語](https://img.shields.io/badge/Language-Korean-blueviolet?style=for-the-badge)](README.ko-kr.md)
  33 +[![フランス語](https://img.shields.io/badge/Language-French-blueviolet?style=for-the-badge)](README-fr.md)
  34 +[![日本語](https://img.shields.io/badge/Language-Japanese-blueviolet?style=for-the-badge)](README-ja.md)
35 35
36 </div> 36 </div>
37 37
@@ -40,70 +40,75 @@ @@ -40,70 +40,75 @@
40 - [GetXによるカウンターアプリ](#GetXによるカウンターアプリ) 40 - [GetXによるカウンターアプリ](#GetXによるカウンターアプリ)
41 - [三本柱](#三本柱) 41 - [三本柱](#三本柱)
42 - [状態管理](#状態管理) 42 - [状態管理](#状態管理)
43 - - [Reactive State Manager](#reactive-state-manager)  
44 - - [More details about state management](#more-details-about-state-management)  
45 - - [Route management](#route-management)  
46 - - [More details about route management](#more-details-about-route-management)  
47 - - [Dependency management](#dependency-management)  
48 - - [More details about dependency management](#more-details-about-dependency-management)  
49 -- [Utils](#utils)  
50 - - [Internationalization](#internationalization)  
51 - - [Translations](#translations)  
52 - - [Using translations](#using-translations)  
53 - - [Locales](#locales)  
54 - - [Change locale](#change-locale)  
55 - - [System locale](#system-locale)  
56 - - [Change Theme](#change-theme) 43 + - [リアクティブな状態管理](#リアクティブな状態管理)
  44 + - [状態管理に関する詳細ドキュメント](#状態管理に関する詳細ドキュメント)
  45 + - [Route管理](#Route管理)
  46 + - [Route管理に関する詳細ドキュメント](#Route管理に関する詳細ドキュメント)
  47 + - [依存オブジェクト管理](#依存オブジェクト管理)
  48 + - [依存オブジェクト管理に関する詳細ドキュメント](#依存オブジェクト管理に関する詳細ドキュメント)
  49 +- [ユーティリティ](#ユーティリティ)
  50 + - [多言語対応](#多言語対応)
  51 + - [翻訳ファイル](#翻訳ファイル)
  52 + - [翻訳ファイルの利用](#翻訳ファイルの利用)
  53 + - [ロケール](#ロケール)
  54 + - [ロケールの変更](#ロケールの変更)
  55 + - [システムのロケールを読み込む](#システムのロケールを読み込む)
  56 + - [Themeの変更](#Themeの変更)
57 - [GetConnect](#getconnect) 57 - [GetConnect](#getconnect)
58 - - [Default configuration](#default-configuration)  
59 - - [Custom configuration](#custom-configuration)  
60 - - [GetPage Middleware](#getpage-middleware)  
61 - - [Priority](#priority)  
62 - - [Redirect](#redirect) 58 + - [デフォルト設定](#デフォルト設定)
  59 + - [カスタム設定](#カスタム設定)
  60 + - [GetPageにミドルウェアを設定](#GetPageにミドルウェアを設定)
  61 + - [実行優先度](#実行優先度)
  62 + - [redirect](#redirect)
63 - [onPageCalled](#onpagecalled) 63 - [onPageCalled](#onpagecalled)
64 - - [OnBindingsStart](#onbindingsstart)  
65 - - [OnPageBuildStart](#onpagebuildstart)  
66 - - [OnPageBuilt](#onpagebuilt)  
67 - - [OnPageDispose](#onpagedispose)  
68 - - [Other Advanced APIs](#other-advanced-apis)  
69 - - [Optional Global Settings and Manual configurations](#optional-global-settings-and-manual-configurations)  
70 - - [Local State Widgets](#local-state-widgets) 64 + - [onBindingsStart](#onbindingsstart)
  65 + - [onPageBuildStart](#onpagebuildstart)
  66 + - [onPageBuilt](#onpagebuilt)
  67 + - [onPageDispose](#onpagedispose)
  68 + - [その他API](#その他API)
  69 + - [オプションのグローバル設定と手動設定](#オプションのグローバル設定と手動設定)
  70 + - [ローカルステートWidget](#ローカルステートWidget)
71 - [ValueBuilder](#valuebuilder) 71 - [ValueBuilder](#valuebuilder)
72 - [ObxValue](#obxvalue) 72 - [ObxValue](#obxvalue)
73 - - [Useful tips](#useful-tips) 73 + - [お役立ちTIPS](#お役立ちTIPS)
  74 + - [StateMixin](#statemixin)
74 - [GetView](#getview) 75 - [GetView](#getview)
75 - [GetResponsiveView](#getresponsiveview) 76 - [GetResponsiveView](#getresponsiveview)
76 - - [How to use it](#how-to-use-it) 77 + - [使い方](#使い方])
77 - [GetWidget](#getwidget) 78 - [GetWidget](#getwidget)
78 - [GetxService](#getxservice) 79 - [GetxService](#getxservice)
79 -- [Breaking changes from 2.0](#breaking-changes-from-20) 80 + - [テストの実行](#テストの実行)
  81 + - [mockitoやmocktailを使う場合](#mockitoやmocktailを使う場合)
  82 + - [Get.reset()](#Get.reset())
  83 + - [Get.testMode](#Get.testMode)
  84 +- [バージョン2.0からの破壊的変更](#バージョン2.0からの破壊的変更)
80 - [なぜGetXなのか](#なぜGetXなのか) 85 - [なぜGetXなのか](#なぜGetXなのか)
81 - [コミュニティ](#コミュニティ) 86 - [コミュニティ](#コミュニティ)
82 - [コミュニティチャンネル](#コミュニティチャンネル) 87 - [コミュニティチャンネル](#コミュニティチャンネル)
83 - - [貢献方法](#貢献方法)  
84 - - [GetXに関する記事とビデオ](#GetXに関する記事とビデオ) 88 + - [コントリビュート方法](#コントリビュート方法)
  89 + - [GetXに関する記事と動画](#GetXに関する記事と動画)
85 90
86 # Getとは 91 # Getとは
87 92
88 -- GetXはFlutterのための超軽量でパワフルなソリューションです。高パフォーマンスな状態管理、インテリジェントな依存性注入、そしてRoute管理の三本柱を迅速かつ実用的な形で組み合わせています。 93 +- GetXはFlutterのための超軽量でパワフルなソリューションです。高パフォーマンスな状態管理機能、インテリジェントな依存オブジェクト管理機能、そしてRoute管理機能の三本柱を軽量かつ実用的な形で組み合わせています。
89 94
90 -- GetXは3つの基本原則を元に開発されています。 **【生産性、パフォーマンス、コードの分離性】** これらはライブラリ内のすべてのリソースに優先適用される項目です。 95 +- GetXは3つの基本原則を念頭に開発されています。 **【生産性、パフォーマンス、コードの分離性】** これらはライブラリ内のすべてのリソースに優先適用されている原則です。
91 96
92 - - **パフォーマンス:** GetXは高いパフォーマンスと最小限のリソース消費を優先しています。GetXはStreamや ChangeNotifierを使用しません。 97 + - **パフォーマンス:** GetXは高いパフォーマンスと最小限のリソース消費を目標にしています。GetXはでは Stream および ChangeNotifier を利用しなくて済みます。
93 98
94 - - **生産性:** GetXはシンプルで使い心地のいい構文を採用しています。あなたの実現したい機能がどんなものであれ、GetXを使えばより簡単に実現できる方法が見つかるでしょう。開発にかかる時間を短縮し、あなたのアプリケーションのパフォーマンスを最大限引き出してくれます。 99 + - **生産性:** GetXはシンプルで使い心地のいいシンタックスを採用しています。あなたの実現したい機能がどんなものであれ、GetXを使えばより簡単に実現できる方法が見つかるでしょう。開発にかかる時間を短縮し、あなたのアプリケーションのパフォーマンスを最大限引き出してくれます。
95 100
96 - 開発者はcontrollerなどのリソースをメモリから削除することに気を配るのが常です。しかしGetXでは、リソースが使用されていないときはメモリから削除されるのがデフォルト動作のため、この必要はありません。(逆にメモリに残しておきたい場合は、依存オブジェクトのパラメーターで「permanent: true」と明示的に宣言します)これにより時間が節約できますし、不要な依存オブジェクトがメモリ上に残るリスクも少なくなります。メモリへの読み込みについてもデフォルトは遅延読み込みであり、使用するときに初めてメモリ上に読み込まれます。 101 + 開発者はメモリリソースの管理に気を配るのが常です。しかしGetXでは、リソースが使用されていないときはメモリから削除されるのがデフォルト動作のため、過度に気にかける必要はありません。(逆にメモリに残しておきたい場合は、依存オブジェクトをインスタンス化するメソッドを使う際に「permanent: true」と宣言してください)これにより時間が節約できますし、不要な依存オブジェクトがメモリ上に残るリスクも少なくなります。メモリへの読み込みについてもデフォルトは遅延読み込みであり、使用するときに初めてメモリ上に読み込まれます。
97 102
98 - - **コードの分離性:** GetXでは、View、プレゼンテーションロジック、ビジネスロジック、依存性注入、およびナビゲーション周りのコードを徹底して分離することができます。Route間のナビゲーションではcontextを必要としないため、Widgetツリーに依存することはありません。ロジックについてもInheritedWidget経由でcontroller/BLoCにアクセスするためのcontextは必要ありません。これによりプレゼンテーションロジックとビジネスロジックをUIレイヤーから完全に切り離すことができます。また、controller/model/BLoCのクラスを、`MultiProvider`を使ってWidgetツリーに注入する必要もありません。GetXでは独自の依存性注入機能を使用して、依存性注入とViewに関わるコードを完全に分離することができます。 103 + - **コードの分離性:** GetXを使うと、ビュー、プレゼンテーションロジック、ビジネスロジック、依存オブジェクトの注入、およびナビゲーション周りのコードを書き分けやすくなります。Routeのナビゲーションにはcontextを必要としないため、Widgetツリーに依存することはありません。ロジックについてもInheritedWidget経由でController/BLoCにアクセスする際のcontextは必要ありません。プレゼンテーションロジックとビジネスロジックをUIクラスから完全に切り離すことができます。また、Controller/モデル/BLoCのクラスを、`MultiProvider`を使ってWidgetツリーに注入する必要もありません。GetXでは独自の依存オブジェクト注入機能を使用し、ビュークラスからビューとは無関係なコードをなくすことができるのです。
99 104
100 - GetXを使うことでアプリケーションの各機能がどこに記載されているのかがわかりやすくなり、自然と見やすいコードになります。メンテナンスが容易になるだけでなく、それまでのFlutterでは考えられなかったモジュール共有が簡単に実現できるようになりました。  
101 - BLoCはその分野におけるFlutterの出発点でしたが、GetXはこれを正統進化させたもので、ビジネスロジックのみならずプレゼンテーションロジックも分離することができます。そのほか依存オブジェクトやRouteの注入も分離し、データレイヤーはこれらすべてから切り離されます。どこに何が配置されているのか構造がわかりやすくなり、Hello Worldを表示するよりも簡単に機能を利用できるようになるでしょう。  
102 - GetXはFlutter製の高性能アプリを作るために採用できる最も簡単で実用的、かつスケーラブルなソリューションです。強力なエコシステムも存在し、初心者にはわかりやすさ、プロフェッショナルには正確性を約束します。セキュアで安定的、かつFlutter/Dartの最新事情をいち早く反映し、Flutter SDKにはない幅広い種類のAPIを提供します。 105 + GetXを使うことでアプリケーションの各機能がどこにあるのかがわかりやすくなり、自然と見やすいコードになります。メンテナンスが容易になるだけでなく、それまでのFlutterでは考えられなかったモジュール共有が簡単に実現できるようになりました。
  106 + BLoCはこの分野におけるFlutterの出発点と言えるものでしたが、GetXはこれを正統進化させており、ビジネスロジックのみならずプレゼンテーションロジックも分離することができます。そのほかデータレイヤーはもちろん、依存オブジェクトやRouteの注入に関するコードも。どこに何が配置されているのか全体の見通しがしやすくなり、Hello Worldを表示させるかのように簡単にアプリの機能を利用できるようになるでしょう。
  107 + Flutterアプリを作るならGetXは最も簡単で実用的、かつスケーラブルなソリューションです。強力なエコシステムも存在があるため、初心者にはわかりやすさ、プロには正確性を提供することができます。そしてFlutter SDKにはない幅広い種類のAPIを提供し、セキュアで安定的な環境を構築します。
103 108
104 -- GetXは肥大化したライブラリではありません。何も気にせずすぐにプログラミングを始められるよう多数の機能を標準で備えていますが、それぞれの機能は個別にコンテナに入っており、使用してはじめて起動します。状態管理機能しか利用していない場合はその機能だけがコンパイルされます。Route管理機能だけを利用している場合は、状態管理機能は何もコンパイルされません。 109 +- GetXは肥大化したライブラリではありません。何も気にせずすぐに開発を始められるよう多数の機能を標準で備えていますが、それぞれの機能は個別にコンテナに入っており、使用してはじめて起動します。状態管理機能しか利用していない場合はその機能だけがコンパイルされます。Route管理機能だけを利用していれば、状態管理機能がコンパイルされることはありません。
105 110
106 -- GetXには大きなエコシステム、コミュニティ、コラボレーターの存在があるため、Flutterが存在する限りメンテナンスされ続けます。GetXもFlutterと同様にAndroid、iOS、Web、Mac、Linux、Windows、そしてあなたのサーバー上で、一つのコードから実行することができます。 111 +- GetXには巨大なエコシステム、コミュニティ、コラボレーターの存在があるため、Flutterが存在する限りメンテナンスされ続けます。またGetXもFlutterと同様にAndroid、iOS、Web、Mac、Linux、Windows、そしてあなたのサーバー上で、単一のコードから実行することができます。
107 112
108 **[Get Server](https://github.com/jonataslaw/get_server)を使うことで、フロントエンドで作成したコードをバックエンドで再利用することが可能です。** 113 **[Get Server](https://github.com/jonataslaw/get_server)を使うことで、フロントエンドで作成したコードをバックエンドで再利用することが可能です。**
109 114
@@ -137,7 +142,7 @@ Flutter縺ァ譁ー隕上繝ュ繧ク繧ァ繧ッ繝医r菴懈縺吶k髫帙↓陦ィ遉コ縺輔l繧九き繧ヲ繝ウ @@ -137,7 +142,7 @@ Flutter縺ァ譁ー隕上繝ュ繧ク繧ァ繧ッ繝医r菴懈縺吶k髫帙↓陦ィ遉コ縺輔l繧九き繧ヲ繝ウ
137 void main() => runApp(GetMaterialApp(home: Home())); 142 void main() => runApp(GetMaterialApp(home: Home()));
138 ``` 143 ```
139 144
140 -- 注1: GetMaterialAppはFlutterのMaterialAppに手を加えたものではありません。MaterialAppをchildに持ち、諸々の追加設定をしてくれるWidgetに過ぎません。この設定は手動でも可能ですが、その必要はありません。GetMaterialAppは、Routeの作成・注入、言語翻訳の注入など、ナビゲーションに必要なものをすべて注入してくれます。Getを状態管理や依存性注入に限定して使用する場合は、GetMaterialAppを使用する必要はありません。GetMaterialAppは、Route、SnackBar、多言語対応、BottomSheet、Dialog、contextなしの高レベルAPIを利用する場合に必要です。 145 +- 注1: GetMaterialAppはFlutterのMaterialAppに手を加えたものではありません。MaterialAppをchildに持ち、諸々の追加設定をしてくれるWidgetに過ぎません。この設定は手動でも可能ですが、その必要はありません。GetMaterialAppは、Routeの作成・注入、言語翻訳の注入など、ナビゲーションに必要なものをすべて注入してくれます。Getを状態管理や依存オブジェクト管理に限定して使用する場合は、GetMaterialAppを使用する必要はありません。GetMaterialAppは、Route、SnackBar、多言語対応、BottomSheet、Dialog、contextなしの高レベルAPIを利用する場合に必要です。
141 - 注2: このステップは、Route管理機能(`Get.to()`や`Get.back()`など)を使用しない場合は、必要ありません。 146 - 注2: このステップは、Route管理機能(`Get.to()`や`Get.back()`など)を使用しない場合は、必要ありません。
142 147
143 - ステップ2: 148 - ステップ2:
@@ -152,7 +157,7 @@ class Controller extends GetxController{ @@ -152,7 +157,7 @@ class Controller extends GetxController{
152 ``` 157 ```
153 158
154 - ステップ3: 159 - ステップ3:
155 - Viewを作成します。StatelessWidgetを使用することでRAMが節約できます。GetではStatefulWidgetを使用する必要がなくなるかもしれません。 160 + ビューを作成します。StatelessWidgetを使用することでRAMが節約できます。GetではStatefulWidgetを使用する必要がなくなるかもしれません。
156 161
157 ```dart 162 ```dart
158 class Home extends StatelessWidget { 163 class Home extends StatelessWidget {
@@ -160,7 +165,7 @@ class Home extends StatelessWidget { @@ -160,7 +165,7 @@ class Home extends StatelessWidget {
160 @override 165 @override
161 Widget build(context) { 166 Widget build(context) {
162 167
163 - // Get.put()を使ってクラスをインスタンス化することですべての「子」Routeで利用ができます。 168 + // Get.put()を使ってクラスをインスタンス化することですべての子Routeで利用できるようになります。
164 final Controller c = Get.put(Controller()); 169 final Controller c = Get.put(Controller());
165 170
166 return Scaffold( 171 return Scaffold(
@@ -201,16 +206,16 @@ Get縺ッ繝√繝縺ァ縺ョ菴懈・ュ繧呈Φ螳壹@縺ヲ險ュ險医&繧後※縺∪縺吶′縲∝倶ココ髢 @@ -201,16 +206,16 @@ Get縺ッ繝√繝縺ァ縺ョ菴懈・ュ繧呈Φ螳壹@縺ヲ險ュ險医&繧後※縺∪縺吶′縲∝倶ココ髢
201 206
202 ## 状態管理 207 ## 状態管理
203 208
204 -Getには、シンプルな手法(GetBuilder)と、リアクティブな手法(GetX/Obx)の2種類の状態管理手法があります。 209 +Getの状態管理には、非リアクティブ(GetBuilder)と、リアクティブ(GetX/Obx)の2つのアプローチがあります。
205 210
206 ### リアクティブな状態管理 211 ### リアクティブな状態管理
207 212
208 リアクティブプログラミングは複雑であると言われ、多くの人に敬遠されています。GetXは、リアクティブプログラミングをシンプルなものに変えます: 213 リアクティブプログラミングは複雑であると言われ、多くの人に敬遠されています。GetXは、リアクティブプログラミングをシンプルなものに変えます:
209 214
210 -- StreamControllerを作る必要がありません。  
211 -- 変数の数だけStreamBuilderを準備する必要がありません。  
212 -- 状態ごとにクラスを作成する必要がありません。  
213 -- 最初の値に対してgetを作成する必要がありません。 215 +* StreamControllerを作る必要はありません。
  216 +* 変数ごとにStreamBuilderをセットする必要はありません。
  217 +* 状態ごとにクラスを作る必要はありません。
  218 +* 初期値のためにgetを準備する必要はありません。
214 - コードの自動生成をする必要がありません。 219 - コードの自動生成をする必要がありません。
215 220
216 GetにおけるリアクティブプログラミングはsetStateと同じように簡単です。 221 GetにおけるリアクティブプログラミングはsetStateと同じように簡単です。
@@ -221,7 +226,7 @@ Get縺ォ縺翫¢繧九Μ繧「繧ッ繝ぅ繝悶繝ュ繧ー繝ゥ繝溘Φ繧ー縺ッsetState縺ィ蜷後§繧医≧ @@ -221,7 +226,7 @@ Get縺ォ縺翫¢繧九Μ繧「繧ッ繝ぅ繝悶繝ュ繧ー繝ゥ繝溘Φ繧ー縺ッsetState縺ィ蜷後§繧医≧
221 var name = 'Jonatas Borges'; 226 var name = 'Jonatas Borges';
222 ``` 227 ```
223 228
224 -このnameを監視可能にするには, ".obs"を値の末尾に付けるだけです。 229 +このnameをObservable(監視可能)にするには, ".obs"を値の末尾に付けるだけです。
225 230
226 ```dart 231 ```dart
227 var name = 'Jonatas Borges'.obs; 232 var name = 'Jonatas Borges'.obs;
@@ -235,9 +240,9 @@ Obx(() => Text("${controller.name}")); @@ -235,9 +240,9 @@ Obx(() => Text("${controller.name}"));
235 240
236 以上です。こんなに簡単なんですよ。 241 以上です。こんなに簡単なんですよ。
237 242
238 -### 状態管理についての詳細 243 +### 状態管理に関する詳細ドキュメント
239 244
240 -**状態管理のより詳細な説明を知りたい方は[こちら](./documentation/ja_JP/state_management.md)をご覧ください。より多くの例や、普通の状態管理とリアクティブな状態管理の違いについても説明されています。** 245 +**状態管理に関するより詳細な説明を知りたい方は[こちらの日本語ドキュメント](./documentation/ja_JP/state_management.md)をご覧ください。多くの事例や、非リアクティブな状態管理とリアクティブな状態管理の違いについても説明されています。**
241 246
242 GetXパワーがもたらす利点をより理解していただけると思います。 247 GetXパワーがもたらす利点をより理解していただけると思います。
243 248
@@ -253,13 +258,13 @@ GetMaterialApp( // MaterialApp 縺ョ蜑阪↓ Get @@ -253,13 +258,13 @@ GetMaterialApp( // MaterialApp 縺ョ蜑阪↓ Get
253 ) 258 )
254 ``` 259 ```
255 260
256 -新しいRouteに画面遷移するにはこの構文。 261 +新しいRouteに画面遷移するにはこのシンタックス。
257 262
258 ```dart 263 ```dart
259 Get.to(NextScreen()); 264 Get.to(NextScreen());
260 ``` 265 ```
261 266
262 -名前付きRouteに画面遷移するにはこの構文。名前付きRouteの詳細は[こちら](./documentation/ja_JP/route_management.md#navigation-with-named-routes) 267 +名前付きRouteに画面遷移するにはこのシンタックス。名前付きRouteの詳細は[こちらの日本語ドキュメント](./documentation/ja_JP/route_management.md#navigation-with-named-routes)
263 268
264 ```dart 269 ```dart
265 Get.toNamed('/details'); 270 Get.toNamed('/details');
@@ -285,29 +290,29 @@ Get.offAll(NextScreen()); @@ -285,29 +290,29 @@ Get.offAll(NextScreen());
285 290
286 以上、contextを一度も使わなかったことに気付きましたか?これがGetでRoute管理を行う最大のメリットのひとつです。contextを使わないので、たとえばcontrollerクラスの中でも、これらのメソッドを実行することができます。 291 以上、contextを一度も使わなかったことに気付きましたか?これがGetでRoute管理を行う最大のメリットのひとつです。contextを使わないので、たとえばcontrollerクラスの中でも、これらのメソッドを実行することができます。
287 292
288 -### Route管理についての詳細 293 +### Route管理に関する詳細ドキュメント
289 294
290 -**Getは名前付きRouteでも動作し、Routeの下位レベルの制御も可能です。詳細なドキュメントは[こちら](./documentation/ja_JP/route_management.md)にあります。** 295 +**Getは名前付きRouteでも動作し、Routeの下位レベルの制御も可能です。詳細なドキュメントは[こちらの日本語ドキュメント](./documentation/ja_JP/route_management.md)にあります。**
291 296
292 -## 依存性注入の管理 297 +## 依存オブジェクト管理
293 298
294 -Getにはシンプルで強力な依存性注入機能があります。わずか1行のコードで、Provider contextやinheritedWidgetも使わず、BLoCやControllerのようなクラスのインスタンスを取得することができます。 299 +Getにはシンプルで強力な依存オブジェクト注入機能があります。わずか1行のコードで、Provider contextやinheritedWidgetも使わず、BLoCやControllerのようなクラスのインスタンスを取得することができます。
295 300
296 ```dart 301 ```dart
297 Controller controller = Get.put(Controller()); // controller = Controller() とする代わりに 302 Controller controller = Get.put(Controller()); // controller = Controller() とする代わりに
298 ``` 303 ```
299 304
300 -- 注: Getの状態管理機能を使用している場合は、Bindings APIにもご注目を。BindingsはViewとControllerを結びつけるのをより便利にしてくれます。 305 +- 注: Getの状態管理機能を使用している場合は、Bindings APIにもご注目を。BindingsはビューとControllerを結びつけるのをより便利にしてくれます。
301 306
302 一つのクラスの中でControllerクラスをインスタンス化するのではなく、Getインスタンスの中でインスタンス化することで、アプリ全体でControllerが利用できるようになります。 307 一つのクラスの中でControllerクラスをインスタンス化するのではなく、Getインスタンスの中でインスタンス化することで、アプリ全体でControllerが利用できるようになります。
303 308
304 -**ヒント:** Getの依存性注入機能の部分は、パッケージ全体の中でも他の部分と切り離されているので、たとえば、あなたのアプリがすでに状態管理機能を一部で使用していたとしても、それらを書き直す必要はなく、この依存性注入機能をそのまま使用することができます。 309 +**ヒント:** Getの依存オブジェクト注入機能の部分は、パッケージ全体の中でも他の部分と切り離されているので、たとえば、あなたのアプリがすでに状態管理機能を一部で使用していたとしても、それらを書き直す必要はなく、この依存オブジェクト注入機能をそのまま使用することができます。
305 310
306 ```dart 311 ```dart
307 controller.fetchApi(); 312 controller.fetchApi();
308 ``` 313 ```
309 314
310 -色々なRouteを行き来した後に、あるControllerクラスのデータにアクセスする必要が生じたとしましょう。ProviderやGet_itなら再びそのクラスに依存性注入する必要がありますよね?Getの場合は違います。Getでは「find」と依頼するだけで、追加の依存性注入は必要ありません。 315 +色々なRouteを行き来した後に、あるControllerクラスのデータにアクセスする必要が生じたとしましょう。ProviderやGet_itなら再びそのクラスに依存オブジェクトを注入する必要がありますよね?Getの場合は違います。Getでは「find」と依頼するだけで、追加の依存オブジェクトの注入は必要ありません。
311 316
312 ```dart 317 ```dart
313 Controller controller = Get.find(); 318 Controller controller = Get.find();
@@ -320,15 +325,15 @@ Controller controller = Get.find(); @@ -320,15 +325,15 @@ Controller controller = Get.find();
320 Text(controller.textFromApi); 325 Text(controller.textFromApi);
321 ``` 326 ```
322 327
323 -### 依存性注入の管理についての詳細 328 +### 依存オブジェクト管理に関する詳細ドキュメント
324 329
325 -**依存性注入管理のより詳細な説明は[こちら](./documentation/ja_JP/dependency_management.md)をご覧ください。** 330 +**依存オブジェクト管理に関するより詳細な説明は[こちらの日本語ドキュメント](./documentation/ja_JP/dependency_management.md)をご覧ください。**
326 331
327 # ユーティリティ 332 # ユーティリティ
328 333
329 ## 多言語対応 334 ## 多言語対応
330 335
331 -### 翻訳 336 +### 翻訳ファイル
332 337
333 翻訳ファイルはシンプルなキーと値のMapとして保持されます。 338 翻訳ファイルはシンプルなキーと値のMapとして保持されます。
334 翻訳を追加するには、クラスを作成して `Translations` を継承します。 339 翻訳を追加するには、クラスを作成して `Translations` を継承します。
@@ -349,7 +354,7 @@ class Messages extends Translations { @@ -349,7 +354,7 @@ class Messages extends Translations {
349 } 354 }
350 ``` 355 ```
351 356
352 -#### 翻訳の利用 357 +#### 翻訳ファイルの利用
353 358
354 指定されたキーに `.tr` (translateのtr)を追加するだけで、`Get.locale` と `Get.fallbackLocale` の現在の値をに沿って適切な言語に翻訳されます。 359 指定されたキーに `.tr` (translateのtr)を追加するだけで、`Get.locale` と `Get.fallbackLocale` の現在の値をに沿って適切な言語に翻訳されます。
355 360
@@ -406,7 +411,7 @@ var locale = Locale('en', 'US'); @@ -406,7 +411,7 @@ var locale = Locale('en', 'US');
406 Get.updateLocale(locale); 411 Get.updateLocale(locale);
407 ``` 412 ```
408 413
409 -#### システムロケール 414 +#### システムのロケールを読み込む
410 415
411 システムのロケールを読み込むには、`Get.deviceLocale`を使用します。 416 システムのロケールを読み込むには、`Get.deviceLocale`を使用します。
412 417
@@ -513,13 +518,13 @@ class HomeProvider extends GetConnect { @@ -513,13 +518,13 @@ class HomeProvider extends GetConnect {
513 } 518 }
514 ``` 519 ```
515 520
516 -## GetPageのミドルウェア 521 +## GetPageにミドルウェアを設定
517 522
518 GetPageに新しいプロパティが追加され、GetMiddleWareのListを設定することができるようになりました。GetMiddleWareは設定した任意の順序で実行されます。 523 GetPageに新しいプロパティが追加され、GetMiddleWareのListを設定することができるようになりました。GetMiddleWareは設定した任意の順序で実行されます。
519 524
520 -**注**: GetPageにMiddlewareを設定すると、そのページの下にあるchildはすべて同じMiddlewareを自動的に持つことになります。 525 +**注**: GetPageにミドルウェアを設定すると、そのページの子ページはすべて同じミドルウェアを自動的に持つことになります。
521 526
522 -### 実行順 527 +### 実行優先度
523 528
524 GetMiddlewareに設定したpriority(優先度)の若い順にミドルウェアが実行されます。 529 GetMiddlewareに設定したpriority(優先度)の若い順にミドルウェアが実行されます。
525 530
@@ -574,7 +579,7 @@ List<Bindings> onBindingsStart(List<Bindings> bindings) { @@ -574,7 +579,7 @@ List<Bindings> onBindingsStart(List<Bindings> bindings) {
574 579
575 ### onPageBuildStart 580 ### onPageBuildStart
576 581
577 -onPageBuildStart関数は、Bindingsが初期化された直後、ページWidetが作成される前に実行されます。 582 +onPageBuildStart関数は、Bindingsが初期化された直後、ページWidgetが作成され前に実行されます。
578 583
579 ```dart 584 ```dart
580 GetPageBuilder onPageBuildStart(GetPageBuilder page) { 585 GetPageBuilder onPageBuildStart(GetPageBuilder page) {
@@ -589,7 +594,7 @@ onPageBuilt髢「謨ー縺ッ縲;etPage.page(繝壹繧ク縺ョ繝薙Ν繝繝シ)縺悟他縺ウ蜃コ縺輔l @@ -589,7 +594,7 @@ onPageBuilt髢「謨ー縺ッ縲;etPage.page(繝壹繧ク縺ョ繝薙Ν繝繝シ)縺悟他縺ウ蜃コ縺輔l
589 594
590 ### onPageDispose 595 ### onPageDispose
591 596
592 -onPageDispose関数は、ページに関するすべてのオブジェクト(Controller、Viewなど)が破棄された直後に実行されます。 597 +onPageDispose関数は、ページに関するすべてのオブジェクト(Controller、ビューなど)が破棄された直後に実行されます
593 598
594 ## その他API 599 ## その他API
595 600
@@ -764,7 +769,7 @@ Get.config( @@ -764,7 +769,7 @@ Get.config(
764 ``` 769 ```
765 770
766 オプションで、すべてのログメッセージを `Get` からリダイレクトさせることができます。 771 オプションで、すべてのログメッセージを `Get` からリダイレクトさせることができます。
767 -好きなロギングのパッケージを使ってログを取得したい場合はこのようにしてください。 772 +お好みのロギングパッケージを使ってログを取得したい場合はこのようにしてください。
768 773
769 ```dart 774 ```dart
770 GetMaterialApp( 775 GetMaterialApp(
@@ -782,24 +787,22 @@ void localLogWriter(String text, {bool isError = false}) { @@ -782,24 +787,22 @@ void localLogWriter(String text, {bool isError = false}) {
782 787
783 ### ローカルステートWidget 788 ### ローカルステートWidget
784 789
785 -These Widgets allows you to manage a single value, and keep the state ephemeral and locally.  
786 -We have flavours for Reactive and Simple.  
787 -For instance, you might use them to toggle obscureText in a `TextField`, maybe create a custom  
788 -Expandable Panel, or maybe modify the current index in `BottomNavigationBar` while changing the content  
789 -of the body in a `Scaffold`. 790 +ローカルステートWidgetは、1つの変数の状態を一時的かつローカルに管理したい場合に便利です。
  791 +シンプルなValueBuilderとリアクティブなObxValueの2種類があります。
  792 +たとえば、`TextField` Widgetの obscureText プロパティを切り替えたり、折りたたみ可能なパネルをカスタムで作成したり、`BottomNavigation` の現在のインデックス値を変更して内容を変更したりといった用途に最適です。
790 793
791 #### ValueBuilder 794 #### ValueBuilder
792 795
793 -A simplification of `StatefulWidget` that works with a `.setState` callback that takes the updated value. 796 +setStateでお馴染みの `StatefulWidget` をシンプルにしたビルダーWidgetです。
794 797
795 ```dart 798 ```dart
796 ValueBuilder<bool>( 799 ValueBuilder<bool>(
797 initialValue: false, 800 initialValue: false,
798 builder: (value, updateFn) => Switch( 801 builder: (value, updateFn) => Switch(
799 value: value, 802 value: value,
800 - onChanged: updateFn, // same signature! you could use ( newValue ) => updateFn( newValue ) 803 + onChanged: updateFn, // ( newValue ) => updateFn( newValue ) も可
801 ), 804 ),
802 - // if you need to call something outside the builder method. 805 + // builderメソッドの外で何か実行する場合
803 onUpdate: (value) => print("Value updated: $value"), 806 onUpdate: (value) => print("Value updated: $value"),
804 onDispose: () => print("Widget unmounted"), 807 onDispose: () => print("Widget unmounted"),
805 ), 808 ),
@@ -807,96 +810,97 @@ ValueBuilder<bool>( @@ -807,96 +810,97 @@ ValueBuilder<bool>(
807 810
808 #### ObxValue 811 #### ObxValue
809 812
810 -Similar to [`ValueBuilder`](#valuebuilder), but this is the Reactive version, you pass a Rx instance (remember the magical .obs?) and  
811 -updates automatically... isn't it awesome? 813 +[`ValueBuilder`](#valuebuilder)に似ていますが、これはそのリアクティブバージョンです。Rxインスタンス(.obsを付けたときに戻る値です)を渡すと自動で更新されます。すごいでしょ?
812 814
813 ```dart 815 ```dart
814 ObxValue((data) => Switch( 816 ObxValue((data) => Switch(
815 value: data.value, 817 value: data.value,
816 - onChanged: data, // Rx has a _callable_ function! You could use (flag) => data.value = flag, 818 + onChanged: data,
  819 + // Rxには_呼び出し可能な_関数が備わっているのでこれだけでOK
  820 + // (flag) => data.value = flag も可能
817 ), 821 ),
818 false.obs, 822 false.obs,
819 ), 823 ),
820 ``` 824 ```
821 825
822 -## Useful tips 826 +## お役立ちTIPS
823 827
824 -`.obs`ervables (also known as _Rx_ Types) have a wide variety of internal methods and operators. 828 +`.obs`が付いた型(_Rx_型とも呼ばれる)には、さまざまな内部メソッドや演算子が用意されています。
825 829
826 -> Is very common to _believe_ that a property with `.obs` **IS** the actual value... but make no mistake!  
827 -> We avoid the Type declaration of the variable, because Dart's compiler is smart enough, and the code  
828 -> looks cleaner, but: 830 +> `.obs`が付いたプロパティが **実際の値** だと信じてしまいがちですが...間違えないように!
  831 +> 我々がcontrollerにおける変数の型宣言を省略してvarとしているのはDartのコンパイラが賢い上に、
  832 +> そのほうがコードがすっきる見えるからですが…
829 833
830 ```dart 834 ```dart
831 var message = 'Hello world'.obs; 835 var message = 'Hello world'.obs;
832 print( 'Message "$message" has Type ${message.runtimeType}'); 836 print( 'Message "$message" has Type ${message.runtimeType}');
833 ``` 837 ```
834 838
835 -Even if `message` _prints_ the actual String value, the Type is **RxString**! 839 +`message`を _print_ することで実際の文字列が取り出されはしますが、型は **RxString** です!
836 840
837 -So, you can't do `message.substring( 0, 4 )`.  
838 -You have to access the real `value` inside the _observable_:  
839 -The most "used way" is `.value`, but, did you know that you can also use... 841 +そのため `message.substring( 0, 4 )` などといったことはできません。
  842 +Stringのメソッドにアクセスするには _observable_ の中にある実際の値 `value` にアクセスします。
  843 +アクセスには `.value`を使うのが通常ですが、他の方法もあるのでご紹介します。
840 844
841 ```dart 845 ```dart
842 final name = 'GetX'.obs; 846 final name = 'GetX'.obs;
843 -// only "updates" the stream, if the value is different from the current one. 847 +// 新しい値が現在のものと異なる場合のみ Stream が更新されます。
844 name.value = 'Hey'; 848 name.value = 'Hey';
845 849
846 -// All Rx properties are "callable" and returns the new value.  
847 -// but this approach does not accepts `null`, the UI will not rebuild. 850 +// すべてのRxプロパティは「呼び出し可能」で、valueを返してくれます。
  851 +// ただし `null` は受付不可。nullの場合はUIが更新されない。
848 name('Hello'); 852 name('Hello');
849 853
850 -// is like a getter, prints 'Hello'. 854 +// これはgetterみたいなものです。'Hello' を返します。
851 name() ; 855 name() ;
852 856
853 -/// numbers: 857 +/// num型の場合
854 858
855 final count = 0.obs; 859 final count = 0.obs;
856 860
857 -// You can use all non mutable operations from num primitives! 861 +// num型の非破壊的な演算子はすべて使えます。
858 count + 1; 862 count + 1;
859 863
860 -// Watch out! this is only valid if `count` is not final, but var 864 +// 注意! この場合は`count`がfinalなら有効ではないです。varなら有効。
861 count += 1; 865 count += 1;
862 866
863 -// You can also compare against values: 867 +// 比較演算子も使用可能
864 count > 2; 868 count > 2;
865 869
866 -/// booleans: 870 +/// bool型の場合
867 871
868 final flag = false.obs; 872 final flag = false.obs;
869 873
870 -// switches the value between true/false 874 +// true/false を入れ替えることができます。
871 flag.toggle(); 875 flag.toggle();
872 876
873 877
874 -/// all types: 878 +/// すべての型
875 879
876 -// Sets the `value` to null. 880 +// `value` を null にセット。
877 flag.nil(); 881 flag.nil();
878 882
879 -// All toString(), toJson() operations are passed down to the `value`  
880 -print( count ); // calls `toString()` inside for RxInt 883 +// toString(), toJson() などの操作はすべて `value` が対象になります。
  884 +print( count ); // RxIntの `toString()` が呼び出されて数字がprintされる。
881 885
882 final abc = [0,1,2].obs; 886 final abc = [0,1,2].obs;
883 -// Converts the value to a json Array, prints RxList  
884 -// Json is supported by all Rx types! 887 +// json配列に変換した値と、'RxList' がprintされます。
  888 +// JsonはすべてのRx型でサポートされています!
885 print('json: ${jsonEncode(abc)}, type: ${abc.runtimeType}'); 889 print('json: ${jsonEncode(abc)}, type: ${abc.runtimeType}');
886 890
887 -// RxMap, RxList and RxSet are special Rx types, that extends their native types.  
888 -// but you can work with a List as a regular list, although is reactive!  
889 -abc.add(12); // pushes 12 to the list, and UPDATES the stream.  
890 -abc[3]; // like Lists, reads the index 3. 891 +// RxMap、RxList、RxSetはそれぞれの元の型を拡張した特別なRx型です。
  892 +// たとえばRxListは通常のListとして扱うことができる上にリアクティブです。
  893 +abc.add(12); // 12をListにプッシュし、Streamを更新してくれます。
  894 +abc[3]; // Listと同様にインデックス番号3の値を取得してくれます。
891 895
892 896
893 -// equality works with the Rx and the value, but hashCode is always taken from the value 897 +// 等価演算子はRx型と元の型でも動作しますが、.hashCode は常にvalueから取得します。
894 final number = 12.obs; 898 final number = 12.obs;
895 -print( number == 12 ); // prints > true 899 +print( number == 12 ); // true
896 900
897 -/// Custom Rx Models: 901 +/// カスタムのRxモデル
898 902
899 -// toJson(), toString() are deferred to the child, so you can implement override on them, and print() the observable directly. 903 +// toJson()やtoString()をモデルクラスに設定すれば、.obsからでもprintされるように実装可能。
900 904
901 class User { 905 class User {
902 String name, last; 906 String name, last;
@@ -909,39 +913,37 @@ class User { @@ -909,39 +913,37 @@ class User {
909 913
910 final user = User(name: 'John', last: 'Doe', age: 33).obs; 914 final user = User(name: 'John', last: 'Doe', age: 33).obs;
911 915
912 -// `user` is "reactive", but the properties inside ARE NOT!  
913 -// So, if we change some variable inside of it... 916 +// `user` 自体はリアクティブですが、その中のプロパティはリアクティブではありません。
  917 +// そのため、このようにプロパティの値を変更してもWidgetは更新されません。
914 user.value.name = 'Roi'; 918 user.value.name = 'Roi';
915 -// The widget will not rebuild!,  
916 -// `Rx` don't have any clue when you change something inside user.  
917 -// So, for custom classes, we need to manually "notify" the change. 919 +// `Rx` には自ら変更を検知する手段がないからです。
  920 +// そのため、カスタムクラスの場合はこのようにWidgetに変更を知らせる必要があります。
918 user.refresh(); 921 user.refresh();
919 922
920 -// or we can use the `update()` method! 923 +// もしくは `update()` メソッドを使用してください。
921 user.update((value){ 924 user.update((value){
922 value.name='Roi'; 925 value.name='Roi';
923 }); 926 });
924 927
925 print( user ); 928 print( user );
926 ``` 929 ```
927 -## StateMixin 930 +#### StateMixin
928 931
929 -Another way to handle your `UI` state is use the `StateMixin<T>` .  
930 -To implement it, use the `with` to add the `StateMixin<T>`  
931 -to your controller which allows a T model. 932 +`UI`の状態を管理するもう一つの手法として、`StateMixin<T>`を利用する方法があります。
  933 +controllerクラスに`with`を使って`StateMixin<T>`を追加することで実装可能です。
932 934
933 ``` dart 935 ``` dart
934 class Controller extends GetController with StateMixin<User>{} 936 class Controller extends GetController with StateMixin<User>{}
935 ``` 937 ```
936 938
937 -The `change()` method change the State whenever we want.  
938 -Just pass the data and the status in this way: 939 +`change()`メソッドにより好きなタイミングで状態を変更することができます。
  940 +このようにデータと状態を渡すだけです。
939 941
940 ```dart 942 ```dart
941 change(data, status: RxStatus.success()); 943 change(data, status: RxStatus.success());
942 ``` 944 ```
943 945
944 -RxStatus allow these status: 946 +RxStatus には以下のステータスが存在します。
945 947
946 ``` dart 948 ``` dart
947 RxStatus.loading(); 949 RxStatus.loading();
@@ -950,7 +952,7 @@ RxStatus.empty(); @@ -950,7 +952,7 @@ RxStatus.empty();
950 RxStatus.error('message'); 952 RxStatus.error('message');
951 ``` 953 ```
952 954
953 -To represent it in the UI, use: 955 +ステータスごとにUIを設定するにはこのようにします。
954 956
955 ```dart 957 ```dart
956 class OtherClass extends GetView<Controller> { 958 class OtherClass extends GetView<Controller> {
@@ -961,13 +963,13 @@ class OtherClass extends GetView<Controller> { @@ -961,13 +963,13 @@ class OtherClass extends GetView<Controller> {
961 body: controller.obx( 963 body: controller.obx(
962 (state)=>Text(state.name), 964 (state)=>Text(state.name),
963 965
964 - // here you can put your custom loading indicator, but  
965 - // by default would be Center(child:CircularProgressIndicator()) 966 + // ローディング中はカスタムのインジケーターの設定も可能ですが、
  967 + // デフォルトで Center(child:CircularProgressIndicator()) となります。
966 onLoading: CustomLoadingIndicator(), 968 onLoading: CustomLoadingIndicator(),
967 onEmpty: Text('No data found'), 969 onEmpty: Text('No data found'),
968 970
969 - // here also you can set your own error widget, but by  
970 - // default will be an Center(child:Text(error)) 971 + // 同様にエラーWidgetはカスタム可能ですが、
  972 + // デフォルトは Center(child:Text(error)) です。
971 onError: (error)=>Text(error), 973 onError: (error)=>Text(error),
972 ), 974 ),
973 ); 975 );
@@ -976,22 +978,22 @@ class OtherClass extends GetView<Controller> { @@ -976,22 +978,22 @@ class OtherClass extends GetView<Controller> {
976 978
977 #### GetView 979 #### GetView
978 980
979 -I love this Widget, is so simple, yet, so useful! 981 +このWidgetは私のお気に入りです。とてもシンプルで扱いやすいですよ!
980 982
981 -Is a `const Stateless` Widget that has a getter `controller` for a registered `Controller`, that's all. 983 +このWidgetを一言で表現すると、「controllerをgetterに持つ `const` な StatelessWidget」です。
982 984
983 ```dart 985 ```dart
984 class AwesomeController extends GetController { 986 class AwesomeController extends GetController {
985 final String title = 'My Awesome View'; 987 final String title = 'My Awesome View';
986 } 988 }
987 989
988 - // ALWAYS remember to pass the `Type` you used to register your controller! 990 + // controllerの `型` を渡すのを忘れずに!
989 class AwesomeView extends GetView<AwesomeController> { 991 class AwesomeView extends GetView<AwesomeController> {
990 @override 992 @override
991 Widget build(BuildContext context) { 993 Widget build(BuildContext context) {
992 return Container( 994 return Container(
993 padding: EdgeInsets.all(20), 995 padding: EdgeInsets.all(20),
994 - child: Text(controller.title), // just call `controller.something` 996 + child: Text(controller.title), // `controller.なんとか` でアクセス
995 ); 997 );
996 } 998 }
997 } 999 }
@@ -999,66 +1001,60 @@ Is a `const Stateless` Widget that has a getter `controller` for a registered `C @@ -999,66 +1001,60 @@ Is a `const Stateless` Widget that has a getter `controller` for a registered `C
999 1001
1000 #### GetResponsiveView 1002 #### GetResponsiveView
1001 1003
1002 -Extend this widget to build responsive view.  
1003 -this widget contains the `screen` property that have all  
1004 -information about the screen size and type. 1004 +GetViewをレスポンシブデザインに対応させたい場合はこのWidgetを継承してください。
  1005 +画面サイズやデバイスタイプなどの情報を持つ `screen` プロパティを保持しています。
1005 1006
1006 -##### How to use it 1007 +##### 使い方
1007 1008
1008 -You have two options to build it. 1009 +Widgetをビルドする方法は2つあります。
1009 1010
1010 -- with `builder` method you return the widget to build.  
1011 -- with methods `desktop`, `tablet`,`phone`, `watch`. the specific  
1012 - method will be built when the screen type matches the method  
1013 - when the screen is [ScreenType.Tablet] the `tablet` method  
1014 - will be exuded and so on.  
1015 - **Note:** If you use this method please set the property `alwaysUseBuilder` to `false` 1011 +- `builder` メソッドを使う。
  1012 +- `desktop`, `tablet`, `phone`, `watch` メソッドを使う。
  1013 + 画面サイズ、デバイスタイプに応じたWidgetがビルドされます。
  1014 + たとえば画面が [ScreenType.Tablet] なら `tablet` メソッドが実行されます。
  1015 + **注:** `alwaysUseBuilder` プロパティをfalseにする必要があります。
1016 1016
1017 -With `settings` property you can set the width limit for the screen types. 1017 +`settings` プロパティでブレイクポイントを設定することもできます。
1018 1018
1019 -![example](https://github.com/SchabanBo/get_page_example/blob/master/docs/Example.gif?raw=true)  
1020 -Code to this screen  
1021 -[code](https://github.com/SchabanBo/get_page_example/blob/master/lib/pages/responsive_example/responsive_view.dart) 1019 +![](https://github.com/SchabanBo/get_page_example/blob/master/docs/Example.gif?raw=true)
  1020 +この画面のコード
  1021 +[コード](https://github.com/SchabanBo/get_page_example/blob/master/lib/pages/responsive_example/responsive_view.dart)
1022 1022
1023 #### GetWidget 1023 #### GetWidget
1024 1024
1025 -Most people have no idea about this Widget, or totally confuse the usage of it.  
1026 -The use case is very rare, but very specific: It `caches` a Controller.  
1027 -Because of the _cache_, can't be a `const Stateless`. 1025 +このWidgetはあまり知られておらず、使用するケースは稀です。
  1026 +GetViewとの違いは、Controllerを`キャッシュ`してくれる点です。
  1027 +このキャッシュがあるため `const` にはできません。
1028 1028
1029 -> So, when do you need to "cache" a Controller? 1029 +> それでは一体いつControllerをキャッシュする必要があるのかって?
1030 1030
1031 -If you use, another "not so common" feature of **GetX**: `Get.create()`. 1031 +それは **GetX** のこれまた使う機会の少ない `Get.create()` を使うときです。
1032 1032
1033 -`Get.create(()=>Controller())` will generate a new `Controller` each time you call  
1034 -`Get.find<Controller>()`, 1033 +`Get.create(()=>Controller())` は `Get.find<Controller>()` を実行するたびに
  1034 +新しいControllerインスタンスを生成します。
1035 1035
1036 -That's where `GetWidget` shines... as you can use it, for example,  
1037 -to keep a list of Todo items. So, if the widget gets "rebuilt", it will keep the same controller instance. 1036 +そこで `GetWidget` の出番です。たとえば、Todoアイテムのリスト内容を保持したいとき。
  1037 +Widgetが更新されてもアイテムはControllerのキャッシュを参照してくれます。
1038 1038
1039 #### GetxService 1039 #### GetxService
1040 1040
1041 -This class is like a `GetxController`, it shares the same lifecycle ( `onInit()`, `onReady()`, `onClose()`).  
1042 -But has no "logic" inside of it. It just notifies **GetX** Dependency Injection system, that this subclass  
1043 -**can not** be removed from memory. 1041 +このクラスは `GetxController` に似ており、同様のライフサイクル(`onInit()`, `onReady()`, `onClose()`)を共有しますが、そこに「ロジック」はありません。**GetX**の依存オブジェクト注入システムに、このサブクラスがメモリから **削除できない** ということを知らせるだけです。
1044 1042
1045 -So is super useful to keep your "Services" always reachable and active with `Get.find()`. Like:  
1046 -`ApiService`, `StorageService`, `CacheService`. 1043 +そのため `Get.find()` で `ApiService`, `StorageService`, `CacheService` のようなサービス系クラスにいつでもアクセスできるようにしておくと非常に便利です。
1047 1044
1048 ```dart 1045 ```dart
1049 Future<void> main() async { 1046 Future<void> main() async {
1050 - await initServices(); /// AWAIT SERVICES INITIALIZATION. 1047 + await initServices(); /// サービスクラスの初期化をawait
1051 runApp(SomeApp()); 1048 runApp(SomeApp());
1052 } 1049 }
1053 1050
1054 -/// Is a smart move to make your Services intiialize before you run the Flutter app.  
1055 -/// as you can control the execution flow (maybe you need to load some Theme configuration,  
1056 -/// apiKey, language defined by the User... so load SettingService before running ApiService.  
1057 -/// so GetMaterialApp() doesnt have to rebuild, and takes the values directly. 1051 +/// Flutterアプリ実行前にサービスクラスを初期化してフローをコントロールするのは賢いやり方です。
  1052 +/// たとえば GetMaterialAppを更新する必要がないようにUser別の
  1053 +/// Theme、apiKey、言語設定などをApiサービス実行前にロードしたり。
1058 void initServices() async { 1054 void initServices() async {
1059 print('starting services ...'); 1055 print('starting services ...');
1060 - /// Here is where you put get_storage, hive, shared_pref initialization.  
1061 - /// or moor connection, or whatever that's async. 1056 + /// get_storage, hive, shared_pref の初期化はここで行います。
  1057 + /// あるいは moor の connection など非同期のメソッドならなんでも。
1062 await Get.putAsync(() => DbService().init()); 1058 await Get.putAsync(() => DbService().init());
1063 await Get.putAsync(SettingsService()).init(); 1059 await Get.putAsync(SettingsService()).init();
1064 print('All services started...'); 1060 print('All services started...');
@@ -1083,21 +1079,21 @@ class SettingsService extends GetxService { @@ -1083,21 +1079,21 @@ class SettingsService extends GetxService {
1083 1079
1084 ``` 1080 ```
1085 1081
1086 -The only way to actually delete a `GetxService`, is with `Get.reset()` which is like a  
1087 -"Hot Reboot" of your app. So remember, if you need absolute persistence of a class instance during the  
1088 -lifetime of your app, use `GetxService`. 1082 +`GetxService` を破棄する唯一の方法は `Get.reset()` メソッドを使うことです。
  1083 +これはアプリにおける「ホットリブート」のようなものです。あるクラスのインスタンスを
  1084 +ライフサイクルの間ずっと残しておきたい場合は `GetxService` を使うというのを覚えておいてください。
1089 1085
1090 1086
1091 -### Tests 1087 +## テストの実行
1092 1088
1093 -You can test your controllers like any other class, including their lifecycles: 1089 +Controllerのライフサイクル含め、他のクラスと同様にテストを実行することができます。
1094 1090
1095 ```dart 1091 ```dart
1096 class Controller extends GetxController { 1092 class Controller extends GetxController {
1097 @override 1093 @override
1098 void onInit() { 1094 void onInit() {
1099 super.onInit(); 1095 super.onInit();
1100 - //Change value to name2 1096 + // 値を name2 に変更
1101 name.value = 'name2'; 1097 name.value = 'name2';
1102 } 1098 }
1103 1099
@@ -1116,22 +1112,20 @@ void main() { @@ -1116,22 +1112,20 @@ void main() {
1116 test(''' 1112 test('''
1117 Test the state of the reactive variable "name" across all of its lifecycles''', 1113 Test the state of the reactive variable "name" across all of its lifecycles''',
1118 () { 1114 () {
1119 - /// You can test the controller without the lifecycle,  
1120 - /// but it's not recommended unless you're not using  
1121 - /// GetX dependency injection 1115 + /// ライフサイクルごとのテストは必ずしも行う必要はありませんが、
  1116 + /// GetXの依存オブジェクト注入機能を使用しているのであれば実行をおすすめします。
1122 final controller = Controller(); 1117 final controller = Controller();
1123 expect(controller.name.value, 'name1'); 1118 expect(controller.name.value, 'name1');
1124 1119
1125 - /// If you are using it, you can test everything,  
1126 - /// including the state of the application after each lifecycle.  
1127 - Get.put(controller); // onInit was called 1120 + /// このようにライフサイクル経過ごとの状態をテスト可能です。
  1121 + Get.put(controller); // onInit が実行される
1128 expect(controller.name.value, 'name2'); 1122 expect(controller.name.value, 'name2');
1129 1123
1130 - /// Test your functions 1124 + /// 関数もテストしましょう
1131 controller.changeName(); 1125 controller.changeName();
1132 expect(controller.name.value, 'name3'); 1126 expect(controller.name.value, 'name3');
1133 1127
1134 - /// onClose was called 1128 + /// onClose が実行される
1135 Get.delete<Controller>(); 1129 Get.delete<Controller>();
1136 1130
1137 expect(controller.name.value, ''); 1131 expect(controller.name.value, '');
@@ -1139,27 +1133,25 @@ Test the state of the reactive variable "name" across all of its lifecycles''', @@ -1139,27 +1133,25 @@ Test the state of the reactive variable "name" across all of its lifecycles''',
1139 } 1133 }
1140 ``` 1134 ```
1141 1135
1142 -#### Tips  
1143 -  
1144 -##### Mockito or mocktail  
1145 -If you need to mock your GetxController/GetxService, you should extend GetxController, and mixin it with Mock, that way 1136 +#### mockitoやmocktailを使う場合
  1137 +GetxController/GetxService をモックする場合 Mock をミックスインしてください。
1146 1138
1147 ```dart 1139 ```dart
1148 class NotificationServiceMock extends GetxService with Mock implements NotificationService {} 1140 class NotificationServiceMock extends GetxService with Mock implements NotificationService {}
1149 ``` 1141 ```
1150 1142
1151 -##### Using Get.reset()  
1152 -If you are testing widgets, or test groups, use Get.reset at the end of your test or in tearDown to reset all settings from your previous test. 1143 +#### Get.reset()
  1144 +WidgetやGroupのテスト時に、テストの最後かtearDownの中で Get.reset() を実行することで設定をリセットすることができます。
1153 1145
1154 -##### Get.testMode  
1155 -if you are using your navigation in your controllers, use `Get.testMode = true` at the beginning of your main. 1146 +#### Get.testMode
  1147 +Controllerの中でナビゲーションを使用している場合は、`Get.testMode = true`をmainの開始で実行してください。
1156 1148
1157 1149
1158 -# Breaking changes from 2.0 1150 +# バージョン2.0からの破壊的変更
1159 1151
1160 -1- Rx types: 1152 +1- Rx型の名称
1161 1153
1162 -| Before | After | 1154 +| 変更前 | 変更後 |
1163 | ------- | ---------- | 1155 | ------- | ---------- |
1164 | StringX | `RxString` | 1156 | StringX | `RxString` |
1165 | IntX | `RxInt` | 1157 | IntX | `RxInt` |
@@ -1168,10 +1160,10 @@ if you are using your navigation in your controllers, use `Get.testMode = true` @@ -1168,10 +1160,10 @@ if you are using your navigation in your controllers, use `Get.testMode = true`
1168 | NumX | `RxNum` | 1160 | NumX | `RxNum` |
1169 | DoubleX | `RxDouble` | 1161 | DoubleX | `RxDouble` |
1170 1162
1171 -RxController and GetBuilder now have merged, you no longer need to memorize which controller you want to use, just use GetxController, it will work for simple state management and for reactive as well. 1163 +RxControllerとGetBuilderが統合され、Controllerにどれを使うか覚えておく必要がなくなりました。GetxControllerを使うだけで、リアクティブと非リアクティブな状態管理の両方に対応できるようになりました。
1172 1164
1173 -2- NamedRoutes  
1174 -Before: 1165 +2- 名前付きRoute
  1166 +変更前:
1175 1167
1176 ```dart 1168 ```dart
1177 GetMaterialApp( 1169 GetMaterialApp(
@@ -1181,7 +1173,7 @@ GetMaterialApp( @@ -1181,7 +1173,7 @@ GetMaterialApp(
1181 ) 1173 )
1182 ``` 1174 ```
1183 1175
1184 -Now: 1176 +変更後:
1185 1177
1186 ```dart 1178 ```dart
1187 GetMaterialApp( 1179 GetMaterialApp(
@@ -1191,9 +1183,9 @@ GetMaterialApp( @@ -1191,9 +1183,9 @@ GetMaterialApp(
1191 ) 1183 )
1192 ``` 1184 ```
1193 1185
1194 -Why this change?  
1195 -Often, it may be necessary to decide which page will be displayed from a parameter, or a login token, the previous approach was inflexible, as it did not allow this.  
1196 -Inserting the page into a function has significantly reduced the RAM consumption, since the routes will not be allocated in memory since the app was started, and it also allowed to do this type of approach: 1186 +変更の効果:
  1187 +ページ表示にはパラメータやログイントークンを起点にする方法もありますが、以前のアプローチではこれができず、柔軟性に欠けていました。
  1188 +ページを関数から取得するよう変更したことで、このようなアプローチを可能にし、アプリ起動直後にRouteがメモリに割り当てられることもないため、RAMの消費量を大幅に削減することもできました。
1197 1189
1198 ```dart 1190 ```dart
1199 1191
@@ -1210,16 +1202,16 @@ GetMaterialApp( @@ -1210,16 +1202,16 @@ GetMaterialApp(
1210 1202
1211 # なぜGetXなのか 1203 # なぜGetXなのか
1212 1204
1213 -1- Flutterのアップデートが重なると、せっかく作ったパッケージがうまく動かなくなることがあります。コンパイルエラーを起こしたり、その時点で解決方法がないエラーが発生したり。開発者はそのエラーがどこから来たのか把握するために問題の追跡をし、該当リポジトリにissueを提起し、問題が解決されるのを見届ける必要があります。Getは開発に必要な主要リソース(状態管理、依存オブジェクトの管理、Route管理)を一元化し、Pubspecにパッケージを1つ追加するだけでコーディングを開始することができます。Flutterのアップデート後に必要なことは、Getも併せてアップデートすることだけです。それですぐに作業を再開できます。またGetはパッケージ間の互換性の問題も解消します。互いに依存するパッケージAの最新バージョンとBの最新バージョンの間に互換性がない、ということが何度あったでしょうか。Getを使えばすべてが同じパッケージ内にあるため、互換性の心配はありません。 1205 +1- Flutterのアップデートが重なると、依存パッケージがうまく動かなくなることがあります。コンパイルエラーを起こしたり、その時点で解決方法がないようなエラーが発生したり。開発者はそのエラーを追跡し、該当リポジトリにissueを提起し、問題が解決されるのを待つ必要があります。Getは開発に必要な主要リソース(状態管理、依存オブジェクト管理、Route管理)を一元化し、Pubspecにパッケージを1つ追加するだけでコーディングを開始することができます。Flutterがアップデートしたときに必要なことは、Getも併せてアップデートすることだけです。それですぐに作業を再開できます。またGetはパッケージ間の互換性の問題も解消します。互いに依存するパッケージAの最新バージョンとBの最新バージョンの間に互換性がない、ということが何度あったでしょうか。Getを使えばすべてが同じパッケージ内にあるため、互換性の心配はありません。
1214 1206
1215 -2- Flutterは手軽で素晴らしいフレームワークですが、`Navigator.of(context).push (context, builder [...]`のように、ほとんどの開発者にとって不要な定型文がまだ残っています。Getを使えばそのような定型文を簡素化できます。Routeを呼ぶためだけに8行のコードを書く代わりに、`Get.to(Home())`を実行すれば、次のページに行くことができるのです。またウェブURLを動的なものにするのは現在Flutterでは本当に骨の折れる作業ですが、GetXを使えば非常に簡単です。そしてFlutterにおける状態管理と依存オブジェクトの管理については、たくさんのパターンやパッケージがあるので多くの議論を生んでいます。しかしGetXのアプローチは大変簡単です。変数の最後に「.obs」を追加し、Obxクラスの中にWidgetを配置するだけで、その変数のすべての更新が自動的に画面に反映されます。 1207 +2- Flutterは手軽で素晴らしいフレームワークですが、`Navigator.of(context).push (context, builder [...]`のように、ほとんどの開発者にとって不要な定型文が一部にあります。Getを使えばそのような定型文を簡素化できます。Routeを呼ぶためだけに8行のコードを書く代わりに、`Get.to(Home())`を実行すれば、次の画面に遷移することができるのです。またウェブURLを動的なものにすることは現在Flutterでは本当に骨の折れる作業ですが、GetXを使えば非常に簡単です。そしてFlutterにおける状態管理と依存オブジェクト管理については、たくさんのパターンやパッケージがあるので多くの議論を生んでいます。しかしGetXのアプローチは大変シンプルです。これは一例ですが、変数の最後に「.obs」を追加して「Obx()」の中にWidgetを配置するだけで、その変数の状態変化が自動でWidgetに反映されます。
1216 1208
1217 -3- パフォーマンスのことを気にせず開発できます。Flutterのパフォーマンスはそれだけで素晴らしいものですが、アプリ内で状態管理と併せて、BLoC/store/controllerなどのクラスを配布するサービスロケーターを使用することを想像してみてください。そのインスタンスが必要ないときはリソースを解放するメソッドを明示的に呼び出さなければなりません。しかし、使用されなくなったら単純に自動でメモリから削除してくれればいいのに、と考えたことはありませんか?それを実現してくれるのがGetXです。SmartManagement機能により未使用リソースはすべてメモリから削除されるので、本来のプログラミングに集中することができます。メモリ管理のためのロジックを作らなくても、常に必要最小限のリソースを使っていることが保証されるのです。 1209 +3- GetXではパフォーマンスのことをあまり気にせず開発ができます。Flutterのパフォーマンスはそれだけで素晴らしいものですが、状態管理と併せて BLoC / データストア / Controller などを届けるためのサービスロケーターを使用することを想像してみてください。そのインスタンスが必要ないときはリソースを解放するイベントを明示的に呼び出さなければなりません。そんなとき、使用されなくなったら自動でメモリから削除してくれればいいのに、と考えたことはありませんか?それを実現してくれるのがGetXです。SmartManagement機能により未使用のリソースはすべて自動でメモリから破棄されるので、本来の開発作業に集中することができます。メモリ管理のためのロジックを作らなくても、常に必要最小限のリソースを使っていることが保証されるのです。
1218 1210
1219 -4- コードのデカップリング(分離)がしやすい。「Viewをビジネスロジックから分離する」というコンセプトを聞いたことがあるかもしれません。これはなにもBLoC、MVC、MVVMに限ったことではなく、どのアーキテクチャパターンにもこのコンセプトが底流にあると言っていいでしょう。しかし、Flutterではcontextの使用によりこのコンセプトが弱まってしまうことがあります。  
1220 -InheritedWidgetを参照するためにcontextが必要なとき、viewの中でそれを使用するか、パラメータとしてcontextを渡しますよね?私はこの方法は美しくないと感じます。特にチームで仕事をする場合において、常にView内のビジネスロジックに依存しなければならないなんて。GetXのアプローチは標準的なそれとは異質のもので、StatefulWidgetやinitStateなどの使用を禁止しているわけではありませんが、それよりもっとすっきり書ける類似のアプローチを備えています。controller自身にライフサイクルがあるため、たとえばREST APIのリクエストを行うときも、Viewの中の何かに依存するということがありません。controllerのライフサイクルの一つである onInit を使用してhttpを呼び出し、データが到着すると変数にセットされます。GetXはフルリアクティブなので(Streamが根底にあります)、インスタンス変数が値で埋まれば、その変数を使用するすべてのWidgetが自動的に更新されます。これにより、UIの専門家はWidgetの構築に注力することができ、ボタンクリックなどのユーザーイベント以外のものをビジネスロジックに渡す必要がなくなります。その一方で、ビジネスロジックを扱う人はビジネスロジックだけに集中して、個別テストを簡単に行うことができます。 1211 +4- コードのデカップリング(分離)がしやすい。「ビューをビジネスロジックから分離する」というコンセプトを聞いたことがあるかもしれません。これはなにもBLoC、MVC、MVVMに限ったことではなく、どのアーキテクチャパターンもこのコンセプトが考え方の基本にあると言っていいでしょう。しかし、Flutterではcontextの使用によりこのコンセプトが薄まってしまいがちです。
  1212 +InheritedWidgetを参照するためにcontextが必要なとき、ビューの中でそれを使用するか、引数としてcontextを渡しますよね?私はこの方法は美しくないと感じます。常にビュー内のビジネスロジックに依存しなければならないのは、特にチームで仕事をする場面においては不便だと感じます。GetXによるアプローチでは、StatefulWidgetやinitStateなどの使用を禁止しているわけではありませんが、それらよりもずっとスッキリ書けるようになっています。Controller自体にライフサイクルがあるため、たとえばREST APIのリクエストを行うときも、ビューの中の何かに依存するということがありません。Controllerのライフサイクルの一つである onInit を使用してhttpを呼び出し、データが到着すると変数にセットされます。GetXはリアクティブな変数を扱うことができるので、インスタンス変数が変わりし次第、その変数に依存するWidgetがすべて自動更新されます。これによりUIの担当者はWidgetの見た目に注力することができ、ボタンクリックなどのユーザーイベント以外のものをビジネスロジックに渡す必要がなくなります。その一方でビジネスロジックの担当者はビジネスロジックだけに集中し、個別のテストを簡単に行うことができます。
1221 1213
1222 -このGetXライブラリは今後も更新され続け、新しい機能を実装していきます。気軽にプルリクエストを出していただき、ライブラリの成長に貢献していただければ幸いです。 1214 +GetXライブラリは今後も更新され続け、新しい機能を実装していきます。気軽にプルリクエストを出していただき、ライブラリの成長に貢献していただけるとうれしいです。
1223 1215
1224 # コミュニティ 1216 # コミュニティ
1225 1217
@@ -1231,7 +1223,7 @@ GetX繧ウ繝溘Η繝九ユ繧」縺ッ髱槫クク縺ォ豢サ逋コ縺ァ譛臥寢縺ェ諠ア縺ァ縺ゅ繧後※縺∪ @@ -1231,7 +1223,7 @@ GetX繧ウ繝溘Η繝九ユ繧」縺ッ髱槫クク縺ォ豢サ逋コ縺ァ譛臥寢縺ェ諠ア縺ァ縺ゅ繧後※縺∪
1231 | :-------------------------------------------------------------------------------------------------------------------------- | :-------------------------------------------------------------------------------------------------------------------------- | :-------------------------------------------------------------------------------------------------------------------- | 1223 | :-------------------------------------------------------------------------------------------------------------------------- | :-------------------------------------------------------------------------------------------------------------------------- | :-------------------------------------------------------------------------------------------------------------------- |
1232 | [![Get on Slack](https://img.shields.io/badge/slack-join-orange.svg)](https://communityinviter.com/apps/getxworkspace/getx) | [![Discord Shield](https://img.shields.io/discord/722900883784073290.svg?logo=discord)](https://discord.com/invite/9Hpt99N) | [![Telegram](https://img.shields.io/badge/chat-on%20Telegram-blue.svg)](https://t.me/joinchat/PhdbJRmsZNpAqSLJL6bH7g) | 1224 | [![Get on Slack](https://img.shields.io/badge/slack-join-orange.svg)](https://communityinviter.com/apps/getxworkspace/getx) | [![Discord Shield](https://img.shields.io/discord/722900883784073290.svg?logo=discord)](https://discord.com/invite/9Hpt99N) | [![Telegram](https://img.shields.io/badge/chat-on%20Telegram-blue.svg)](https://t.me/joinchat/PhdbJRmsZNpAqSLJL6bH7g) |
1233 1225
1234 -## 貢献方法 1226 +## コントリビュート方法
1235 1227
1236 _GetXプロジェクトに貢献してみませんか?あなたをコントリビューターの一人としてご紹介できるのを楽しみにしています。GetおよびFlutterをより良いものにするためのコントリビュート例をご紹介します。_ 1228 _GetXプロジェクトに貢献してみませんか?あなたをコントリビューターの一人としてご紹介できるのを楽しみにしています。GetおよびFlutterをより良いものにするためのコントリビュート例をご紹介します。_
1237 1229
@@ -1241,9 +1233,9 @@ _GetX繝励Ο繧ク繧ァ繧ッ繝医↓雋「迪ョ縺励※縺ソ縺セ縺帙s縺具シ溘≠縺ェ縺溘r繧ウ繝ウ繝医Μ @@ -1241,9 +1233,9 @@ _GetX繝励Ο繧ク繧ァ繧ッ繝医↓雋「迪ョ縺励※縺ソ縺セ縺帙s縺具シ溘≠縺ェ縺溘r繧ウ繝ウ繝医Μ
1241 - コードやテストのプルリクエスト。 1233 - コードやテストのプルリクエスト。
1242 - 新機能の提案。 1234 - 新機能の提案。
1243 1235
1244 -どのような形の貢献であれ歓迎しますので、ぜひコミュニティにご参加ください! 1236 +どのような形の貢献であれ歓迎しますので、ぜひコミュニティにご参加ください!
1245 1237
1246 -## GetXに関する記事とビデオ 1238 +## GetXに関する記事と動画
1247 1239
1248 - [Flutter Getx EcoSystem package for arabic people](https://www.youtube.com/playlist?list=PLV1fXIAyjeuZ6M8m56zajMUwu4uE3-SL0) - Tutorial by [Pesa Coder](https://github.com/UsamaElgendy). 1240 - [Flutter Getx EcoSystem package for arabic people](https://www.youtube.com/playlist?list=PLV1fXIAyjeuZ6M8m56zajMUwu4uE3-SL0) - Tutorial by [Pesa Coder](https://github.com/UsamaElgendy).
1249 - [Dynamic Themes in 3 lines using GetX™](https://medium.com/swlh/flutter-dynamic-themes-in-3-lines-c3b375f292e3) - Tutorial by [Rod Brown](https://github.com/RodBr). 1241 - [Dynamic Themes in 3 lines using GetX™](https://medium.com/swlh/flutter-dynamic-themes-in-3-lines-c3b375f292e3) - Tutorial by [Rod Brown](https://github.com/RodBr).
1 -# Dependency Management  
2 -- [Dependency Management](#dependency-management)  
3 - - [Instancing methods](#instancing-methods) 1 +# 依存オブジェクト管理
  2 +- [依存オブジェクト管理](#依存オブジェクト管理)
  3 + - [インスタンス化に使用するメソッド](#インスタンス化に使用するメソッド)
4 - [Get.put()](#getput) 4 - [Get.put()](#getput)
5 - - [Get.lazyPut](#getlazyput)  
6 - - [Get.putAsync](#getputasync)  
7 - - [Get.create](#getcreate)  
8 - - [Using instantiated methods/classes](#using-instantiated-methodsclasses)  
9 - - [Specifying an alternate instance](#specifying-an-alternate-instance)  
10 - - [Differences between methods](#differences-between-methods)  
11 - - [Bindings](#bindings)  
12 - - [Bindings class](#bindings-class) 5 + - [Get.lazyPut()](#getlazyput)
  6 + - [Get.putAsync()](#getputasync)
  7 + - [Get.create()](#getcreate)
  8 + - [インスタンス化したクラスを使う](#インスタンス化したクラスを使う)
  9 + - [依存オブジェクトの置換](#依存オブジェクトの置換)
  10 + - [各メソッドの違い](#各メソッドの違い)
  11 + - [Bindings(Routeと依存オブジェクトの結束)](#Bindings(Routeと依存オブジェクトの結束))
  12 + - [Bindingsクラス](#bindingsクラス)
13 - [BindingsBuilder](#bindingsbuilder) 13 - [BindingsBuilder](#bindingsbuilder)
14 - [SmartManagement](#smartmanagement) 14 - [SmartManagement](#smartmanagement)
15 - - [How to change](#how-to-change) 15 + - [設定の変更方法](#設定の変更方法)
16 - [SmartManagement.full](#smartmanagementfull) 16 - [SmartManagement.full](#smartmanagementfull)
17 - [SmartManagement.onlyBuilders](#smartmanagementonlybuilders) 17 - [SmartManagement.onlyBuilders](#smartmanagementonlybuilders)
18 - [SmartManagement.keepFactory](#smartmanagementkeepfactory) 18 - [SmartManagement.keepFactory](#smartmanagementkeepfactory)
19 - - [How bindings work under the hood](#how-bindings-work-under-the-hood)  
20 - - [Notes](#notes) 19 + - [Bindingsの仕組み](#Bindingsの仕組み)
  20 + - [補足](#補足)
21 21
22 -Get has a simple and powerful dependency manager that allows you to retrieve the same class as your Bloc or Controller with just 1 lines of code, no Provider context, no inheritedWidget: 22 +Getにはシンプルで強力な依存オブジェクト管理機能があります。たった1行のコードで、Provider contextやinheritedWidgetを使うことなく、BlocもしくはControllerのインスタンスを取得することができます。
23 23
24 ```dart 24 ```dart
25 -Controller controller = Get.put(Controller()); // Rather Controller controller = Controller(); 25 +Controller controller = Get.put(Controller()); // Controller controller = Controller() の代わりに
26 ``` 26 ```
27 27
28 -Instead of instantiating your class within the class you are using, you are instantiating it within the Get instance, which will make it available throughout your App.  
29 -So you can use your controller (or Bloc class) normally 28 +UIクラスの中でControllerクラスをインスタンス化する代わりに、Getインスタンスの中でインスタンス化することで、アプリ全体でControllerを利用できるようになります。
30 29
31 -- Note: If you are using Get's State Manager, pay more attention to the [Bindings](#bindings) api, which will make easier to connect your view to your controller.  
32 -- Note²: Get dependency management is decloupled from other parts of the package, so if for example your app is already using a state manager (any one, it doesn't matter), you don't need to change that, you can use this dependency injection manager with no problems at all 30 +- 注: Getの状態管理機能を使用する場合は、[Bindings](#bindings)の使用も検討してください。Bindingsを使うことでビューにControllerを結合させることができます。
  31 +- 注²: Getの依存オブジェクト管理機能は、パッケージの他の部分から独立しています。そのため、たとえばあなたのアプリが既に他の状態管理ライブラリを使用している場合(どんなものでも)、何の問題もなく2つを組み合わせることができます。
33 32
34 -## Instancing methods  
35 -The methods and it's configurable parameters are: 33 +## インスタンス化に使用するメソッド
  34 +Controllerを初期化するのに使用するメソッドとその設定パラメーターについてご説明します。
36 35
37 ### Get.put() 36 ### Get.put()
38 37
39 -The most common way of inserting a dependency. Good for the controllers of your views for example. 38 +依存オブジェクトを注入するための最も基本のメソッド。たとえば、ビューで使用するControllerに使います。
40 39
41 ```dart 40 ```dart
42 Get.put<SomeClass>(SomeClass()); 41 Get.put<SomeClass>(SomeClass());
@@ -44,46 +43,45 @@ Get.put<LoginController>(LoginController(), permanent: true); @@ -44,46 +43,45 @@ Get.put<LoginController>(LoginController(), permanent: true);
44 Get.put<ListItemController>(ListItemController, tag: "some unique string"); 43 Get.put<ListItemController>(ListItemController, tag: "some unique string");
45 ``` 44 ```
46 45
47 -This is all options you can set when using put: 46 +以下が put() を使用する際に設定できるパラメーターです。
48 ```dart 47 ```dart
49 Get.put<S>( 48 Get.put<S>(
50 - // mandatory: the class that you want to get to save, like a controller or anything  
51 - // note: "S" means that it can be a class of any type 49 + // 必須。インスタンスを保存しておきたいControllerなどを設定
  50 + // 注: "S" 型はジェネリクスで、どんな型でもOK
52 S dependency 51 S dependency
53 52
54 - // optional: this is for when you want multiple classess that are of the same type  
55 - // since you normally get a class by using Get.find<Controller>(),  
56 - // you need to use tag to tell which instance you need  
57 - // must be unique string 53 + // オプション。これは同じ型のControllerインスタンスが複数存在する場合に、
  54 + // タグIDにより識別したい場合に使用します。
  55 + // Get.find<Controller>(tag: ) でこのputで設定したインスタンスを探します。
  56 + // tag はユニークなStringである必要があります。
58 String tag, 57 String tag,
59 58
60 - // optional: by default, get will dispose instances after they are not used anymore (example,  
61 - // the controller of a view that is closed), but you might need that the instance  
62 - // to be kept there throughout the entire app, like an instance of sharedPreferences or something  
63 - // so you use this  
64 - // defaults to false 59 + // オプション。デフォルトでは使用されなくなったインスタンスは破棄されますが、
  60 + // (たとえばビューが閉じられた場合など) SharedPreferencesのインスタンスなど、
  61 + // アプリ全体を通して生かしておきたい場合があるかと思います。
  62 + // その場合はこれをtrueにしてください。デフォルトはfalseです。
65 bool permanent = false, 63 bool permanent = false,
66 64
67 - // optional: allows you after using an abstract class in a test, replace it with another one and follow the test.  
68 - // defaults to false 65 + // オプション。テストで抽象クラスを使用した後、別クラスに置換してテストを追うことができます。
  66 + // デフォルトはfalseです。
69 bool overrideAbstract = false, 67 bool overrideAbstract = false,
70 68
71 - // optional: allows you to create the dependency using function instead of the dependency itself.  
72 - // this one is not commonly used 69 + // オプション: 依存オブジェクトを関数を使って作ることができます。
  70 + // 使用頻度は低いと思います。
73 InstanceBuilderCallback<S> builder, 71 InstanceBuilderCallback<S> builder,
74 ) 72 )
75 ``` 73 ```
76 74
77 -### Get.lazyPut  
78 -It is possible to lazyLoad a dependency so that it will be instantiated only when is used. Very useful for computational expensive classes or if you want to instantiate several classes in just one place (like in a Bindings class) and you know you will not gonna use that class at that time. 75 +### Get.lazyPut()
  76 +依存オブジェクトをすぐにロードする代わりに、lazy(遅延、消極的)ロードすることができます。実際に使用されるときに初めてインスタンス化されます。計算量の多いクラスや、Bindingsを使って複数のControllerをまとめてインスタンス化したいが、その時点ではすぐにそれらを使用しないことがわかっている場合などに非常に便利です。
79 77
80 ```dart 78 ```dart
81 -/// ApiMock will only be called when someone uses Get.find<ApiMock> for the first time 79 +/// この場合のApiMockは Get.find<ApiMock> を使用した時点でインスタンス化されます。
82 Get.lazyPut<ApiMock>(() => ApiMock()); 80 Get.lazyPut<ApiMock>(() => ApiMock());
83 81
84 Get.lazyPut<FirebaseAuth>( 82 Get.lazyPut<FirebaseAuth>(
85 () { 83 () {
86 - // ... some logic if needed 84 + // 必要ならここに何かのロジック
87 return FirebaseAuth(); 85 return FirebaseAuth();
88 }, 86 },
89 tag: Math.random().toString(), 87 tag: Math.random().toString(),
@@ -93,27 +91,27 @@ Get.lazyPut<FirebaseAuth>( @@ -93,27 +91,27 @@ Get.lazyPut<FirebaseAuth>(
93 Get.lazyPut<Controller>( () => Controller() ) 91 Get.lazyPut<Controller>( () => Controller() )
94 ``` 92 ```
95 93
96 -This is all options you can set when using lazyPut: 94 +これが .lazyPut で設定できるパラメーターです。
97 ```dart 95 ```dart
98 Get.lazyPut<S>( 96 Get.lazyPut<S>(
99 - // mandatory: a method that will be executed when your class is called for the first time 97 + // 必須。クラスSが初めてfindの対象になったときに実行されるメソッド
100 InstanceBuilderCallback builder, 98 InstanceBuilderCallback builder,
101 -  
102 - // optional: same as Get.put(), it is used for when you want multiple different instance of a same class  
103 - // must be unique 99 +
  100 + // オプション。Get.put()のtagと同様に同じクラスの異なるインスタンスが必要なときに使用
  101 + // ユニークな値を指定
104 String tag, 102 String tag,
105 103
106 - // optional: It is similar to "permanent", the difference is that the instance is discarded when  
107 - // is not being used, but when it's use is needed again, Get will recreate the instance  
108 - // just the same as "SmartManagement.keepFactory" in the bindings api  
109 - // defaults to false 104 + // オプション。"permanent" に似ていますが、使用されていないときはインスタンスが
  105 + // 破棄され、再び使用するときにGetがインスタンスを再び作成する点が異なります。
  106 + // Bindings APIの "SmartManagement.keepFactory " と同じです。
  107 + // デフォルトはfalse
110 bool fenix = false 108 bool fenix = false
111 - 109 +
112 ) 110 )
113 ``` 111 ```
114 112
115 -### Get.putAsync  
116 -If you want to register an asynchronous instance, you can use `Get.putAsync`: 113 +### Get.putAsync()
  114 +SharedPreferencesなど、非同期のインスタンスを登録したいときに使います。
117 115
118 ```dart 116 ```dart
119 Get.putAsync<SharedPreferences>(() async { 117 Get.putAsync<SharedPreferences>(() async {
@@ -125,87 +123,85 @@ Get.putAsync<SharedPreferences>(() async { @@ -125,87 +123,85 @@ Get.putAsync<SharedPreferences>(() async {
125 Get.putAsync<YourAsyncClass>( () async => await YourAsyncClass() ) 123 Get.putAsync<YourAsyncClass>( () async => await YourAsyncClass() )
126 ``` 124 ```
127 125
128 -This is all options you can set when using putAsync: 126 +これが .putAsync で設定できるパラメーターです。
129 ```dart 127 ```dart
130 Get.putAsync<S>( 128 Get.putAsync<S>(
131 129
132 - // mandatory: an async method that will be executed to instantiate your class 130 + // 必須。クラスをインスタンス化するための非同期メソッドを指定
133 AsyncInstanceBuilderCallback<S> builder, 131 AsyncInstanceBuilderCallback<S> builder,
134 132
135 - // optional: same as Get.put(), it is used for when you want multiple different instance of a same class  
136 - // must be unique 133 + // オプション。Get.put() と同じです。同じクラスの異なるインスタンスを作りたいときに使用
  134 + // ユニークな値を指定
137 String tag, 135 String tag,
138 136
139 - // optional: same as in Get.put(), used when you need to maintain that instance alive in the entire app  
140 - // defaults to false 137 + // オプション。Get.put() と同じです。アプリ全体を通して生かしておきたい場合に使用
  138 + // デフォルトはfalse
141 bool permanent = false 139 bool permanent = false
142 ) 140 )
143 ``` 141 ```
144 142
145 -### Get.create 143 +### Get.create()
146 144
147 -This one is tricky. A detailed explanation of what this is and the differences between the other one can be found on [Differences between methods:](#differences-between-methods) section 145 +これは使いどころに迷うかもしれません。他のものとの違いなど詳細な説明は「[各メソッドの違い](#各メソッドの違い)」のセクションをご一読ください。
148 146
149 ```dart 147 ```dart
150 Get.Create<SomeClass>(() => SomeClass()); 148 Get.Create<SomeClass>(() => SomeClass());
151 Get.Create<LoginController>(() => LoginController()); 149 Get.Create<LoginController>(() => LoginController());
152 ``` 150 ```
153 151
154 -This is all options you can set when using create: 152 +これが .create で設定できるパラメーターです。
155 153
156 ```dart 154 ```dart
157 Get.create<S>( 155 Get.create<S>(
158 - // required: a function that returns a class that will be "fabricated" every  
159 - // time `Get.find()` is called  
160 - // Example: Get.create<YourClass>(() => YourClass()) 156 + // 必須。Get.find() が呼ばれるたびにインスタンスがこの関数で新たに組み立てられる。
  157 + // 例: Get.create<YourClass>(() => YourClass())
161 FcBuilderFunc<S> builder, 158 FcBuilderFunc<S> builder,
162 159
163 - // optional: just like Get.put(), but it is used when you need multiple instances  
164 - // of a of a same class  
165 - // Useful in case you have a list that each item need it's own controller  
166 - // needs to be a unique string. Just change from tag to name 160 + // オプション。Get.put() のtagと同様で、同じクラスによる
  161 + // 複数インスタンスを扱うときに使用します。
  162 + // リストのアイテムにそれぞれコントローラが必要な場合に便利です。
  163 + // 文字列はユニークである必要があります。
167 String name, 164 String name,
168 165
169 - // optional: just like int`Get.put()`, it is for when you need to keep the  
170 - // instance alive thoughout the entire app. The difference is in Get.create  
171 - // permanent is true by default 166 + // オプション。Get.put() と同様アプリ全体でインスタンスを維持するときに使用。
  167 + // 唯一の違いは Get.create() のpermanentはデフォルトでtrueということだけです。
172 bool permanent = true 168 bool permanent = true
173 ``` 169 ```
174 170
175 -## Using instantiated methods/classes 171 +## インスタンス化したクラスを使う
176 172
177 -Imagine that you have navigated through numerous routes, and you need a data that was left behind in your controller, you would need a state manager combined with the Provider or Get_it, correct? Not with Get. You just need to ask Get to "find" for your controller, you don't need any additional dependencies: 173 +いくつかのRouteを渡り歩いた後、以前のControllerに残してきたデータが必要になったとしたら、Provider や Get_it と組み合わせる必要がありますよね?Getの場合は違います。GetにControllerの「検索」を依頼するだけで追加の依存オブジェクトの注入は必要ありません。
178 174
179 ```dart 175 ```dart
180 final controller = Get.find<Controller>(); 176 final controller = Get.find<Controller>();
181 -// OR 177 +// もしくは
182 Controller controller = Get.find(); 178 Controller controller = Get.find();
183 179
184 -// Yes, it looks like Magic, Get will find your controller, and will deliver it to you.  
185 -// You can have 1 million controllers instantiated, Get will always give you the right controller. 180 +// マジックみたいですよね。でも実際にGetはControllerのインスタンスを探して届けてくれます。
  181 +// 100万ものControllerをインスタンス化していても、Getは常に正しいControllerを探してくれます。
186 ``` 182 ```
187 183
188 -And then you will be able to recover your controller data that was obtained back there: 184 +そしてそのControllerが以前取得したデータをあなたは復元することができます。
189 185
190 ```dart 186 ```dart
191 Text(controller.textFromApi); 187 Text(controller.textFromApi);
192 ``` 188 ```
193 189
194 -Since the returned value is a normal class, you can do anything you want: 190 +戻り値は通常のクラスなので、そのクラスで可能なことは何でもできます。
195 ```dart 191 ```dart
196 int count = Get.find<SharedPreferences>().getInt('counter'); 192 int count = Get.find<SharedPreferences>().getInt('counter');
197 -print(count); // out: 12345 193 +print(count); // 出力: 12345
198 ``` 194 ```
199 195
200 -To remove an instance of Get: 196 +インスタンスを明示的に削除したい場合はこのようにしてください。
201 197
202 ```dart 198 ```dart
203 -Get.delete<Controller>(); //usually you don't need to do this because GetX already delete unused controllers 199 +Get.delete<Controller>(); // 通常であれば、GetXは未使用Controllerを自動削除するので、この作業は必要ありません。
204 ``` 200 ```
205 201
206 -## Specifying an alternate instance 202 +## 依存オブジェクトの置換
207 203
208 -A currently inserted instance can be replaced with a similar or extended class instance by using the `replace` or `lazyReplace` method. This can then be retrieved by using the original class. 204 +注入されている依存オブジェクトは `replace` または `lazyReplace` メソッドを使って、子クラスなど関連クラスのインスタンスに置き換えることができます。これは元の抽象クラスを型指定することで取得することができます。
209 205
210 ```dart 206 ```dart
211 abstract class BaseClass {} 207 abstract class BaseClass {}
@@ -234,44 +230,44 @@ print(instance is OtherClass); //true @@ -234,44 +230,44 @@ print(instance is OtherClass); //true
234 230
235 ## Differences between methods 231 ## Differences between methods
236 232
237 -First, let's of the `fenix` of Get.lazyPut and the `permanent` of the other methods. 233 +まずは Get.lazyPut の `fenix` プロパティと、他メソッドの `permanent` プロパティの違いについてご説明します。
238 234
239 -The fundamental difference between `permanent` and `fenix` is how you want to store your instances. 235 +`permanent` と `fenix` の根本的な違いは、インスタンスをどのように保持したいかという点に尽きます。
240 236
241 -Reinforcing: by default, GetX deletes instances when they are not in use.  
242 -It means that: If screen 1 has controller 1 and screen 2 has controller 2 and you remove the first route from stack, (like if you use `Get.off()` or `Get.offNamed()`) the controller 1 lost its use so it will be erased. 237 +しつこいようですが、GetXでは使われていないインスタンスは削除されるのがデフォルトの動作です。
  238 +これはもし画面AがController A、画面BがController Bを持っている場合において、画面Bに遷移するときに画面Aをスタックから削除した場合(`Get.off()` や `Get.offNamed()` を使うなどして)、Controller Aは消えてなくなるということです。
243 239
244 -But if you want to opt for using `permanent:true`, then the controller will not be lost in this transition - which is very useful for services that you want to keep alive throughout the entire application. 240 +しかし Get.put() する際に `permanent:true` としていれば、Controller Aはこの画面削除により失われることはありません。これはアプリケーション全体を通してControllerを残しておきたい場合に大変便利です。
245 241
246 -`fenix` in the other hand is for services that you don't worry in losing between screen changes, but when you need that service, you expect that it is alive. So basically, it will dispose the unused controller/service/class, but when you need it, it will "recreate from the ashes" a new instance. 242 +一方の `fenix` は、画面削除に伴っていったんはControllerが消去されますが、再び使いたいと思ったときに復活させることができます。つまり基本的には未使用の Controller / サービス / その他クラス は消去されますが、必要なときは新しいインスタンスを「燃えカス」から作り直すことができるのです。
247 243
248 -Proceeding with the differences between methods: 244 +各メソッドを使用する際のプロセスの違いをご説明します。
249 245
250 -- Get.put and Get.putAsync follows the same creation order, with the difference that the second uses an asynchronous method: those two methods creates and initializes the instance. That one is inserted directly in the memory, using the internal method `insert` with the parameters `permanent: false` and `isSingleton: true` (this isSingleton parameter only purpose is to tell if it is to use the dependency on `dependency` or if it is to use the dependency on `FcBuilderFunc`). After that, `Get.find()` is called that immediately initialize the instances that are on memory. 246 +- Get.put と Get.putAsync はインスタンスを作成して初期化するプロセスは同じですが、後者は非同期メソッドを使用するという違いがあります。この2つのメソッドは内部に保有するメソッド `insert` に `permanent: false` と `isSingleton: true` という引数を渡して、メモリに直接インスタンスを挿入します (この isSingleton が行っていることは、依存オブジェクトを `dependency` と `builder` プロパティのどちらから拝借するかを判断することだけです)。その後に `Get.find()` が呼ばれると、メモリ上にあるインスタンスを即座に初期化するというプロセスをたどります。
251 247
252 -- Get.create: As the name implies, it will "create" your dependency! Similar to `Get.put()`, it also calls the internal method `insert` to instancing. But `permanent` became true and `isSingleton` became false (since we are "creating" our dependency, there is no way for it to be a singleton instace, that's why is false). And because it has `permanent: true`, we have by default the benefit of not losing it between screens! Also, `Get.find()` is not called immediately, it wait to be used in the screen to be called. It is created this way to make use of the parameter `permanent`, since then, worth noticing, `Get.create()` was made with the goal of create not shared instances, but don't get disposed, like for example a button in a listView, that you want a unique instance for that list - because of that, Get.create must be used together with GetWidget. 248 +- Get.create はその名の通り、依存オブジェクトを「クリエイト」します。Get.put() と同様に内部メソッドである `insert` を呼び出してインスタンス化します。違いは `permanent: true` で `isSingleton: false` である点です (依存オブジェクトを「クリエイト」しているため、シングルトンにはなりません。それが false になっている理由です)。また `permanent: true` となっているので、デフォルトでは画面の破棄などでインスタンスを失わないというメリットがあります。また `Get.find()` はすぐに呼ばれず、画面内で実際に使用されてから呼ばれます。これは `permanent` の特性を活かすための設計ですが、それゆえ `Get.create()` は共有しないけど破棄もされないインスタンスを作成する目的で作られたと言えます。たとえば、ListViewの中のボタンアイテムに使うControllerインスタンスのように、そのリスト内でしか使わないけどリストアイテムごとに固有のインスタンスが必要なケースなどが考えられます。そのため、Get.create は GetWidget との併用がマストです。
253 249
254 -- Get.lazyPut: As the name implies, it is a lazy proccess. The instance is create, but it is not called to be used immediately, it remains waiting to be called. Contrary to the other methods, `insert` is not called here. Instead, the instance is inserted in another part of the memory, a part responsible to tell if the instance can be recreated or not, let's call it "factory". If we want to create something to be used later, it will not be mix with things been used right now. And here is where `fenix` magic enters: if you opt to leaving `fenix: false`, and your `smartManagement` are not `keepFactory`, then when using `Get.find` the instance will change the place in the memory from the "factory" to common instance memory area. Right after that, by default it is removed from the "factory". Now, if you opt for `fenix: true`, the instance continues to exist in this dedicated part, even going to the common area, to be called again in the future. 250 +- Get.lazyPut は初期化をlazy(遅延、消極的)に行います。実行されるとインスタンスは作成されますが、すぐに使用できるように初期化はされず、待機状態になります。また他のメソッドと異なり `insert` メソッドは呼び出されません。その代わり、インスタンスはメモリの別の部分に挿入されます。この部分を「ファクトリー」と呼ぶことにしましょう。「ファクトリー」は、そのインスタンスが再生成できるかどうかを決める役割を持っています。これは後で使う予定のものを、現在進行形で使われているものと混ざらないようにするための工夫です。ここで `fenix` によるマジックが登場します。デフォルトの `fenix: false` のままにしており、かつ `SmartManagement` が `keepFactory` ではない場合において `Get.find` を使用すると、インスタンスは「ファクトリー」から共有メモリ領域に移動します。その直後にインスタンスは「ファクトリー」から削除されます。しかし `fenix: true` としていた場合、インスタンスは「ファクトリー」に残るため、共有メモリ領域から削除されても再び呼び出すことができるのです。
255 251
256 -## Bindings 252 +## Bindings(Routeと依存オブジェクトの結束)
257 253
258 -One of the great differentials of this package, perhaps, is the possibility of full integration of the routes, state manager and dependency manager.  
259 -When a route is removed from the Stack, all controllers, variables, and instances of objects related to it are removed from memory. If you are using streams or timers, they will be closed automatically, and you don't have to worry about any of that.  
260 -In version 2.10 Get completely implemented the Bindings API.  
261 -Now you no longer need to use the init method. You don't even have to type your controllers if you don't want to. You can start your controllers and services in the appropriate place for that.  
262 -The Binding class is a class that will decouple dependency injection, while "binding" routes to the state manager and dependency manager.  
263 -This allows Get to know which screen is being displayed when a particular controller is used and to know where and how to dispose of it.  
264 -In addition, the Binding class will allow you to have SmartManager configuration control. You can configure the dependencies to be arranged when removing a route from the stack, or when the widget that used it is laid out, or neither. You will have intelligent dependency management working for you, but even so, you can configure it as you wish. 254 +このパッケージの一番の差別化要素は、Route管理 / 状態管理 / 依存オブジェクト管理 を統合したことにあると思っています。
  255 +スタックからRouteが削除されれば、関係するController、変数、オブジェクトのインスタンスがすべてメモリから削除されます。たとえばStreamやTimerを使用している場合も同様ですので、開発者は何も心配する必要はありません。
  256 +Getはバージョン2.10からBindings APIをフル実装しました。
  257 +Bindingsを使用すれば init でControllerを起動する必要はありません。またControllerの型を指定する必要もありません。Controllerやサービスは各々適切な場所で起動することができるようになりました。
  258 +Bindingsは依存オブジェクトの注入をビューから切り離すことができるクラスです。それに加え、状態と依存オブジェクトの管理機能をRouteに「結束(bind)」してくれます。
  259 +これによりGetは、あるControllerが使用されたときにどの画面UIが表示されているかを知ることができます。つまり、そのControllerをどのタイミングでどう処分するかを判断することができるということです。
  260 +さらにBindingsでは SmartManager の制御により、依存オブジェクトをどのタイミング(スタックからRouteを削除したときか、それに依存するWidgetを表示したときか、いずれでもないか)で整理するかを設定することができます。インテリジェントな依存オブジェクトの自動管理機能を持ちつつ、自分の好きなように設定できるのです。
265 261
266 -### Bindings class 262 +### Bindingsクラス
267 263
268 -- Create a class and implements Binding 264 +- Bindings機能を実装したクラスを作成することができます。
269 265
270 ```dart 266 ```dart
271 class HomeBinding implements Bindings {} 267 class HomeBinding implements Bindings {}
272 ``` 268 ```
273 269
274 -Your IDE will automatically ask you to override the "dependencies" method, and you just need to click on the lamp, override the method, and insert all the classes you are going to use on that route: 270 +"dependencies" メソッドをオーバーライドするようIDEに自動で指摘されます。表示をクリックしてメソッドを override し、そのRoute内で使用するすべてのクラスを挿入してください。
275 271
276 ```dart 272 ```dart
277 class HomeBinding implements Bindings { 273 class HomeBinding implements Bindings {
@@ -290,9 +286,9 @@ class DetailsBinding implements Bindings { @@ -290,9 +286,9 @@ class DetailsBinding implements Bindings {
290 } 286 }
291 ``` 287 ```
292 288
293 -Now you just need to inform your route, that you will use that binding to make the connection between route manager, dependencies and states. 289 +Bindingsを設定したら、このクラスが Route管理 / 依存オブジェクト管理 / 状態管理 を互いに接続する目的で使用されるものだということをRouteに知らせてあげます。
294 290
295 -- Using named routes: 291 +- 名前付きRouteを使う場合
296 292
297 ```dart 293 ```dart
298 getPages: [ 294 getPages: [
@@ -309,16 +305,16 @@ getPages: [ @@ -309,16 +305,16 @@ getPages: [
309 ]; 305 ];
310 ``` 306 ```
311 307
312 -- Using normal routes: 308 +- 通常のRouteを使う場合
313 309
314 ```dart 310 ```dart
315 Get.to(Home(), binding: HomeBinding()); 311 Get.to(Home(), binding: HomeBinding());
316 Get.to(DetailsView(), binding: DetailsBinding()) 312 Get.to(DetailsView(), binding: DetailsBinding())
317 ``` 313 ```
318 314
319 -There, you don't have to worry about memory management of your application anymore, Get will do it for you. 315 +これでアプリケーションのメモリ管理を気にする必要がなくなります。Getがすべてやってくれます。
320 316
321 -The Binding class is called when a route is called, you can create an "initialBinding in your GetMaterialApp to insert all the dependencies that will be created. 317 +BindingsクラスはRouteの呼び出しと同時に呼び出されます。また、すべてに共通の依存オブジェクトを挿入するためには GetMaterialApp の initialBinding プロパティを使用してください。
322 318
323 ```dart 319 ```dart
324 GetMaterialApp( 320 GetMaterialApp(
@@ -329,8 +325,7 @@ GetMaterialApp( @@ -329,8 +325,7 @@ GetMaterialApp(
329 325
330 ### BindingsBuilder 326 ### BindingsBuilder
331 327
332 -The default way of creating a binding is by creating a class that implements Bindings.  
333 -But alternatively, you can use `BindingsBuilder` callback so that you can simply use a function to instantiate whatever you desire. 328 +Bindingsを作成する一般的な方法は Bindings を実装したクラスを作成することですが、`BindingsBuilder` コールバックを使う方法もあります。
334 329
335 Example: 330 Example:
336 331
@@ -354,25 +349,25 @@ getPages: [ @@ -354,25 +349,25 @@ getPages: [
354 ]; 349 ];
355 ``` 350 ```
356 351
357 -That way you can avoid to create one Binding class for each route making this even simpler. 352 +この方法ならRouteごとにBindingsクラスを作る必要はありません。
358 353
359 -Both ways of doing work perfectly fine and we want you to use what most suit your tastes. 354 +どちらの方法でも効果は変わりませんのでお好みの方法を使ってください。
360 355
361 ### SmartManagement 356 ### SmartManagement
362 357
363 -GetX by default disposes unused controllers from memory, even if a failure occurs and a widget that uses it is not properly disposed.  
364 -This is what is called the `full` mode of dependency management.  
365 -But if you want to change the way GetX controls the disposal of classes, you have `SmartManagement` class that you can set different behaviors. 358 +エラーが発生してControllerを使用するWidgetが正しく破棄されなかった場合でも、Controllerが未使用になればGetXはデフォルトの動作通りそれをメモリから削除します。
  359 +これがいわゆる依存オブジェクト管理機能の `full` モードと呼ばれるものです。
  360 +しかしもしGetXによるオブジェクト破棄の方法をコントロールしたい場合は、`SmartManagement`クラスを使って設定してください。
366 361
367 -#### How to change 362 +#### 設定の変更方法
368 363
369 -If you want to change this config (which you usually don't need) this is the way: 364 +この設定は通常変更する必要はありませんが、変更されたい場合はこのようにしてください。
370 365
371 ```dart 366 ```dart
372 void main () { 367 void main () {
373 runApp( 368 runApp(
374 GetMaterialApp( 369 GetMaterialApp(
375 - smartManagement: SmartManagement.onlyBuilders //here 370 + smartManagement: SmartManagement.onlyBuilders // ここで設定
376 home: Home(), 371 home: Home(),
377 ) 372 )
378 ) 373 )
@@ -381,30 +376,30 @@ void main () { @@ -381,30 +376,30 @@ void main () {
381 376
382 #### SmartManagement.full 377 #### SmartManagement.full
383 378
384 -It is the default one. Dispose classes that are not being used and were not set to be permanent. In the majority of the cases you will want to keep this config untouched. If you new to GetX then don't change this. 379 +これがデフォルトのモードです。使用されていない、かつ `permanent: true` が設定されていないオブジェクトを自動で破棄してくれます。特殊な事情がない限り、この設定は触らない方がいいでしょう。GetXを使って間がない場合は特に。
385 380
386 #### SmartManagement.onlyBuilders 381 #### SmartManagement.onlyBuilders
387 -With this option, only controllers started in `init:` or loaded into a Binding with `Get.lazyPut()` will be disposed. 382 +`init:` もしくはBindings内で `Get.lazyPut()` により設定したビルダー製のオブジェクトだけを破棄するモードです。
388 383
389 -If you use `Get.put()` or `Get.putAsync()` or any other approach, SmartManagement will not have permissions to exclude this dependency. 384 +もしそれが `Get.put()` や `Get.putAsync()` などのアプローチで生成したオブジェクトだとしたら、SmartManagement は勝手にメモリから除外することはできません。
390 385
391 -With the default behavior, even widgets instantiated with "Get.put" will be removed, unlike SmartManagement.onlyBuilders. 386 +それに対してデフォルトのモードでは `Get.put()` で生成したオブジェクトも破棄します。
392 387
393 #### SmartManagement.keepFactory 388 #### SmartManagement.keepFactory
394 389
395 -Just like SmartManagement.full, it will remove it's dependencies when it's not being used anymore. However, it will keep their factory, which means it will recreate the dependency if you need that instance again. 390 +SmartManagement.full と同じように、オブジェクトが使用されていない状態になれば破棄します。ただし、前述の「ファクトリー」に存在するものだけは残します。つまりそのインスタンスが再び必要になった際は依存オブジェクトを再度生成するということです。
396 391
397 -### How bindings work under the hood  
398 -Bindings creates transitory factories, which are created the moment you click to go to another screen, and will be destroyed as soon as the screen-changing animation happens.  
399 -This happens so fast that the analyzer will not even be able to register it.  
400 -When you navigate to this screen again, a new temporary factory will be called, so this is preferable to using SmartManagement.keepFactory, but if you don't want to create Bindings, or want to keep all your dependencies on the same Binding, it will certainly help you.  
401 -Factories take up little memory, they don't hold instances, but a function with the "shape" of that class you want.  
402 -This has a very low cost in memory, but since the purpose of this lib is to get the maximum performance possible using the minimum resources, Get removes even the factories by default.  
403 -Use whichever is most convenient for you. 392 +### Bindingsの仕組み
  393 +Bindingsは「一過性のファクトリー」のようなものを作成します。これはそのRouteに画面遷移した瞬間に作成され、そこから画面移動するアニメーションが発生した瞬間に破棄されます。
  394 +この動作は非常に高速で行われるので、アナライザーでは捕捉できないほどです。
  395 +再び元の画面に戻ると新しい「一過性のファクトリー」が呼び出されます。そのためこれは SmartManagement.keepFactory を使用するよりも多くの場合好ましいですが、Bindingsを作成したくない場合やすべての依存オブジェクトを同じBindingsに持っておきたい場合は SmartManagement.keepFactory を使うといいでしょう。
  396 +ファクトリーのメモリ使用量は少なく、インスタンスを保持することはありません。その代わりにそのクラスのインスタンスを形作る関数を保持します。
  397 +メモリコストは非常に低いのですが、最小リソースで最大パフォーマンスを得ることが目的のGetではデフォルトでファクトリーを削除します。
  398 +どちらか都合に合う方ををお使いいただければと思います。
404 399
405 -## Notes 400 +## 補足
406 401
407 -- DO NOT USE SmartManagement.keepFactory if you are using multiple Bindings. It was designed to be used without Bindings, or with a single Binding linked in the GetMaterialApp's initialBinding. 402 +- 複数のBindingsを使う場合は SmartManagement.keepFactory は**使わない**でください。これは Bindings を使わないケースや、GetMaterialAppのinitialBindingに設定された単独のBindingと一緒に使うケースを想定されて作られました。
408 403
409 -- Using Bindings is completely optional, if you want you can use `Get.put()` and `Get.find()` on classes that use a given controller without any problem.  
410 -However, if you work with Services or any other abstraction, I recommend using Bindings for a better organization. 404 +- Bindingsを使うことは必須ではありません。`Get.put()` と `Get.find()` だけでも全く問題ありません。
  405 +ただし、サービスやその他抽象度の高いクラスをアプリに取り入れる場合はコード整理のために使うことをおすすめします。
1 -- [Route Management](#route-management)  
2 - - [How to use](#how-to-use)  
3 - - [Navigation without named routes](#navigation-without-named-routes)  
4 - - [Navigation with named routes](#navigation-with-named-routes)  
5 - - [Send data to named Routes](#send-data-to-named-routes)  
6 - - [Dynamic urls links](#dynamic-urls-links)  
7 - - [Middleware](#middleware)  
8 - - [Navigation without context](#navigation-without-context)  
9 - - [SnackBars](#snackbars)  
10 - - [Dialogs](#dialogs)  
11 - - [BottomSheets](#bottomsheets)  
12 - - [Nested Navigation](#nested-navigation)  
13 -  
14 -# Route Management  
15 -  
16 -This is the complete explanation of all there is to Getx when the matter is route management. 1 +- [Route管理](#Route管理)
  2 + - [使い方](#使い方)
  3 + - [通常Routeによるナビゲーション](#通常Routeによるナビゲーション)
  4 + - [名前付きRouteによるナビゲーション](#名前付きRouteによるナビゲーション)
  5 + - [名前付きRouteにデータを送る](#名前付きRouteにデータを送る)
  6 + - [動的URLの生成](#動的URLの生成)
  7 + - [ミドルウェアの使用](#ミドルウェアの使用)
  8 + - [contextを使わないナビゲーション](#contextを使わないナビゲーション)
  9 + - [SnackBar](#snackbar)
  10 + - [Dialog](#dialog)
  11 + - [BottomSheet](#bottomsheet)
  12 + - [ネスト構造のナビゲーション](#ネスト構造のナビゲーション)
  13 +
  14 +# Route管理
  15 +
  16 +このドキュメントではGetXにおけるRoute管理のすべてをご説明します。
17 17
18 ## How to use 18 ## How to use
19 19
20 -Add this to your pubspec.yaml file: 20 +次の3文字を pubspec.yaml ファイルに追加してください。
21 21
22 ```yaml 22 ```yaml
23 dependencies: 23 dependencies:
24 get: 24 get:
25 ``` 25 ```
26 26
27 -If you are going to use routes/snackbars/dialogs/bottomsheets without context, or use the high-level Get APIs, you need to simply add "Get" before your MaterialApp, turning it into GetMaterialApp and enjoy! 27 +Route / SnackBar / Dialog / BottomSheet をcontextなしで、あるいは高レベルのGet APIを使用するには MaterialApp の前に「Get」を追加してください。それだけで GetMaterialApp の機能が使用できます。
28 28
29 ```dart 29 ```dart
30 -GetMaterialApp( // Before: MaterialApp( 30 +GetMaterialApp( // 変更前: MaterialApp(
31 home: MyHome(), 31 home: MyHome(),
32 ) 32 )
33 ``` 33 ```
34 34
35 -## Navigation without named routes 35 +## 名前付きRouteによる画面遷移
36 36
37 -To navigate to a new screen: 37 +次の画面に遷移するには Get.to を使ってください。
38 38
39 ```dart 39 ```dart
40 Get.to(NextScreen()); 40 Get.to(NextScreen());
41 ``` 41 ```
42 42
43 -To close snackbars, dialogs, bottomsheets, or anything you would normally close with Navigator.pop(context); 43 +SnackBar / Dialog / BottomSheet など Navigator.pop(context) で閉じるものと同じものを閉じるには Get.back を使います。
44 44
45 ```dart 45 ```dart
46 Get.back(); 46 Get.back();
47 ``` 47 ```
48 48
49 -To go to the next screen and no option to go back to the previous screen (for use in SplashScreens, login screens and etc.) 49 +次の画面に遷移しつつ、前の画面に戻れないようにするには Get.off を使います(スプラッシュスクリーンやログイン画面などで使用)。
50 50
51 ```dart 51 ```dart
52 Get.off(NextScreen()); 52 Get.off(NextScreen());
53 ``` 53 ```
54 54
55 -To go to the next screen and cancel all previous routes (useful in shopping carts, polls, and tests) 55 +次の画面に遷移して、それ以前のRouteはすべて破棄するには Get.offAll を使います(ショッピングカート、投票、テストなどで使用)
56 56
57 ```dart 57 ```dart
58 Get.offAll(NextScreen()); 58 Get.offAll(NextScreen());
59 ``` 59 ```
60 60
61 -To navigate to the next route, and receive or update data as soon as you return from it: 61 +次の画面に遷移して、戻ったらデータを受け取る方法はこちら。
62 62
63 ```dart 63 ```dart
64 var data = await Get.to(Payment()); 64 var data = await Get.to(Payment());
65 ``` 65 ```
66 66
67 -on other screen, send a data for previous route: 67 +次の画面では、このようにデータを前の画面に送る必要があります。
68 68
69 ```dart 69 ```dart
70 Get.back(result: 'success'); 70 Get.back(result: 'success');
71 ``` 71 ```
72 72
73 -And use it: 73 +そして使いましょう。
74 74
75 ex: 75 ex:
76 76
@@ -78,13 +78,12 @@ ex: @@ -78,13 +78,12 @@ ex:
78 if(data == 'success') madeAnything(); 78 if(data == 'success') madeAnything();
79 ``` 79 ```
80 80
81 -Don't you want to learn our syntax?  
82 -Just change the Navigator (uppercase) to navigator (lowercase), and you will have all the functions of the standard navigation, without having to use context  
83 -Example: 81 +どのようなシンタックスがあるかもっと知りたいですか?
  82 +いつもの Navigator ではなく navigator と入れてみてください。通常のNavigatorで使えるプロパティがcontextなしで使えるようになっているかと思います。
84 83
85 ```dart 84 ```dart
86 85
87 -// Default Flutter navigator 86 +// 通常のFlutterによるNavigator
88 Navigator.of(context).push( 87 Navigator.of(context).push(
89 context, 88 context,
90 MaterialPageRoute( 89 MaterialPageRoute(
@@ -94,7 +93,7 @@ Navigator.of(context).push( @@ -94,7 +93,7 @@ Navigator.of(context).push(
94 ), 93 ),
95 ); 94 );
96 95
97 -// Get using Flutter syntax without needing context 96 +// GetではFlutterのシンタックスをcontextなしで使えます
98 navigator.push( 97 navigator.push(
99 MaterialPageRoute( 98 MaterialPageRoute(
100 builder: (_) { 99 builder: (_) {
@@ -103,35 +102,35 @@ navigator.push( @@ -103,35 +102,35 @@ navigator.push(
103 ), 102 ),
104 ); 103 );
105 104
106 -// Get syntax (It is much better, but you have the right to disagree) 105 +// Getのシンタックス(上記よりかなり短いですね)
107 Get.to(HomePage()); 106 Get.to(HomePage());
108 107
109 108
110 ``` 109 ```
111 110
112 -## Navigation with named routes 111 +## 名前付きRouteによる画面遷移
113 112
114 -- If you prefer to navigate by namedRoutes, Get also supports this. 113 +- Getは名前付きRouteによる遷移もサポートしています。
115 114
116 -To navigate to nextScreen 115 +次の画面への遷移はこう。
117 116
118 ```dart 117 ```dart
119 Get.toNamed("/NextScreen"); 118 Get.toNamed("/NextScreen");
120 ``` 119 ```
121 120
122 -To navigate and remove the previous screen from the tree. 121 +Get.off の名前付きRoute版。
123 122
124 ```dart 123 ```dart
125 Get.offNamed("/NextScreen"); 124 Get.offNamed("/NextScreen");
126 ``` 125 ```
127 126
128 -To navigate and remove all previous screens from the tree. 127 +Get.offAll の名前付きRoute版。
129 128
130 ```dart 129 ```dart
131 Get.offAllNamed("/NextScreen"); 130 Get.offAllNamed("/NextScreen");
132 ``` 131 ```
133 132
134 -To define routes, use GetMaterialApp: 133 +Routeを定義するにはGetMaterialAppを使ってください。
135 134
136 ```dart 135 ```dart
137 void main() { 136 void main() {
@@ -144,7 +143,7 @@ void main() { @@ -144,7 +143,7 @@ void main() {
144 GetPage( 143 GetPage(
145 name: '/third', 144 name: '/third',
146 page: () => Third(), 145 page: () => Third(),
147 - transition: Transition.zoom 146 + transition: Transition.zoom
148 ), 147 ),
149 ], 148 ],
150 ) 149 )
@@ -152,7 +151,7 @@ void main() { @@ -152,7 +151,7 @@ void main() {
152 } 151 }
153 ``` 152 ```
154 153
155 -To handle navigation to non-defined routes (404 error), you can define an unknownRoute page in GetMaterialApp. 154 +未定義Route(404エラー)に遷移させるには、GetMaterialAppで unknownRoute を設定してください。
156 155
157 ```dart 156 ```dart
158 void main() { 157 void main() {
@@ -169,39 +168,39 @@ void main() { @@ -169,39 +168,39 @@ void main() {
169 } 168 }
170 ``` 169 ```
171 170
172 -### Send data to named Routes 171 +### 名前付きRouteにデータを送る
173 172
174 -Just send what you want for arguments. Get accepts anything here, whether it is a String, a Map, a List, or even a class instance. 173 +次の画面に渡すデータは arguments で引数を設定します。Getでは引数にどんなものでも指定できます。StringでもMapでもListでも、クラスのインスタンスでも大丈夫です。
175 174
176 ```dart 175 ```dart
177 Get.toNamed("/NextScreen", arguments: 'Get is the best'); 176 Get.toNamed("/NextScreen", arguments: 'Get is the best');
178 ``` 177 ```
179 178
180 -on your class or controller: 179 +ビュー側のクラスやControllerで値を使うにはこうしてください。
181 180
182 ```dart 181 ```dart
183 print(Get.arguments); 182 print(Get.arguments);
184 -//print out: Get is the best 183 +// Get is the best が表示される
185 ``` 184 ```
186 185
187 -### Dynamic urls links 186 +### 動的URLの生成
188 187
189 -Get offer advanced dynamic urls just like on the Web. Web developers have probably already wanted this feature on Flutter, and most likely have seen a package promise this feature and deliver a totally different syntax than a URL would have on web, but Get also solves that. 188 +Getはウェブのような高度な動的URLを提供します。ウェブ開発者はFlutterにこの機能が提供されることを待ち望んでいたことでしょう。この機能の提供を謳うパッケージは存在しますが、ウェブ上のURLとは全く異なるシンタックスが表示されているのを見たことがあるかもしれません。Getはこの点も解決します。
190 189
191 ```dart 190 ```dart
192 Get.offAllNamed("/NextScreen?device=phone&id=354&name=Enzo"); 191 Get.offAllNamed("/NextScreen?device=phone&id=354&name=Enzo");
193 ``` 192 ```
194 193
195 -on your controller/bloc/stateful/stateless class: 194 +ビュー側のクラスやControllerで値を使う方法。
196 195
197 ```dart 196 ```dart
198 print(Get.parameters['id']); 197 print(Get.parameters['id']);
199 -// out: 354 198 +// 出力: 354
200 print(Get.parameters['name']); 199 print(Get.parameters['name']);
201 -// out: Enzo 200 +// 出力: Enzo
202 ``` 201 ```
203 202
204 -You can also receive NamedParameters with Get easily: 203 +この名前付きパラメーターはこのように簡単に受け取ることもできます。
205 204
206 ```dart 205 ```dart
207 void main() { 206 void main() {
@@ -217,7 +216,8 @@ void main() { @@ -217,7 +216,8 @@ void main() {
217 name: '/profile/', 216 name: '/profile/',
218 page: () => MyProfile(), 217 page: () => MyProfile(),
219 ), 218 ),
220 - //You can define a different page for routes with arguments, and another without arguments, but for that you must use the slash '/' on the route that will not receive arguments as above. 219 + // 引数userを使う場合と使わない場合で別ページを定義することが可能です。
  220 + // ただ、そのためにはスラッシュ '/' をベースのRoute名の後に入れる必要があります。
221 GetPage( 221 GetPage(
222 name: '/profile/:user', 222 name: '/profile/:user',
223 page: () => UserProfile(), 223 page: () => UserProfile(),
@@ -225,7 +225,7 @@ void main() { @@ -225,7 +225,7 @@ void main() {
225 GetPage( 225 GetPage(
226 name: '/third', 226 name: '/third',
227 page: () => Third(), 227 page: () => Third(),
228 - transition: Transition.cupertino 228 + transition: Transition.cupertino
229 ), 229 ),
230 ], 230 ],
231 ) 231 )
@@ -233,46 +233,46 @@ void main() { @@ -233,46 +233,46 @@ void main() {
233 } 233 }
234 ``` 234 ```
235 235
236 -Send data on route name 236 +Route名を使ってデータを送る方法。
237 237
238 ```dart 238 ```dart
239 Get.toNamed("/profile/34954"); 239 Get.toNamed("/profile/34954");
240 ``` 240 ```
241 241
242 -On second screen take the data by parameter 242 +次の画面でデータを受け取る方法。
243 243
244 ```dart 244 ```dart
245 print(Get.parameters['user']); 245 print(Get.parameters['user']);
246 // out: 34954 246 // out: 34954
247 ``` 247 ```
248 248
249 -or send multiple parameters like this 249 +複数のパラメーターを送信するにはこちら。
250 250
251 ```dart 251 ```dart
252 Get.toNamed("/profile/34954?flag=true&country=italy"); 252 Get.toNamed("/profile/34954?flag=true&country=italy");
253 ``` 253 ```
254 -or 254 +もしくは
255 ```dart 255 ```dart
256 var parameters = <String, String>{"flag": "true","country": "italy",}; 256 var parameters = <String, String>{"flag": "true","country": "italy",};
257 Get.toNamed("/profile/34954", parameters: parameters); 257 Get.toNamed("/profile/34954", parameters: parameters);
258 ``` 258 ```
259 259
260 -On second screen take the data by parameters as usually 260 +次の画面でデータを受け取る方法。
261 261
262 ```dart 262 ```dart
263 print(Get.parameters['user']); 263 print(Get.parameters['user']);
264 print(Get.parameters['flag']); 264 print(Get.parameters['flag']);
265 print(Get.parameters['country']); 265 print(Get.parameters['country']);
266 -// out: 34954 true italy 266 +// 出力: 34954 true italy
267 ``` 267 ```
268 268
269 269
270 270
271 -And now, all you need to do is use Get.toNamed() to navigate your named routes, without any context (you can call your routes directly from your BLoC or Controller class), and when your app is compiled to the web, your routes will appear in the url <3 271 +あとは Get.toNamed() を使い、名前付きRouteを指定するだけです(contextを使わないので BLoC や Controller から直接Routeを呼び出すことができます)。ウェブアプリとしてコンパイルされると、Routeが正しくURLに表示されます。
272 272
273 -### Middleware 273 +### ミドルウェアの使用
274 274
275 -If you want to listen Get events to trigger actions, you can to use routingCallback to it 275 +何かのアクションのトリガーとなるイベントを取得したい場合は、routingCallbackを使用してください。
276 276
277 ```dart 277 ```dart
278 GetMaterialApp( 278 GetMaterialApp(
@@ -284,7 +284,7 @@ GetMaterialApp( @@ -284,7 +284,7 @@ GetMaterialApp(
284 ) 284 )
285 ``` 285 ```
286 286
287 -If you are not using GetMaterialApp, you can use the manual API to attach Middleware observer. 287 +GetMaterialAppを使用しない場合は、手動のAPIを使ってミドルウェアオブザーバーを設定してください。
288 288
289 ```dart 289 ```dart
290 void main() { 290 void main() {
@@ -294,21 +294,21 @@ void main() { @@ -294,21 +294,21 @@ void main() {
294 initialRoute: "/", 294 initialRoute: "/",
295 navigatorKey: Get.key, 295 navigatorKey: Get.key,
296 navigatorObservers: [ 296 navigatorObservers: [
297 - GetObserver(MiddleWare.observer), // HERE !!! 297 + GetObserver(MiddleWare.observer), // ここ
298 ], 298 ],
299 ), 299 ),
300 ); 300 );
301 } 301 }
302 ``` 302 ```
303 303
304 -Create a MiddleWare class 304 +ミドルウェアクラスを作成する
305 305
306 ```dart 306 ```dart
307 class MiddleWare { 307 class MiddleWare {
308 static observer(Routing routing) { 308 static observer(Routing routing) {
309 - /// You can listen in addition to the routes, the snackbars, dialogs and bottomsheets on each screen.  
310 - ///If you need to enter any of these 3 events directly here,  
311 - ///you must specify that the event is != Than you are trying to do. 309 + /// Routeの他に SnackBar / Dialog / BottomSheet のイベントも監視することができます。
  310 + /// また、ここで直接この3つのいずれかを表示したい場合は、
  311 + /// イベント自身が「それではない」ことを事前にチェックする必要があります。
312 if (routing.current == '/second' && !routing.isSnackbar) { 312 if (routing.current == '/second' && !routing.isSnackbar) {
313 Get.snackbar("Hi", "You are on second route"); 313 Get.snackbar("Hi", "You are on second route");
314 } else if (routing.current =='/third'){ 314 } else if (routing.current =='/third'){
@@ -318,7 +318,7 @@ class MiddleWare { @@ -318,7 +318,7 @@ class MiddleWare {
318 } 318 }
319 ``` 319 ```
320 320
321 -Now, use Get on your code: 321 +それではGetをコードで使ってみましょう。
322 322
323 ```dart 323 ```dart
324 class First extends StatelessWidget { 324 class First extends StatelessWidget {
@@ -391,11 +391,11 @@ class Third extends StatelessWidget { @@ -391,11 +391,11 @@ class Third extends StatelessWidget {
391 } 391 }
392 ``` 392 ```
393 393
394 -## Navigation without context 394 +## contextを使わないナビゲーション
395 395
396 -### SnackBars 396 +### SnackBar
397 397
398 -To have a simple SnackBar with Flutter, you must get the context of Scaffold, or you must use a GlobalKey attached to your Scaffold 398 +FlutterでシンプルなSnackBarを表示したいとき、Scaffoldのcontextか、GlobalKeyを取得する必要があります。
399 399
400 ```dart 400 ```dart
401 final snackBar = SnackBar( 401 final snackBar = SnackBar(
@@ -405,23 +405,22 @@ final snackBar = SnackBar( @@ -405,23 +405,22 @@ final snackBar = SnackBar(
405 onPressed: (){} 405 onPressed: (){}
406 ), 406 ),
407 ); 407 );
408 -// Find the Scaffold in the widget tree and use  
409 -// it to show a SnackBar. 408 +// WidgetツリーでScaffoldを探し、それをSnackBar表示に使用します。
410 Scaffold.of(context).showSnackBar(snackBar); 409 Scaffold.of(context).showSnackBar(snackBar);
411 ``` 410 ```
412 411
413 -With Get: 412 +Getならこうなります。
414 413
415 ```dart 414 ```dart
416 Get.snackbar('Hi', 'i am a modern snackbar'); 415 Get.snackbar('Hi', 'i am a modern snackbar');
417 ``` 416 ```
418 417
419 -With Get, all you have to do is call your Get.snackbar from anywhere in your code or customize it however you want! 418 +コードのどこにいようと、Get.snackbar を呼ぶだけでいいのです。カスタマイズも自由自在です。
420 419
421 ```dart 420 ```dart
422 Get.snackbar( 421 Get.snackbar(
423 - "Hey i'm a Get SnackBar!", // title  
424 - "It's unbelievable! I'm using SnackBar without context, without boilerplate, without Scaffold, it is something truly amazing!", // message 422 + "Hey i'm a Get SnackBar!", // タイトル
  423 + "It's unbelievable! I'm using SnackBar without context, without boilerplate, without Scaffold, it is something truly amazing!", // 本文
425 icon: Icon(Icons.alarm), 424 icon: Icon(Icons.alarm),
426 shouldIconPulse: true, 425 shouldIconPulse: true,
427 onTap:(){}, 426 onTap:(){},
@@ -431,7 +430,7 @@ Get.snackbar( @@ -431,7 +430,7 @@ Get.snackbar(
431 ); 430 );
432 431
433 432
434 - ////////// ALL FEATURES ////////// 433 + ////////// すべてのプロパティ //////////
435 // Color colorText, 434 // Color colorText,
436 // Duration duration, 435 // Duration duration,
437 // SnackPosition snackPosition, 436 // SnackPosition snackPosition,
@@ -468,18 +467,17 @@ Get.snackbar( @@ -468,18 +467,17 @@ Get.snackbar(
468 /////////////////////////////////// 467 ///////////////////////////////////
469 ``` 468 ```
470 469
471 -If you prefer the traditional snackbar, or want to customize it from scratch, including adding just one line (Get.snackbar makes use of a mandatory title and message), you can use  
472 -`Get.rawSnackbar();` which provides the RAW API on which Get.snackbar was built. 470 +従来の SnackBar がお好みの場合や、ゼロからカスタマイズしたい場合 (たとえば Get.snackbar ではタイトルと本文が必須項目となっています)は `Get.rawSnackbar();` を使ってください。SnackBarの元々のAPIを取得できます。
473 471
474 -### Dialogs 472 +### Dialog
475 473
476 -To open dialog: 474 +ダイアログを表示する方法。
477 475
478 ```dart 476 ```dart
479 Get.dialog(YourDialogWidget()); 477 Get.dialog(YourDialogWidget());
480 ``` 478 ```
481 479
482 -To open default dialog: 480 +デフォルトのダイアログを表示する方法。
483 481
484 ```dart 482 ```dart
485 Get.defaultDialog( 483 Get.defaultDialog(
@@ -488,15 +486,15 @@ Get.defaultDialog( @@ -488,15 +486,15 @@ Get.defaultDialog(
488 ); 486 );
489 ``` 487 ```
490 488
491 -You can also use Get.generalDialog instead of showGeneralDialog. 489 +また showGeneralDialog の代わりに Get.generalDialog が使えます。
492 490
493 -For all other Flutter dialog widgets, including cupertinos, you can use Get.overlayContext instead of context, and open it anywhere in your code.  
494 -For widgets that don't use Overlay, you can use Get.context.  
495 -These two contexts will work in 99% of cases to replace the context of your UI, except for cases where inheritedWidget is used without a navigation context. 491 +Overlayを使用するCupertino含むその他のFlutterのダイアログについては、contextの代わりに Get.overlayContext を使うことでコードのどこでもダイアログを表示することができます。
  492 +Overlayを使わないWidgetについては、Get.context が使えます。
  493 +これら2つのcontextはほとんどのケースでUIのcontextを代替することができるでしょう。ただし、ナビゲーションのcontextを使用せずInheritedWidgetが使われているケースは例外です。
496 494
497 -### BottomSheets 495 +### BottomSheet
498 496
499 -Get.bottomSheet is like showModalBottomSheet, but don't need of context. 497 +Get.bottomSheet は showModalBottomSheet に似ていますが、contextが不要です。
500 498
501 ```dart 499 ```dart
502 Get.bottomSheet( 500 Get.bottomSheet(
@@ -519,18 +517,18 @@ Get.bottomSheet( @@ -519,18 +517,18 @@ Get.bottomSheet(
519 ); 517 );
520 ``` 518 ```
521 519
522 -## Nested Navigation 520 +## ネスト構造のナビゲーション
523 521
524 -Get made Flutter's nested navigation even easier.  
525 -You don't need the context, and you will find your navigation stack by Id. 522 +GetはFlutterのネスト構造のナビゲーションの扱いも簡単にしてくれます。
  523 +contextを必要とせず、IDによりナビゲーションのスタックを見つけることができます。
526 524
527 -- NOTE: Creating parallel navigation stacks can be dangerous. The ideal is not to use NestedNavigators, or to use sparingly. If your project requires it, go ahead, but keep in mind that keeping multiple navigation stacks in memory may not be a good idea for RAM consumption. 525 +- 注: 並列のナビゲーションスタックを作成することは危険です。ネスト構造のNavigatorを使用しないか、使用を控えめにするのが理想です。必要なら使っていただいても問題ありませんが、複数のナビゲーションのスタックを保持することはRAM消費の面で好ましくないということは覚えておいてください。
528 526
529 -See how simple it is: 527 +こんなに簡単にできます。
530 528
531 ```dart 529 ```dart
532 Navigator( 530 Navigator(
533 - key: Get.nestedKey(1), // create a key by index 531 + key: Get.nestedKey(1), // インデックス指定でkey作成
534 initialRoute: '/', 532 initialRoute: '/',
535 onGenerateRoute: (settings) { 533 onGenerateRoute: (settings) {
536 if (settings.name == '/') { 534 if (settings.name == '/') {
@@ -543,7 +541,7 @@ Navigator( @@ -543,7 +541,7 @@ Navigator(
543 child: TextButton( 541 child: TextButton(
544 color: Colors.blue, 542 color: Colors.blue,
545 onPressed: () { 543 onPressed: () {
546 - Get.toNamed('/second', id:1); // navigate by your nested route by index 544 + Get.toNamed('/second', id:1); // インデックス指定でネスト型Routeに遷移
547 }, 545 },
548 child: Text("Go to second"), 546 child: Text("Go to second"),
549 ), 547 ),
1 -* [State Management](#state-management)  
2 - + [Reactive State Manager](#reactive-state-manager)  
3 - - [Advantages](#advantages)  
4 - - [Maximum performance:](#maximum-performance)  
5 - - [Declaring a reactive variable](#declaring-a-reactive-variable)  
6 - - [Having a reactive state, is easy.](#having-a-reactive-state-is-easy)  
7 - - [Using the values in the view](#using-the-values-in-the-view)  
8 - - [Conditions to rebuild](#conditions-to-rebuild)  
9 - - [Where .obs can be used](#where-obs-can-be-used)  
10 - - [Note about Lists](#note-about-lists)  
11 - - [Why i have to use .value](#why-i-have-to-use-value) 1 +* [状態管理](#状態管理)
  2 + + [リアクティブな状態管理](#リアクティブな状態管理)
  3 + - [利点](#利点)
  4 + - [パフォーマンスの最大化](#パフォーマンスの最大化)
  5 + - [リアクティブな変数の宣言](#リアクティブな変数の宣言)
  6 + - [初期値の設定](#初期値の設定)
  7 + - [Observableの値をビュー内で使う](#Observableの値をビュー内で使う)
  8 + - [更新条件を設定](#更新条件を設定)
  9 + - [.obsの使いどころ](#.obsの使いどころ)
  10 + - [List(Rx)に関する補足](#List(Rx)に関する補足)
  11 + - [なぜ「.value」を使う必要があるのか](#なぜ「.value」を使う必要があるのか)
12 - [Obx()](#obx) 12 - [Obx()](#obx)
13 - - [Workers](#workers)  
14 - + [Simple State Manager](#simple-state-manager)  
15 - - [Advantages](#advantages-1)  
16 - - [Usage](#usage)  
17 - - [How it handles controllers](#how-it-handles-controllers)  
18 - - [You won't need StatefulWidgets anymore](#you-wont-need-statefulwidgets-anymore)  
19 - - [Why it exists](#why-it-exists)  
20 - - [Other ways of using it](#other-ways-of-using-it)  
21 - - [Unique IDs](#unique-ids)  
22 - + [Mixing the two state managers](#mixing-the-two-state-managers)  
23 - + [GetBuilder vs GetX vs Obx vs MixinBuilder](#getbuilder-vs-getx-vs-obx-vs-mixinbuilder) 13 + - [Worker](#worker)
  14 + + [非リアクティブな状態管理](#非リアクティブな状態管理)
  15 + - [利点](#利点)
  16 + - [使用例](#使用例)
  17 + - [Controllerインスタンスの扱い](#Controllerインスタンスの扱い)
  18 + - [StatefulWidgetsはもういらない](#StatefulWidgetsはもういらない)
  19 + - [Getの目的](#Getの目的)
  20 + - [Controllerの様々な使用方法](#Controllerの様々な使用方法)
  21 + - [ユニークIDの設定](#ユニークIDの設定)
  22 + + [状態管理ソリューションを混在させる](#状態管理ソリューションを混在させる)
  23 + + [StateMixin](#StateMixin)
  24 + + [GetBuilder VS GetX VS Obx VS MixinBuilder](#GetBuilder-VS-GetX-VS-Obx-VS-MixinBuilder)
24 25
25 -# State Management 26 +# 状態管理
26 27
27 -GetX does not use Streams or ChangeNotifier like other state managers. Why? In addition to building applications for android, iOS, web, linux, macos and linux, with GetX you can build server applications with the same syntax as Flutter/GetX. In order to improve response time and reduce RAM consumption, we created GetValue and GetStream, which are low latency solutions that deliver a lot of performance, at a low operating cost. We use this base to build all of our resources, including state management. 28 +GetXは他の状態管理ライブラリのように Stream や ChangeNotifier を使用する必要がありません。なぜか?私たちは応答時間とRAM消費量を改善するために GetValueとGetStream という低遅延のソリューションを開発しましたが、状態管理機能を含むGetXのリソースはすべてこれをベースに作られているためです。このソリューションはより低い運用コストと高いパフォーマンスを実現します。GetXを使えばAndroid、iOS、Web、Linux、macOS用のアプリケーションを作成するだけでなく、Flutter/GetXと同じシンタックスでサーバーアプリケーションを作ることができます。
28 29
29 -* _Complexity_: Some state managers are complex and have a lot of boilerplate. With GetX you don't have to define a class for each event, the code is highly clean and clear, and you do a lot more by writing less. Many people have given up on Flutter because of this topic, and they now finally have a stupidly simple solution for managing states.  
30 -* _No code generators_: You spend half your development time writing your application logic. Some state managers rely on code generators to have minimally readable code. Changing a variable and having to run build_runner can be unproductive, and often the waiting time after a flutter clean will be long, and you will have to drink a lot of coffee. 30 +* _バカみたいにシンプル_: 他の状態管理アプローチの中には、複雑で多くのボイラープレートコードを書かなければいけないものもあります。この問題により少なくない人たちがFlutterを見限りましたが、今ようやく、バカみたいにシンプルなソリューションを手に入れることができました。GetXを使えば、非常にすっきりとした、記述量の少ないコードでより多くのことができるようになります。イベントごとにクラスを定義する必要もありません。
  31 +* _コード生成にサヨナラ_: 開発時間の半分はアプリケーションロジックの作成に費やします。それにも関わらず、状態管理ライブラリの中には、ミニマルなコードを作るためにコード生成ツールに依存しているものがあります。変数を変更して build_runner を実行するのは非生産的ですし、flutter clean 後の待ち時間もコーヒーをたくさん飲まなければならないほど長くなることもあります。
31 32
32 -With GetX everything is reactive, and nothing depends on code generators, increasing your productivity in all aspects of your development. 33 +GetXはすべてがリアクティブであり、コード生成ツールに依存しないため、開発のあらゆる面において生産性が向上します。
33 34
34 -* _It does not depend on context_: You probably already needed to send the context of your view to a controller, making the View's coupling with your business logic high. You have probably had to use a dependency for a place that has no context, and had to pass the context through various classes and functions. This just doesn't exist with GetX. You have access to your controllers from within your controllers without any context. You don't need to send the context by parameter for literally nothing.  
35 -* _Granular control_: most state managers are based on ChangeNotifier. ChangeNotifier will notify all widgets that depend on it when notifyListeners is called. If you have 40 widgets on one screen, which have a variable of your ChangeNotifier class, when you update one, all of them will be rebuilt. 35 +* _context依存にサヨナラ_: ビューとビジネスロジックを連携させるため、ビューのcontextをControllerに送る必要に迫られた。contextがないところで依存オブジェクトの注入をする必要があり、contextを方々のクラスや関数からなんとか渡した。これらの経験、誰もが通ってきた道かと思います。しかし、GetXではこのような経験をすることはありません。contextなしで、Controllerの中から別のControllerにアクセスすることができます。パラメーターを通じて無駄にcontextを送る必要はもうありません。
  36 +* _細かいコントロール_: 多くの状態管理ソリューションは、ChangeNotifierをベースにしています。ChangeNotifierは、notifyListenerが呼ばれたときに、依存するすべてのWidgetに通知します。画面に40個のWidgetがあるとしましょう。それらがすべてChangeNotifierの変数に依存している場合、変数を1つでも更新すれば、すべてのWidgetが更新されます。
36 37
37 -With GetX, even nested widgets are respected. If you have Obx watching your ListView, and another watching a checkbox inside the ListView, when changing the CheckBox value, only it will be updated, when changing the List value, only the ListView will be updated. 38 +GetXを使えばネストされたWidgetさえも的確にビルドを処理することができます。ListViewを担当するObxと、ListViewの中のチェックボックスを担当するObxがあれば、チェックボックスの値を変更した場合はチェックボックスWidgetだけが更新され、Listの値を変更した場合はListViewだけが更新されます。
38 39
39 -* _It only reconstructs if its variable REALLY changes_: GetX has flow control, that means if you display a Text with 'Paola', if you change the observable variable to 'Paola' again, the widget will not be reconstructed. That's because GetX knows that 'Paola' is already being displayed in Text, and will not do unnecessary reconstructions. 40 +* _変数が本当に変わったときだけ更新する_: GetXはデータの流れをコントロールします。つまり、Textに紐づいたObservable(監視可能)変数の値 'Paola' を、同じ 'Paola' に変更してもWidgetは更新されません。これは、GetXがTextに'Paola'がすでに表示されていることをわかっているためです。
40 41
41 -Most (if not all) current state managers will rebuild on the screen. 42 +多くの状態管理ソリューションは、この場合更新を行います。
42 43
43 -## Reactive State Manager 44 +## リアクティブな状態管理
44 45
45 -Reactive programming can alienate many people because it is said to be complicated. GetX turns reactive programming into something quite simple: 46 +リアクティブプログラミングは複雑であると言われがちなためか、多くの人に敬遠されています。しかし、GetXはリアクティブプログラミングを非常にシンプルなものにしてくれます。
46 47
47 -* You won't need to create StreamControllers.  
48 -* You won't need to create a StreamBuilder for each variable  
49 -* You will not need to create a class for each state.  
50 -* You will not need to create a get for an initial value. 48 +* StreamControllerを作る必要はありません。
  49 +* 変数ごとにStreamBuilderをセットする必要はありません。
  50 +* 状態ごとにクラスを作る必要はありません。
  51 +* 初期値のためにgetを準備する必要はありません。
51 52
52 -Reactive programming with Get is as easy as using setState. 53 +Getによるリアクティブプログラミングは、setState並に簡単です。
53 54
54 -Let's imagine that you have a name variable and want that every time you change it, all widgets that use it are automatically changed. 55 +たとえば name という変数があり、それを変更するたびに変数に依存するすべてのWidgetを自動更新したいとします。
55 56
56 -This is your count variable: 57 +これがその name 変数です。
57 58
58 ``` dart 59 ``` dart
59 var name = 'Jonatas Borges'; 60 var name = 'Jonatas Borges';
60 ``` 61 ```
61 62
62 -To make it observable, you just need to add ".obs" to the end of it: 63 +これをObservable(監視可能)にするには、値の末尾に ".obs" を付け足すだけです。
63 64
64 ``` dart 65 ``` dart
65 var name = 'Jonatas Borges'.obs; 66 var name = 'Jonatas Borges'.obs;
66 ``` 67 ```
67 68
68 -That's all. It's *that* simple. 69 +これで終わりです。*こんなに* 簡単なんですよ。
69 70
70 -From now on, we might refer to this reactive-".obs"(ervables) variables as _Rx_. 71 +(以後、このリアクティブな ".obs" 変数、Observable(監視可能)を _Rx_ と呼ぶことがあります。)
71 72
72 -What did we do under the hood? We created a `Stream` of `String` s, assigned the initial value `"Jonatas Borges"` , we notified all widgets that use `"Jonatas Borges"` that they now "belong" to this variable, and when the _Rx_ value changes, they will have to change as well. 73 +内部ではこのような処理を行っています: `String`の`Stream`を作成し、初期値`"Jonatas Borges"`を割り当て、`"Jonatas Borges"`に依存するすべてのWidgetに、あなたは今この変数の影響下にあるから、_Rx_の値が変更されたときには、あなたも同様に変更する必要がある旨を通知。
73 74
74 -This is the **magic of GetX**, thanks to Dart's capabilities. 75 +これがDartの機能のおかげで実現できた **GetX マジック** です。
75 76
76 -But, as we know, a `Widget` can only be changed if it is inside a function, because static classes do not have the power to "auto-change". 77 +しかし皆さんご存知の通り、`Widget` は関数の中にいなければ自らを更新できません。静的クラスには「自動更新」の機能がないからです。
77 78
78 -You will need to create a `StreamBuilder` , subscribe to this variable to listen for changes, and create a "cascade" of nested `StreamBuilder` if you want to change several variables in the same scope, right? 79 +それなら、同じスコープ内で複数の変数に依存してWidgetをビルドする場合は、複数の `StreamBuilder` をネストして変数の変化を監視する必要がありますね。
79 80
80 -No, you don't need a `StreamBuilder` , but you are right about static classes. 81 +いいえ、**GetX** なら `StreamBuilder` すら不要です。
81 82
82 -Well, in the view, we usually have a lot of boilerplate when we want to change a specific Widget, that's the Flutter way.  
83 -With **GetX** you can also forget about this boilerplate code. 83 +またWidgetを更新する際のボイラープレートコードについても、**GetX**では忘れてください。
84 84
85 -`StreamBuilder( … )` ? `initialValue: …` ? `builder: …` ? Nope, you just need to place this variable inside an `Obx()` Widget. 85 +`StreamBuilder( ... )` ? `initialValue: ...` ? `builder: ...` ? これらはすべて不要で、対象のWidgetを `Obx()` の中に入れるだけです。
86 86
87 ``` dart 87 ``` dart
88 Obx (() => Text (controller.name)); 88 Obx (() => Text (controller.name));
89 ``` 89 ```
90 90
91 -_What do you need to memorize?_ Only `Obx(() =>` . 91 +_覚えること?_ それは `Obx(() =>` だけです。
92 92
93 -You are just passing that Widget through an arrow-function into an `Obx()` (the "Observer" of the _Rx_). 93 +そのWidgetをアロー関数を通じて `Obx()`(_Rx_のObserver(監視者))に渡すだけです。
94 94
95 -`Obx` is pretty smart, and will only change if the value of `controller.name` changes. 95 +`Obx` は非常に賢く、`controller.name` の値が本当に変わったときにのみ、Widgetの更新をかけます。
96 96
97 -If `name` is `"John"` , and you change it to `"John"` ( `name.value = "John"` ), as it's the same `value` as before, nothing will change on the screen, and `Obx` , to save resources, will simply ignore the new value and not rebuild the Widget. **Isn't that amazing?** 97 +`name` が `"John"` だとして、それを `"John"` ( `name.value = "John"` ) に変更しても、以前と同じ `value` のため画面上では何も変化しません。`Obx` はリソースを節約するために値を無視し、Widgetを更新しません。**すごいでしょ?**
98 98
99 -> So, what if I have 5 _Rx_ (observable) variables within an `Obx` ? 99 +> では、もしも `Obx` の中に_Rx_(Observable)変数が5つあったらどうでしょう?
100 100
101 -It will just update when **any** of them changes. 101 +5つの**いずれかに**値の変化があればWidgetは更新されます。
102 102
103 -> And if I have 30 variables in a class, when I update one, will it update **all** the variables that are in that class? 103 +> また、1つのControllerクラスに30もの変数がある場合、1つの変数を更新したら変数に関わるWidgetが**すべて**更新されてしまうのでしょうか?
104 104
105 -Nope, just the **specific Widget** that uses that _Rx_ variable. 105 +いいえ、_Rx_ 変数を使う特定のWidgetだけが更新されます。
106 106
107 -So, **GetX** only updates the screen, when the _Rx_ variable changes it's value. 107 +言い換えるなら、**GetX**は _Rx_ 変数の値が変化したときだけ画面更新をしてくれるということです。
108 108
109 -``` 109 +```dart
110 110
111 final isOpen = false.obs; 111 final isOpen = false.obs;
112 112
113 -// NOTHING will happen... same value. 113 +// 同じ値なので何も起きません。
114 void onButtonTap() => isOpen.value=false; 114 void onButtonTap() => isOpen.value=false;
115 ``` 115 ```
116 116
117 -### Advantages 117 +### 利点
118 118
119 -**GetX()** helps you when you need **granular** control over what's being updated. 119 +**GetX()**は何を更新して何をしないのか、の**細かい**コントロールが可能です。
120 120
121 -If you do not need `unique IDs` , because all your variables will be modified when you perform an action, then use `GetBuilder` ,  
122 -because it's a Simple State Updater (in blocks, like `setState()` ), made in just a few lines of code.  
123 -It was made simple, to have the least CPU impact, and just to fulfill a single purpose (a _State_ rebuild) and spend the minimum resources possible. 121 +すべての更新するのでそのようなコントロールが不要な場合は、`GetBuilder` を検討してください。
  122 +これはわずか数行のコードで作られた、状態更新のためのシンプルなビルダーです。(`setState()`のようにブロックで)
  123 +CPUへの影響を最小限にするために作られており、単一の目的(_状態_ の再構築)を果たすため、可能な限りリソース消費を抑えました。
124 124
125 -If you need a **powerful** State Manager, you can't go wrong with **GetX**. 125 +**強力な** 状態管理のソリューションを求めているなら、**GetX**で間違いはありません。
126 126
127 -It doesn't work with variables, but __flows__, everything in it are `Streams` under the hood. 127 +変数をそのまま扱うことはできませんが、内部では `Stream` としてデータが扱われています。
128 128
129 -You can use _rxDart_ in conjunction with it, because everything are `Streams`,  
130 -you can listen to the `event` of each "_Rx_ variable",  
131 -because everything in it are `Streams`. 129 +すべてが `Stream` なので、_RxDart_ を組み合わせることも可能ですし、
  130 +"_Rx_ 変数" のイベントや状態を監視することも可能です。
132 131
133 -It is literally a _BLoC_ approach, easier than _MobX_, and without code generators or decorations.  
134 -You can turn **anything** into an _"Observable"_ with just a `.obs` . 132 +GetXは _MobX_ より簡単で、コード自動生成や記述量を減らした_BLoC_ 型アプローチと言えるかもしれません。
  133 +値の末尾に `.obs` を付けるだけで**なんでも** _"Observable(監視可能)"_ にできるのです。
135 134
136 -### Maximum performance: 135 +### パフォーマンスの最大化
137 136
138 -In addition to having a smart algorithm for minimal rebuilds, **GetX** uses comparators  
139 -to make sure the State has changed. 137 +ビルドを最小限に抑えるための賢いアルゴリズムに加えて、
  138 +**GetX**はコンパレーターを使用して状態が変更されたことを確認します。
140 139
141 -If you experience any errors in your app, and send a duplicate change of State,  
142 -**GetX** will ensure it will not crash. 140 +アプリでなにかしらのエラーが発生し、状態が変更された情報を
  141 +二重に送信してしまったとしても**GetX**はクラッシュを防いでくれます。
143 142
144 -With **GetX** the State only changes if the `value` change.  
145 -That's the main difference between **GetX**, and using _ `computed` from MobX_.  
146 -When joining two __observables__, and one changes; the listener of that _observable_ will change as well. 143 +**GetX**では値が変化したときにはじめて「状態」が変化するためです。
  144 +これが **GetX** と _MobX の `computed`_ を使う際の主な違いです。
  145 +2つの __Observable__ を組み合わせて一つが変化したとき、それを監視しているオブジェクトも変化します。
147 146
148 -With **GetX**, if you join two variables, `GetX()` (similar to `Observer()` ) will only rebuild if it implies a real change of State. 147 +これは `GetX()` (`Observer()`のようなもの) において2つの変数を組み合わせた場合においても、
  148 +それが本当に状態の変化を意味するときだけWidgetの更新が行われるということでもあります。
149 149
150 -### Declaring a reactive variable 150 +### リアクティブな変数の宣言
151 151
152 -You have 3 ways to turn a variable into an "observable". 152 +変数を "Observable" にする方法は3つあります。
153 153
154 -1 - The first is using **`Rx{Type}`**. 154 +1 - **`Rx{Type}`** を使用する
155 155
156 ``` dart 156 ``` dart
157 -// initial value is recommended, but not mandatory 157 +// 初期値を入れることを推奨しますが、必須ではありません
158 final name = RxString(''); 158 final name = RxString('');
159 final isLogged = RxBool(false); 159 final isLogged = RxBool(false);
160 final count = RxInt(0); 160 final count = RxInt(0);
@@ -163,7 +163,7 @@ final items = RxList<String>([]); @@ -163,7 +163,7 @@ final items = RxList<String>([]);
163 final myMap = RxMap<String, int>({}); 163 final myMap = RxMap<String, int>({});
164 ``` 164 ```
165 165
166 -2 - The second is to use **`Rx`** and use Darts Generics, `Rx<Type>` 166 +2 - **`Rx`** とジェネリクスによる型指定の組み合わせ
167 167
168 ``` dart 168 ``` dart
169 final name = Rx<String>(''); 169 final name = Rx<String>('');
@@ -174,11 +174,11 @@ final number = Rx<Num>(0); @@ -174,11 +174,11 @@ final number = Rx<Num>(0);
174 final items = Rx<List<String>>([]); 174 final items = Rx<List<String>>([]);
175 final myMap = Rx<Map<String, int>>({}); 175 final myMap = Rx<Map<String, int>>({});
176 176
177 -// Custom classes - it can be any class, literally 177 +// 任意の型を指定可能 - どんなクラスでもOK
178 final user = Rx<User>(); 178 final user = Rx<User>();
179 ``` 179 ```
180 180
181 -3 - The third, more practical, easier and preferred approach, just add **`.obs`** as a property of your `value` : 181 +3 - 最も実用的で簡単な方法として、**`.obs`** を値に付ける
182 182
183 ``` dart 183 ``` dart
184 final name = ''.obs; 184 final name = ''.obs;
@@ -189,31 +189,31 @@ final number = 0.obs; @@ -189,31 +189,31 @@ final number = 0.obs;
189 final items = <String>[].obs; 189 final items = <String>[].obs;
190 final myMap = <String, int>{}.obs; 190 final myMap = <String, int>{}.obs;
191 191
192 -// Custom classes - it can be any class, literally 192 +// カスタムクラスのインスタンスにも付けられます
193 final user = User().obs; 193 final user = User().obs;
194 ``` 194 ```
195 195
196 -##### Having a reactive state, is easy. 196 +##### 初期値の設定
197 197
198 -As we know, _Dart_ is now heading towards _null safety_.  
199 -To be prepared, from now on, you should always start your _Rx_ variables with an **initial value**. 198 +ご存知の通り、_Dart_ は現在 _null safety_ へ移行しているところです。
  199 +それに備えるために今後は _Rx_ 変数は常に**初期値**を設定してください。
200 200
201 -> Transforming a variable into an _observable_ + _initial value_ with **GetX** is the simplest, and most practical approach. 201 +> **GetX** で変数を _Observable_ にしつつ _初期値_ を設定するのはとても簡単です。
202 202
203 -You will literally add a " `.obs` " to the end of your variable, and **that’s it**, you’ve made it observable,  
204 -and its `.value` , well, will be the _initial value_). 203 +変数の末尾に `.obs` を付ける。**それだけ。**
  204 +めでたく Observable とそのプロパティ `.value` (つまり _初期値_)ができました。
205 205
206 -### Using the values in the view 206 +### Observableの値をビュー内で使う
207 207
208 ``` dart 208 ``` dart
209 -// controller file 209 +// Controllerクラス
210 final count1 = 0.obs; 210 final count1 = 0.obs;
211 final count2 = 0.obs; 211 final count2 = 0.obs;
212 int get sum => count1.value + count2.value; 212 int get sum => count1.value + count2.value;
213 ``` 213 ```
214 214
215 ``` dart 215 ``` dart
216 -// view file 216 +// ビュークラス
217 GetX<Controller>( 217 GetX<Controller>(
218 builder: (controller) { 218 builder: (controller) {
219 print("count 1 rebuild"); 219 print("count 1 rebuild");
@@ -234,37 +234,38 @@ GetX<Controller>( @@ -234,37 +234,38 @@ GetX<Controller>(
234 ), 234 ),
235 ``` 235 ```
236 236
237 -If we increment `count1.value++` , it will print: 237 +`count1.value++` を実行すると、以下の通りprintされます。
238 238
239 * `count 1 rebuild` 239 * `count 1 rebuild`
240 240
241 * `count 3 rebuild` 241 * `count 3 rebuild`
242 242
243 -because `count1` has a value of `1` , and `1 + 0 = 1` , changing the `sum` getter value. 243 +なぜなら `count1` の値が `1` に変わり、それに伴ってgetter `sum` の値にも `1 + 0 = 1` と変化が起こるからです。
244 244
245 -If we change `count2.value++` , it will print: 245 +今度は `count2.value++` を実行してみましょう。
246 246
247 * `count 2 rebuild` 247 * `count 2 rebuild`
248 248
249 * `count 3 rebuild` 249 * `count 3 rebuild`
250 250
251 -because `count2.value` changed, and the result of the `sum` is now `2` . 251 +もうおわかりですね。これは `count2.value` が変わり、その結果 `sum` が `2` になったからです。
252 252
253 -* NOTE: By default, the very first event will rebuild the widget, even if it is the same `value`. 253 +* 注: デフォルト仕様では、`value` に変化がなかったとしても、それが最初のイベントであればWidgetを更新します。
254 254
255 - This behavior exists due to Boolean variables. 255 + この仕様はbool変数の性質から来るものです。
256 256
257 -Imagine you did this: 257 +たとえばこの場合を想像してみてください。
258 258
259 ``` dart 259 ``` dart
260 var isLogged = false.obs; 260 var isLogged = false.obs;
261 ``` 261 ```
262 262
263 -And then, you checked if a user is "logged in" to trigger an event in `ever` . 263 +そして、isLogged(ユーザーがログインしたかどうか)の変化をトリガーにever関数内のコールバックfireRouteを呼び出したいとします。
264 264
265 ``` dart 265 ``` dart
266 @override 266 @override
267 onInit() async { 267 onInit() async {
  268 + // everは引数1が変化するたびに引数2を実行するリスナー
268 ever(isLogged, fireRoute); 269 ever(isLogged, fireRoute);
269 isLogged.value = await Preferences.hasToken(); 270 isLogged.value = await Preferences.hasToken();
270 } 271 }
@@ -278,26 +279,26 @@ fireRoute(logged) { @@ -278,26 +279,26 @@ fireRoute(logged) {
278 } 279 }
279 ``` 280 ```
280 281
281 -if `hasToken` was `false` , there would be no change to `isLogged` , so `ever()` would never be called.  
282 -To avoid this type of behavior, the first change to an _observable_ will always trigger an event,  
283 -even if it contains the same `.value` . 282 +もし `hasToken` が `false` なら `isLogged` に変化はありません。すると `ever()` のコールバックは永遠に呼び出されないことになります。
  283 +このような挙動を防ぐために _Observable_ への最初の更新は、それがたとえ同じ `.value` だったとしても
  284 +常にイベントを引き起こすようにしています。
284 285
285 -You can remove this behavior if you want, using: 286 +ご参考までに、この仕様は以下の設定で解除することができます。
286 `isLogged.firstRebuild = false;` 287 `isLogged.firstRebuild = false;`
287 288
288 -### Conditions to rebuild 289 +### 更新条件を設定
289 290
290 -In addition, Get provides refined state control. You can condition an event (such as adding an object to a list), on a certain condition. 291 +Getにはさらに洗練された「状態」のコントロール方法があります。イベント(Listへのオブジェクト追加など)に対して条件を付けることが可能です。
291 292
292 ``` dart 293 ``` dart
293 -// First parameter: condition, must return true or false.  
294 -// Second parameter: the new value to apply if the condition is true. 294 +// 引数1: Listにオブジェクトを加える条件。trueかfalseを返すこと
  295 +// 引数2: 条件がtrueの場合に加える新しいオブジェクト
295 list.addIf(item < limit, item); 296 list.addIf(item < limit, item);
296 ``` 297 ```
297 298
298 -Without decorations, without a code generator, without complications :smile: 299 +最低限のコードで、コード生成ツールも使わず、とても簡単ですね :smile:
299 300
300 -Do you know Flutter's counter app? Your Controller class might look like this: 301 +カウンターアプリもこのようにシンプルに実現できます。
301 302
302 ``` dart 303 ``` dart
303 class CountController extends GetxController { 304 class CountController extends GetxController {
@@ -305,19 +306,19 @@ class CountController extends GetxController { @@ -305,19 +306,19 @@ class CountController extends GetxController {
305 } 306 }
306 ``` 307 ```
307 308
308 -With a simple: 309 +Controllerを設定して、下記を実行するだけ。
309 310
310 ``` dart 311 ``` dart
311 controller.count.value++ 312 controller.count.value++
312 ``` 313 ```
313 314
314 -You could update the counter variable in your UI, regardless of where it is stored. 315 +UIの数字が置き換わりましたね。このようにアプリのどこであっても更新をかけることができます。
315 316
316 -### Where .obs can be used 317 +### .obsの使いどころ
317 318
318 -You can transform anything on obs. Here are two ways of doing it: 319 +.obs を使うことでどんなものもObservableにすることができます。方法は2つ。
319 320
320 -* You can convert your class values to obs 321 +* クラスのインスタンス変数をobsに変換する
321 322
322 ``` dart 323 ``` dart
323 class RxUser { 324 class RxUser {
@@ -326,7 +327,7 @@ class RxUser { @@ -326,7 +327,7 @@ class RxUser {
326 } 327 }
327 ``` 328 ```
328 329
329 -* or you can convert the entire class to be an observable 330 +* クラスのインスタンスを丸々obsに変換する
330 331
331 ``` dart 332 ``` dart
332 class User { 333 class User {
@@ -335,181 +336,181 @@ class User { @@ -335,181 +336,181 @@ class User {
335 var age; 336 var age;
336 } 337 }
337 338
338 -// when instantianting: 339 +// インスタンス化の際
339 final user = User(name: "Camila", age: 18).obs; 340 final user = User(name: "Camila", age: 18).obs;
340 ``` 341 ```
341 342
342 -### Note about Lists 343 +### List(Rx)に関する補足
343 344
344 -Lists are completely observable as are the objects within it. That way, if you add a value to a list, it will automatically rebuild the widgets that use it. 345 +List(Rx)はその中のオブジェクトと同様、監視可能(Observable)です。そのためオブジェクトを追加すると、List(Rx)に依存するWidgetは自動更新されます。
345 346
346 -You also don't need to use ".value" with lists, the amazing dart api allowed us to remove that.  
347 -Unfortunaly primitive types like String and int cannot be extended, making the use of .value mandatory, but that won't be a problem if you work with gets and setters for these. 347 +またList(Rx)をListとするために ".value" を使う必要はありません。DartのAPIがこれを可能にしてくれました。ただ、残念ながら他のStringやintのようなプリミティブ型は拡張ができないため、.value を使う必要があります。getterやsetterを活用するのであればあまり問題になりませんが。
348 348
349 ``` dart 349 ``` dart
350 -// On the controller 350 +// Controllerクラス
351 final String title = 'User Info:'.obs 351 final String title = 'User Info:'.obs
352 final list = List<User>().obs; 352 final list = List<User>().obs;
353 353
354 -// on the view  
355 -Text(controller.title.value), // String need to have .value in front of it 354 +// ビュークラス
  355 +Text(controller.title.value), // Stringの場合は .value が必要
356 ListView.builder ( 356 ListView.builder (
357 - itemCount: controller.list.length // lists don't need it 357 + itemCount: controller.list.length // Listの場合は不要
358 ) 358 )
359 ``` 359 ```
360 360
361 -When you are making your own classes observable, there is a different way to update them: 361 +カスタムのクラスをObservableにした場合は、様々な方法で値を更新することができます。
362 362
363 ``` dart 363 ``` dart
364 -// on the model file  
365 -// we are going to make the entire class observable instead of each attribute 364 +// モデルクラス
  365 +// 属性をobsにするやり方ではなく、クラス全体をobsにする方法を採ります
366 class User() { 366 class User() {
367 User({this.name = '', this.age = 0}); 367 User({this.name = '', this.age = 0});
368 String name; 368 String name;
369 int age; 369 int age;
370 } 370 }
371 371
372 -// on the controller file 372 +// Controllerクラス
373 final user = User().obs; 373 final user = User().obs;
374 -// when you need to update the user variable:  
375 -user.update( (user) { // this parameter is the class itself that you want to update 374 +// user変数を更新するときはこのようなメソッドを作ります
  375 +user.update( (user) { // このパラメーターは更新するオブジェクトそのもの
376 user.name = 'Jonny'; 376 user.name = 'Jonny';
377 user.age = 18; 377 user.age = 18;
378 }); 378 });
379 -// an alternative way of update the user variable: 379 +// あるいは、この方法でも。変数名は呼び出し可能です。
380 user(User(name: 'João', age: 35)); 380 user(User(name: 'João', age: 35));
381 381
382 -// on view: 382 +// ビュークラス
383 Obx(()=> Text("Name ${user.value.name}: Age: ${user.value.age}")) 383 Obx(()=> Text("Name ${user.value.name}: Age: ${user.value.age}"))
384 -// you can also access the model values without the .value:  
385 -user().name; // notice that is the user variable, not the class (variable has lowercase u) 384 +// .value を使わずにモデルのプロパティにアクセスすることも可能です
  385 +user().name; // userがUserではないことに注目。user()でUserを受け取れます。
386 ``` 386 ```
387 387
388 -You don't have to work with sets if you don't want to. you can use the "assign 'and" assignAll "api.  
389 -The "assign" api will clear your list, and add a single object that you want to start there.  
390 -The "assignAll" api will clear the existing list and add any iterable objects that you inject into it. 388 +ListのsetAllやsetRangeメソッドの代わりに、"assign" "assignAll" APIを使っていただくことも可能です。
  389 +"assign" APIはListの内容をクリアした後に、指定した単独のオブジェクトを追加してくれます。
  390 +"assignAll" APIはそのIterable版です。
391 391
392 -### Why i have to use .value 392 +### なぜ「.value」を使う必要があるのか
393 393
394 -We could remove the obligation to use 'value' to `String` and `int` with a simple decoration and code generator, but the purpose of this library is precisely avoid external dependencies. We want to offer an environment ready for programming, involving the essentials (management of routes, dependencies and states), in a simple, lightweight and performant way, without a need of an external package. 394 +ちょっとしたアノテーションとコード生成ツールを使って`String`や`int`で `.value` を使わなくて済むようにもすることはできますが、このライブラリの目的は「外部依存パッケージを減らす」ことです。私たちは、外部パッケージを必要としない、必須ツール(Route、依存オブジェクト、状態の管理)が揃った開発環境を軽量かつシンプルな方法で提供したいと考えています。
395 395
396 -You can literally add 3 letters to your pubspec (get) and a colon and start programming. All solutions included by default, from route management to state management, aim at ease, productivity and performance. 396 +まさに pubspecに3文字(get)とコロンを加えて、プログラミングを始めることができるのです。Route管理から状態管理まで、必要なソリューションが標準装備されています。GetXはシンプルさ、生産性、高いパフォーマンスを目指します。
397 397
398 -The total weight of this library is less than that of a single state manager, even though it is a complete solution, and that is what you must understand. 398 +これほど多機能であるにも関わらず、このライブラリの総容量は他の多くの状態管理ライブラリよりも少ないです。その点をご理解いただけるとうれしいです。
399 399
400 -If you are bothered by `.value` , and like a code generator, MobX is a great alternative, and you can use it in conjunction with Get. For those who want to add a single dependency in pubspec and start programming without worrying about the version of a package being incompatible with another, or if the error of a state update is coming from the state manager or dependency, or still, do not want to worrying about the availability of controllers, whether literally "just programming", get is just perfect. 400 +`.value` が嫌でコード生成ツールを使いたいという方には、MobXは素晴らしいライブラリだと思いますし、Getと併用することもできます。逆に多くの外部パッケージに依存したくない方、パッケージ間の互換性を気にしたくない方、状態管理ツールや依存オブジェクトから状態更新エラーが出ているかどうかを気にせずプログラミングをしたい方、依存するControllerクラスのインスタンスがあるかどうかを都度都度心配したくない方にとってはGetはまさに最適です。
401 401
402 -If you have no problem with the MobX code generator, or have no problem with the BLoC boilerplate, you can simply use Get for routes, and forget that it has state manager. Get SEM and RSM were born out of necessity, my company had a project with more than 90 controllers, and the code generator simply took more than 30 minutes to complete its tasks after a Flutter Clean on a reasonably good machine, if your project it has 5, 10, 15 controllers, any state manager will supply you well. If you have an absurdly large project, and code generator is a problem for you, you have been awarded this solution. 402 +MobXのコード生成や、BLoCのボイラープレートコードが気にならないのであれば、Route管理にだけでもGetをお使いいただけるとうれしいです。GetのSEMとRSMは必要に迫られて生まれたものです。私の会社で以前、90以上のControllerを持つプロジェクトがあり、それなりの性能のマシンでflutter cleanを行った後でさえ、コード生成ツールがタスクを完了するのに30分以上かかりました。もしあなたが大きなプロジェクトに関わっており、コード生成ツールが問題になっているのであれば、Getを検討してみてください。
403 403
404 -Obviously, if someone wants to contribute to the project and create a code generator, or something similar, I will link in this readme as an alternative, my need is not the need for all devs, but for now I say, there are good solutions that already do that, like MobX. 404 +もちろん、コード生成ツールをGetXに導入したい方が実際にツールを作成してプロジェクトに貢献した場合は、このReadMeに代替ソリューションとして掲載させていただきます。私はすべての開発者のニーズをかなえたいわけではありませんが、今はこの質問に対しては、「すでにMobXのように同様のことを実現してくれる良いソリューションがある」とだけ言わせてください。
405 405
406 ### Obx() 406 ### Obx()
407 407
408 -Typing in Get using Bindings is unnecessary. you can use the Obx widget instead of GetX which only receives the anonymous function that creates a widget.  
409 -Obviously, if you don't use a type, you will need to have an instance of your controller to use the variables, or use `Get.find<Controller>()` .value or Controller.to.value to retrieve the value. 408 +GetX()の代わりにObx()を使用することもできます。ObxはWidgetを生成する匿名関数をパラメーターに持ちます。複数のControllerに対応することができますが、自身はControllerのインスタンスを持たず、型指定もできません。そのため別途Controllerのインスタンスを作るか、`Get.find<Controller>()` でインスタンスを探しておく必要があります。
410 409
411 -### Workers 410 +### Worker
412 411
413 -Workers will assist you, triggering specific callbacks when an event occurs. 412 +Worker はイベント発生に伴って指定したコールバックを呼び出すことができます。
414 413
415 ``` dart 414 ``` dart
416 -/// Called every time `count1` changes. 415 +/// `count1` が更新されるたびに第2引数のコールバックが実行される
417 ever(count1, (_) => print("$_ has been changed")); 416 ever(count1, (_) => print("$_ has been changed"));
418 417
419 -/// Called only first time the variable $_ is changed 418 +/// `count1` の最初の更新時のみ実行される
420 once(count1, (_) => print("$_ was changed once")); 419 once(count1, (_) => print("$_ was changed once"));
421 420
422 -/// Anti DDos - Called every time the user stops typing for 1 second, for example. 421 +/// DDoS攻撃対策に最適。たとえば、ユーザーが打鍵やクリックを止めて1秒後に実行など
423 debounce(count1, (_) => print("debouce$_"), time: Duration(seconds: 1)); 422 debounce(count1, (_) => print("debouce$_"), time: Duration(seconds: 1));
424 423
425 -/// Ignore all changes within 1 second. 424 +/// 1秒以内の連続更新はすべて無視して実行しない
426 interval(count1, (_) => print("interval $_"), time: Duration(seconds: 1)); 425 interval(count1, (_) => print("interval $_"), time: Duration(seconds: 1));
427 ``` 426 ```
428 427
429 -All workers (except `debounce` ) have a `condition` named parameter, which can be a `bool` or a callback that returns a `bool` .  
430 -This `condition` defines when the `callback` function executes. 428 +すべてのWorker(`debounce` 以外) は `condition` パラメーターを持ちます。`condition` は `bool` でも `bool` を返すコールバックでも構いません。
  429 +この `condition` が Worker のコールバックを実行するかどうかを決めています。
  430 +
  431 +また Worker は `Worker` インスタンスを返します。これは `dispose()` などを通じて Worker を破棄するときに使用します。
431 432
432 -All workers returns a `Worker` instance, that you can use to cancel ( via `dispose()` ) the worker.  
433 -  
434 433
435 * **`ever`** 434 * **`ever`**
436 435
437 - is called every time the _Rx_ variable emits a new value. 436 + は _Rx_ 変数が新しい値になるたびに呼ばれます。
438 437
439 * **`everAll`** 438 * **`everAll`**
440 439
441 - Much like `ever` , but it takes a `List` of _Rx_ values Called every time its variable is changed. That's it. 440 + `ever` とほぼ同じですが、_Rx_ 変数の `List` を受け取ります。いずれかの値が更新されれば、その更新後の値を受け取ってコールバックが実行されます。
442 441
443 * **`once`** 442 * **`once`**
444 443
445 -'once' is called only the first time the variable has been changed. 444 +変数が最初に更新されたときのみに呼ばれます。
446 445
447 * **`debounce`** 446 * **`debounce`**
448 447
449 -'debounce' is very useful in search functions, where you only want the API to be called when the user finishes typing. If the user types "Jonny", you will have 5 searches in the APIs, by the letter J, o, n, n, and y. With Get this does not happen, because you will have a "debounce" Worker that will only be triggered at the end of typing. 448 +'debounce' は検索機能などで導入するととても有益です。たとえば、ユーザーがタイピングを止めたときにのみAPIを呼び出したいときに使います。ユーザーが "Jonny" と入れたときに 5回も APIに問い合わせを行うのは避けたいですよね。Getなら "debounce" があるので大丈夫です。
450 449
451 * **`interval`** 450 * **`interval`**
452 451
453 -'interval' is different from the debouce. debouce if the user makes 1000 changes to a variable within 1 second, he will send only the last one after the stipulated timer (the default is 800 milliseconds). Interval will instead ignore all user actions for the stipulated period. If you send events for 1 minute, 1000 per second, debounce will only send you the last one, when the user stops strafing events. interval will deliver events every second, and if set to 3 seconds, it will deliver 20 events that minute. This is recommended to avoid abuse, in functions where the user can quickly click on something and get some advantage (imagine that the user can earn coins by clicking on something, if he clicked 300 times in the same minute, he would have 300 coins, using interval, you you can set a time frame for 3 seconds, and even then clicking 300 or a thousand times, the maximum he would get in 1 minute would be 20 coins, clicking 300 or 1 million times). The debounce is suitable for anti-DDos, for functions like search where each change to onChange would cause a query to your api. Debounce will wait for the user to stop typing the name, to make the request. If it were used in the coin scenario mentioned above, the user would only win 1 coin, because it is only executed, when the user "pauses" for the established time. 452 +`interval` は debounce とは異なります。ユーザーが1秒間に1000回変数に変更を加えた場合、debounceが一定期間経過後(デフォルトは800ミリ秒)に最後の変更イベントだけ送信するのに対して、intervalは代わりに一定期間の間のユーザーによるアクションをすべて無視します。intervalは1秒ごとにイベントを送信しており、3秒に設定した場合は1分間に20個のイベントを送信します。これはユーザーがキーやマウスを連打することで何かしらの報酬を得られる場合に、その悪用を避けるために使用できます(ユーザーが何かをクリックしてコインを獲得できるとします。たとえ何秒かかったとしても300回クリックすれば300枚のコインを得ることができてしまいます。intervalを使用してインターバルを3秒に設定した場合は、何回クリックしようが1分間で得られるコインの上限は20枚になります)。一方のdebounceはアンチDDosや、検索のように変更を加えるたびにonChangeからAPI問い合わせが発生するような機能に適しています。ユーザーが入力し終わるのを待ってリクエストを送信するのです。debounceを前述のコイン獲得のケースで使用した場合、ユーザーはコインを1枚しか獲得できません。これは指定した期間、ユーザーが動作を「一時停止」したときにのみ実行されるからです。
454 453
455 -* NOTE: Workers should always be used when starting a Controller or Class, so it should always be on onInit (recommended), Class constructor, or the initState of a StatefulWidget (this practice is not recommended in most cases, but it shouldn't have any side effects). 454 +* 注: Workerを使用する場合は、Controllerなどを起動するときに次のいずれかの方法で登録する必要があります。onInit(推奨)内、クラスのコンストラクタ、またはStatefulWidgetのinitState内(この方法は推奨しませんが、副作用はないはずです)。
456 455
457 -## Simple State Manager 456 +## 非リアクティブな状態管理
458 457
459 -Get has a state manager that is extremely light and easy, which does not use ChangeNotifier, will meet the need especially for those new to Flutter, and will not cause problems for large applications. 458 +GetはChangeNotifierを使わない軽量かつシンプルな状態管理機能を有しています。特にFlutterに慣れていない方のニーズを満たし、大規模なアプリケーションでも問題を起こすことがないと信じています。
460 459
461 -GetBuilder is aimed precisely at multiple state control. Imagine that you added 30 products to a cart, you click delete one, at the same time that the list is updated, the price is updated and the badge in the shopping cart is updated to a smaller number. This type of approach makes GetBuilder killer, because it groups states and changes them all at once without any "computational logic" for that. GetBuilder was created with this type of situation in mind, since for ephemeral change of state, you can use setState and you would not need a state manager for this. 460 +GetBuilderは複数の状態を扱う場面で使われることを想定して作られました。たとえばショッピングカートに30個の商品があるとします。そしてあなたが商品を一つ削除すると同時に、カートのリストが更新され、合計金額が更新され、アイテム数を示すバッジが更新されます。GetBuilderはこのようなユースケースに最適です。というのも、GetBuilderは状態をControllerで束ねてそのControllerに依存するすべてのWidgetを一度に更新させることができるからです。
462 461
463 -That way, if you want an individual controller, you can assign IDs for that, or use GetX. This is up to you, remembering that the more "individual" widgets you have, the more the performance of GetX will stand out, while the performance of GetBuilder should be superior, when there is multiple change of state. 462 +それらとは独立したControllerが必要な場合は、GetBuilderのidプロパティに専用IDを割り当てるか、GetXを使ってください。ケースバイケースですが、そのような「独立した」Widetが多いほど GetX() のパフォーマンスが際立ち、複数の状態変化がありそれに伴うWidgetの更新が多いほど GetBuilder() のパフォーマンスが勝ることを覚えておいてください。
464 463
465 -### Advantages 464 +### 利点
466 465
467 -1. Update only the required widgets. 466 +1. 必要なWidgetのみ更新される。
468 467
469 -2. Does not use changeNotifier, it is the state manager that uses less memory (close to 0mb). 468 +2. ChangeNotifierを使わず、メモリ使用量が少ない。
470 469
471 -3. Forget StatefulWidget! With Get you will never need it. With the other state managers, you will probably have to use a StatefulWidget to get the instance of your Provider, BLoC, MobX Controller, etc. But have you ever stopped to think that your appBar, your scaffold, and most of the widgets that are in your class are stateless? So why save the state of an entire class, if you can only save the state of the Widget that is stateful? Get solves that, too. Create a Stateless class, make everything stateless. If you need to update a single component, wrap it with GetBuilder, and its state will be maintained. 470 +3. StatefulWidgetのことはもう忘れましょう。Getでは必要ありません。他の状態管理ライブラリではStatefulWidgetを使用することがあるでしょう。しかしAppBarやScaffoldなどクラス内のほとんどのWidgetがStatelessであるにも関わらず、StatefulなWidgetの状態だけを保持する代わりに、クラス全体の状態を保持しているのはなぜでしょうか?Getならクラス全体をStatelessにすることができます。更新が必要なコンポーネントは GetBuilder などで囲むことで「状態」が保持されます。
472 471
473 -4. Organize your project for real! Controllers must not be in your UI, place your TextEditController, or any controller you use within your Controller class. 472 +4. プロジェクトを整理しましょう!ControllerはUIの中にあってはいけません。TextEditControllerなどの類はすべてControllerクラスに配置してしまいましょう。
474 473
475 -5. Do you need to trigger an event to update a widget as soon as it is rendered? GetBuilder has the property "initState", just like StatefulWidget, and you can call events from your controller, directly from it, no more events being placed in your initState. 474 +5. Widgetのレンダリングが開始されると同時にイベントを実行してWidgetを更新させる必要がありますか?GetBuilderにはStatefulWidgetと同様の「initState」プロパティがあり、そこからControllerのイベントを直接呼び出すことができます。initStateを使用する必要はもうありません。
476 475
477 -6. Do you need to trigger an action like closing streams, timers and etc? GetBuilder also has the dispose property, where you can call events as soon as that widget is destroyed. 476 +6. StreamやTimerのインスタンスを破棄したい場合はGetBuilderのdisposeプロパティを利用してください。Widgetが破棄されると同時にイベントを呼び出すことができます。
478 477
479 -7. Use streams only if necessary. You can use your StreamControllers inside your controller normally, and use StreamBuilder also normally, but remember, a stream reasonably consumes memory, reactive programming is beautiful, but you shouldn't abuse it. 30 streams open simultaneously can be worse than changeNotifier (and changeNotifier is very bad). 478 +7. GetXとStreamController / StreamBuilderを組み合わせるなどしてStreamを普通に使っていただいても問題ありませんが、必要なときに限って使うことをおすすめします。Streamのメモリ消費は適度であり、リアクティブプログラミングは美しいですが、たとえば30ものStreamを同時に立ち上げることを考えてみてください。これはChangeNotifierを使うよりもよくないことのように思います。
480 479
481 -8. Update widgets without spending ram for that. Get stores only the GetBuilder creator ID, and updates that GetBuilder when necessary. The memory consumption of the get ID storage in memory is very low even for thousands of GetBuilders. When you create a new GetBuilder, you are actually sharing the state of GetBuilder that has a creator ID. A new state is not created for each GetBuilder, which saves A LOT OF ram for large applications. Basically your application will be entirely Stateless, and the few Widgets that will be Stateful (within GetBuilder) will have a single state, and therefore updating one will update them all. The state is just one. 480 +8. 必要以上にRAMを使わずWidgetを更新します。GetはGetBuilderのクリエーターIDのみを保存し、必要に応じてGetBuilderを更新します。何千ものGetBuilderを作成したとしても、ID保存のためのメモリ消費量は非常に少ないです。GetBuilderを新規に作成するということは、実際にはクリエーターIDを持つ GetBuilder の状態を共有しているに過ぎないためです。GetBuilderごとに状態が新たに作成されるわけではないため、特に大規模なアプリケーションでは多くのRAMを節約できます。基本的にGetXで作成するアプリケーションは全体的にStatelessであり、いくつかのStatefulなWidget(GetBuilder内のWidget)は単一の状態を持っているため、一つを更新すればすべてが更新されます。
482 481
483 -9. Get is omniscient and in most cases it knows exactly the time to take a controller out of memory. You should not worry about when to dispose of a controller, Get knows the best time to do this. 482 +9. Getはアプリ全体の流れをよく把握しており、Controllerをメモリから破棄するタイミングを正確に知っています。実際の破棄はGetがやってくれるため、開発者が心配する必要はありません。
484 483
485 -### Usage 484 +### 使用例
486 485
487 ``` dart 486 ``` dart
488 -// Create controller class and extends GetxController 487 +// Controllerクラスを作成してGetxControllerを継承しましょう
489 class Controller extends GetxController { 488 class Controller extends GetxController {
490 int counter = 0; 489 int counter = 0;
491 void increment() { 490 void increment() {
492 counter++; 491 counter++;
493 - update(); // use update() to update counter variable on UI when increment be called 492 + update();
  493 + // increment 実行時にcounter変数に依存するUIを更新。
  494 + // GetBuilderを使うWidgetの場合はupdate()が必要。
494 } 495 }
495 } 496 }
496 -// On your Stateless/Stateful class, use GetBuilder to update Text when increment be called 497 +// ビュー側のクラスでGetBuilderを使ってcounter変数を組み込む
497 GetBuilder<Controller>( 498 GetBuilder<Controller>(
498 - init: Controller(), // INIT IT ONLY THE FIRST TIME 499 + init: Controller(), // 最初に使用するときのみ初期化
499 builder: (_) => Text( 500 builder: (_) => Text(
500 '${_.counter}', 501 '${_.counter}',
501 ), 502 ),
502 ) 503 )
503 -//Initialize your controller only the first time. The second time you are using ReBuilder for the same controller, do not use it again. Your controller will be automatically removed from memory as soon as the widget that marked it as 'init' is deployed. You don't have to worry about that, Get will do it automatically, just make sure you don't start the same controller twice. 504 +// Controllerの初期化は最初の1回だけ行ってください。同じControllerを再度 GetBuilder / GetX で使用する場合は初期化する必要はありません。コントローラは、それを「init」とマークしたウィジェットがデプロイされると同時に、自動的にメモリから削除されます。Getがすべて自動で行ってくれるので、何も心配することはありません。同じControllerを2つ立ち上げることがないよう、それだけご注意ください。
504 ``` 505 ```
505 506
506 -**Done!** 507 +**最後に**
507 508
508 -* You have already learned how to manage states with Get. 509 +* 以上、Getを使った状態管理の手法をご説明させていただきました。
509 510
510 -* Note: You may want a larger organization, and not use the init property. For that, you can create a class and extends Bindings class, and within it mention the controllers that will be created within that route. Controllers will not be created at that time, on the contrary, this is just a statement, so that the first time you use a Controller, Get will know where to look. Get will remain lazyLoad, and will continue to dispose Controllers when they are no longer needed. See the pub.dev example to see how it works. 511 +* 注: もっと柔軟に管理する手法として、initプロパティを使わない方法もあります。Bindingsを継承したクラスを作成し、dependenciesメソッドをoverrideしてその中でGet.put()でControllerを注入してください(複数可)。このクラスとUI側のクラスを紐づけることでControllerをそのRoute内で使用できます。そしてそのControllerを初めて使用するとき、Getはdependencies内を見て初期化を実行してくれます。このlazy(遅延、消極的)ロードを維持しつつ、不要になったControllerは破棄し続けます。具体的な仕組みについてはpub.devの例をご参照ください。
511 512
512 -If you navigate many routes and need data that was in your previously used controller, you just need to use GetBuilder Again (with no init): 513 +Routeを移動して以前使用したControllerのデータが必要になった場合は、再度GetBuilderを使用してください。initする必要はありません。
513 514
514 ``` dart 515 ``` dart
515 class OtherClass extends StatelessWidget { 516 class OtherClass extends StatelessWidget {
@@ -526,16 +527,16 @@ class OtherClass extends StatelessWidget { @@ -526,16 +527,16 @@ class OtherClass extends StatelessWidget {
526 527
527 ``` 528 ```
528 529
529 -If you need to use your controller in many other places, and outside of GetBuilder, just create a get in your controller and have it easily. (or use `Get.find<Controller>()` ) 530 +GetBuilderの外でControllerを使用する場合は、Controller内にgetterを作成しておくと便利です。Controller.to で呼び出しましょう。(もしくは `Get.find<Controller>()` を使うのもありです)
530 531
531 ``` dart 532 ``` dart
532 class Controller extends GetxController { 533 class Controller extends GetxController {
533 534
534 - /// You do not need that. I recommend using it just for ease of syntax.  
535 - /// with static method: Controller.to.increment();  
536 - /// with no static method: Get.find<Controller>().increment();  
537 - /// There is no difference in performance, nor any side effect of using either syntax. Only one does not need the type, and the other the IDE will autocomplete it.  
538 - static Controller get to => Get.find(); // add this line 535 + /// 記述量を省くためにstaticメソッドにすることをおすすめします。
  536 + /// staticメソッド使う場合 → Controller.to.increment();
  537 + /// 使わない場合 → Get.find<Controller>().increment();
  538 + /// どちらを使ってもパフォーマンスに影響があったり副作用が出たりはしません。前者は型の指定が不要という違いがあるだけです
  539 + static Controller get to => Get.find(); // これを追加
539 540
540 int counter = 0; 541 int counter = 0;
541 void increment() { 542 void increment() {
@@ -545,35 +546,34 @@ class Controller extends GetxController { @@ -545,35 +546,34 @@ class Controller extends GetxController {
545 } 546 }
546 ``` 547 ```
547 548
548 -And then you can access your controller directly, that way: 549 +これで以下のようにControllerに直接アクセスできます。
549 550
550 ``` dart 551 ``` dart
551 FloatingActionButton( 552 FloatingActionButton(
552 onPressed: () { 553 onPressed: () {
553 Controller.to.increment(), 554 Controller.to.increment(),
554 - } // This is incredibly simple! 555 + } // とっても簡単ですね!
555 child: Text("${Controller.to.counter}"), 556 child: Text("${Controller.to.counter}"),
556 ), 557 ),
557 ``` 558 ```
558 559
559 -When you press FloatingActionButton, all widgets that are listening to the 'counter' variable will be updated automatically. 560 +FloatingActionButton を押すと counter変数 に依存するWidgetがすべて自動的に更新されます。
560 561
561 -### How it handles controllers 562 +### Controllerインスタンスの扱い
562 563
563 -Let's say we have this: 564 +次のような画面の流れがあるとします。
564 565
565 - `Class a => Class B (has controller X) => Class C (has controller X)` 566 + `画面A => 画面B (Controller X を使用) => 画面C (Controller X を使用)`
566 567
567 -In class A the controller is not yet in memory, because you have not used it yet (Get is lazyLoad). In class B you used the controller, and it entered memory. In class C you used the same controller as in class B, Get will share the state of controller B with controller C, and the same controller is still in memory. If you close screen C and screen B, Get will automatically take controller X out of memory and free up resources, because Class a is not using the controller. If you navigate to B again, controller X will enter memory again, if instead of going to class C, you return to class A again, Get will take the controller out of memory in the same way. If class C didn't use the controller, and you took class B out of memory, no class would be using controller X and likewise it would be disposed of. The only exception that can mess with Get, is if you remove B from the route unexpectedly, and try to use the controller in C. In this case, the creator ID of the controller that was in B was deleted, and Get was programmed to remove it from memory every controller that has no creator ID. If you intend to do this, add the "autoRemove: false" flag to class B's GetBuilder and use adoptID = true; in class C's GetBuilder. 568 +画面Aの段階ではまだ未使用なので、Controllerはメモリにありません(Getは基本lazyロードなので)。画面Bに遷移すると、Controllerがメモリ内に保存されます。画面Cでは画面Bと同じControllerを使用しているため、GetはBとCでControllerの状態を共有し、同じControllerがメモリ内に引き続きいることになります。画面Cを閉じてさらに画面Bを閉じ、画面Aに戻ったとしましょう。そこではControllerが使われていないため、GetはControllerをメモリから出してリソースを解放します。そこで再度画面Bに遷移すると、Controllerは再度メモリに保存されます。そして今度は画面Cに行かずに画面Aに戻ります。Getは同様にControllerをメモリから破棄してくれます。また、仮に画面CがControllerを使っておらず画面Cにいたとして、画面BをRouteスタックから削除したとしましょう。するとControllerを使用している画面(クラス)はなくなりますので、同様にメモリから破棄されます。Getが正常動作しないと考えられる唯一の例外は、画面Cにいるときに画面Bを誤ってRouteスタックから削除してしまい、Controllerの使用を試みたときです。この場合は、画面Bで作成されたControllerのクリエーターIDが削除されてしまったことが原因です(GetはクリエーターIDのないControllerはメモリから破棄するようプログラムされています)。もし意図があってこの事例に対応したい場合は、画面BのGetBuilderに "autoRemove: false" フラグを追加した上で、CクラスのGetBuilderに "adoptID: true" を追加してください。
568 569
569 -### You won't need StatefulWidgets anymore 570 +### StatefulWidgetsはもういらない
570 571
571 -Using StatefulWidgets means storing the state of entire screens unnecessarily, even because if you need to minimally rebuild a widget, you will embed it in a Consumer/Observer/BlocProvider/GetBuilder/GetX/Obx, which will be another StatefulWidget.  
572 -The StatefulWidget class is a class larger than StatelessWidget, which will allocate more RAM, and this may not make a significant difference between one or two classes, but it will most certainly do when you have 100 of them!  
573 -Unless you need to use a mixin, like TickerProviderStateMixin, it will be totally unnecessary to use a StatefulWidget with Get. 572 +StatefulWidgetsを使用すると、画面全体の状態を不必要に保存することになります。ウィジェットを最小限に再構築する必要がある場合は、Consumer/Observer/BlocProvider/GetBuilder/GetX/Obxの中に埋め込むことになりますが、それは別のStatefulWidgetになります。
  573 +StatefulWidgetはStatelessWidgetよりも多くのRAMが割り当てられます。これは1つや2つのStatefulWidgetでは大きな違いは産まないかもしれませんが、それが100もあった場合は確実に違いが出ます。
  574 +TickerProviderStateMixinのようなMixinを使用する必要がない限り、GetでStatefulWidgetを使用する必要はありません。
574 575
575 -You can call all methods of a StatefulWidget directly from a GetBuilder.  
576 -If you need to call initState() or dispose() method for example, you can call them directly; 576 +たとえばinitState()やdispose()メソッドなど、StatefulWidgetのメソッドをGetBuilderから直接呼び出すことも可能です。
577 577
578 ``` dart 578 ``` dart
579 GetBuilder<Controller>( 579 GetBuilder<Controller>(
@@ -583,7 +583,7 @@ GetBuilder<Controller>( @@ -583,7 +583,7 @@ GetBuilder<Controller>(
583 ), 583 ),
584 ``` 584 ```
585 585
586 -A much better approach than this is to use the onInit() and onClose() method directly from your controller. 586 +しかし、これよりもベターなアプローチはControllerの中で直接 onInit() や onClose() メソッドを呼び出すことです。
587 587
588 ``` dart 588 ``` dart
589 @override 589 @override
@@ -593,24 +593,23 @@ void onInit() { @@ -593,24 +593,23 @@ void onInit() {
593 } 593 }
594 ``` 594 ```
595 595
596 -* NOTE: If you want to start a method at the moment the controller is called for the first time, you DON'T NEED to use constructors for this, in fact, using a performance-oriented package like Get, this borders on bad practice, because it deviates from the logic in which the controllers are created or allocated (if you create an instance of this controller, the constructor will be called immediately, you will be populating a controller before it is even used, you are allocating memory without it being in use, this definitely hurts the principles of this library). The onInit() methods; and onClose(); were created for this, they will be called when the Controller is created, or used for the first time, depending on whether you are using Get.lazyPut or not. If you want, for example, to make a call to your API to populate data, you can forget about the old-fashioned method of initState/dispose, just start your call to the api in onInit, and if you need to execute any command like closing streams, use the onClose() for that. 596 +* 注: コンストラクタを通じてControllerを立ち上げる必要はありません。このようなプラクティスは、パフォーマンス重視であるGetのControllerの作成や割り当ての原理、考え方から外れてしまいます(コンストラクタ経由でインスタンスを作成すれば、実際に使用される前の段階でControllerを生成し、メモリを割り当てることになります)。onInit() と onClose() メソッドはこのために作られたもので、Controllerのインスタンスが作成されたとき、または初めて使用されたときに呼び出されます(Get.lazyPutを使用しているか否か次第)。たとえば、データを取得するためにAPIを呼び出したい場合は initState/dispose の代わりに onInit() を使用し、Streamを閉じるなどのコマンドを実行する必要がある場合は onClose() を使用してください。
597 597
598 -### Why it exists 598 +### Getの目的
599 599
600 -The purpose of this package is precisely to give you a complete solution for navigation of routes, management of dependencies and states, using the least possible dependencies, with a high degree of decoupling. Get engages all high and low level Flutter APIs within itself, to ensure that you work with the least possible coupling. We centralize everything in a single package, to ensure that you don't have any kind of coupling in your project. That way, you can put only widgets in your view, and leave the part of your team that works with the business logic free, to work with the business logic without depending on any element of the View. This provides a much cleaner working environment, so that part of your team works only with widgets, without worrying about sending data to your controller, and part of your team works only with the business logic in its breadth, without depending on no element of the view. 600 +このパッケージの目的は、Routeのナビゲーション、依存オブジェクトと状態の管理のための完全なソリューションを、開発者が外部パッケージに極力依存せずに済むような形で提供し、高度なコード分離性(デカップリング)を実現することです。それを確実なものとするため、Getはあらゆる高レベルおよび低レベルのFlutter APIを取り込んでいます。これによりビューとロジックを切り分けることが容易になり、UIチームにはWidgetの構築に集中してもらい、ビジネスロジック担当チームにはロジックに集中してもらうことができます。Getを使うことでよりクリーンな作業環境を構築することができるのです。
601 601
602 -So to simplify this:  
603 -You don't need to call methods in initState and send them by parameter to your controller, nor use your controller constructor for that, you have the onInit() method that is called at the right time for you to start your services.  
604 -You do not need to call the device, you have the onClose() method that will be called at the exact moment when your controller is no longer needed and will be removed from memory. That way, leave views for widgets only, refrain from any kind of business logic from it. 602 +要するに、initState内でメソッドを呼び出してパラメーターを通じてControllerにデータを送信する必要も、そのためにControllerのコンストラクタを使用する必要もありません。Getには必要なタイミングでサービスを呼び出してくれう onInit() メソッドがあります。
  603 +Controllerが不要になれば、onClose() メソッドがジャストなタイミングでメモリから破棄してくれます。これにより、ビューとビジネスロジックを分離することができるのです。
605 604
606 -Do not call a dispose method inside GetxController, it will not do anything, remember that the controller is not a Widget, you should not "dispose" it, and it will be automatically and intelligently removed from memory by Get. If you used any stream on it and want to close it, just insert it into the close method. Example: 605 +GetxController 内に dispose() メソッドがあっても何も起こらないので記述しないでください。ControllerはWidgetではないので「dispose」できません。たとえばController内でStreamを使用していてそれを閉じたい場合は、以下のように onClose() メソッドにコードを記述してください。
607 606
608 ``` dart 607 ``` dart
609 class Controller extends GetxController { 608 class Controller extends GetxController {
610 StreamController<User> user = StreamController<User>(); 609 StreamController<User> user = StreamController<User>();
611 StreamController<String> name = StreamController<String>(); 610 StreamController<String> name = StreamController<String>();
612 611
613 - /// close stream = onClose method, not dispose. 612 + /// Streamを閉じる場合は dispose() ではなく onClose()
614 @override 613 @override
615 void onClose() { 614 void onClose() {
616 user.close(); 615 user.close();
@@ -620,132 +619,131 @@ class Controller extends GetxController { @@ -620,132 +619,131 @@ class Controller extends GetxController {
620 } 619 }
621 ``` 620 ```
622 621
623 -Controller life cycle: 622 +Controllerのライフサイクルについて。
624 623
625 -* onInit() where it is created.  
626 -* onClose() where it is closed to make any changes in preparation for the delete method  
627 -* deleted: you do not have access to this API because it is literally removing the controller from memory. It is literally deleted, without leaving any trace. 624 +* onInit() はControllerが作成されたタイミングで実行されます。
  625 +* onClose() は onDelete() メソッドが実行される直前のタイミングで実行されます。
  626 +* Controllerが削除されるとそのAPIにアクセスすることはできません。文字通りメモリからの削除だからです。削除のトレースログも残りません。
628 627
629 -### Other ways of using it 628 +### Controllerの様々な使用方法
630 629
631 -You can use Controller instance directly on GetBuilder value: 630 +ControllerインスタンスはGetBuilderのvalueを通じて使用することができます。
632 631
633 ``` dart 632 ``` dart
634 GetBuilder<Controller>( 633 GetBuilder<Controller>(
635 init: Controller(), 634 init: Controller(),
636 builder: (value) => Text( 635 builder: (value) => Text(
637 - '${value.counter}', //here 636 + '${value.counter}', // ここ
638 ), 637 ),
639 ), 638 ),
640 ``` 639 ```
641 640
642 -You may also need an instance of your controller outside of your GetBuilder, and you can use these approaches to achieve this: 641 +GetBuilderの外でControllerインスタンスを使う場合は、このアプローチをおすすめします。
643 642
644 ``` dart 643 ``` dart
645 class Controller extends GetxController { 644 class Controller extends GetxController {
646 static Controller get to => Get.find(); 645 static Controller get to => Get.find();
647 [...] 646 [...]
648 } 647 }
649 -// on you view:  
650 -GetBuilder<Controller>(  
651 - init: Controller(), // use it only first time on each controller 648 +// ビュー側で
  649 +GetBuilder<Controller>(
  650 + init: Controller(), // 最初に使うときだけ必要
652 builder: (_) => Text( 651 builder: (_) => Text(
653 - '${Controller.to.counter}', //here 652 + '${Controller.to.counter}', // ここ
654 ) 653 )
655 ), 654 ),
656 ``` 655 ```
657 656
658 -or 657 +もしくは
659 658
660 ``` dart 659 ``` dart
661 class Controller extends GetxController { 660 class Controller extends GetxController {
662 - // static Controller get to => Get.find(); // with no static get 661 + // static get を省き、
663 [...] 662 [...]
664 } 663 }
665 -// on stateful/stateless class  
666 -GetBuilder<Controller>(  
667 - init: Controller(), // use it only first time on each controller 664 +// ビュー側で
  665 +GetBuilder<Controller>(
  666 + init: Controller(), // 最初に使うときだけ必要
668 builder: (_) => Text( 667 builder: (_) => Text(
669 - '${Get.find<Controller>().counter}', //here 668 + '${Get.find<Controller>().counter}', // ここ
670 ), 669 ),
671 ), 670 ),
672 ``` 671 ```
673 672
674 -* You can use "non-canonical" approaches to do this. If you are using some other dependency manager, like get_it, modular, etc., and just want to deliver the controller instance, you can do this: 673 +* get_it や modular など他の依存オブジェクト管理ライブラリを使用しているため、単にControllerのインスタンスを渡したいだけの場合は、このような「非正規」な方法もあります。
675 674
676 ``` dart 675 ``` dart
677 Controller controller = Controller(); 676 Controller controller = Controller();
678 [...] 677 [...]
679 GetBuilder<Controller>( 678 GetBuilder<Controller>(
680 - init: controller, //here 679 + init: controller, // ここ
681 builder: (_) => Text( 680 builder: (_) => Text(
682 - '${controller.counter}', // here 681 + '${controller.counter}', // ここ
683 ), 682 ),
684 ), 683 ),
685 684
686 ``` 685 ```
687 686
688 -### Unique IDs 687 +### ユニークIDの設定
689 688
690 -If you want to refine a widget's update control with GetBuilder, you can assign them unique IDs: 689 +GetBuilderを使ってWidgetの更新をコントロールしたい場合は、このようにユニークIDを振ってください。
691 690
692 ``` dart 691 ``` dart
693 GetBuilder<Controller>( 692 GetBuilder<Controller>(
694 id: 'text' 693 id: 'text'
695 - init: Controller(), // use it only first time on each controller 694 + init: Controller(), // 最初に使うときだけ必要
696 builder: (_) => Text( 695 builder: (_) => Text(
697 - '${Get.find<Controller>().counter}', //here 696 + '${Get.find<Controller>().counter}', // ここ
698 ), 697 ),
699 ), 698 ),
700 ``` 699 ```
701 700
702 -And update it this form: 701 +そして以下のようにWidgetを更新します。
703 702
704 ``` dart 703 ``` dart
705 update(['text']); 704 update(['text']);
706 ``` 705 ```
707 706
708 -You can also impose conditions for the update: 707 +さらに更新に条件を設けることができます。
709 708
710 ``` dart 709 ``` dart
711 update(['text'], counter < 10); 710 update(['text'], counter < 10);
712 ``` 711 ```
713 712
714 -GetX does this automatically and only reconstructs the widget that uses the exact variable that was changed, if you change a variable to the same as the previous one and that does not imply a change of state , GetX will not rebuild the widget to save memory and CPU cycles (3 is being displayed on the screen, and you change the variable to 3 again. In most state managers, this will cause a new rebuild, but with GetX the widget will only is rebuilt again, if in fact his state has changed). 713 +GetXはこの更新を自動で行ってくれます。指定したIDを持ち、その変数に依存するWidgetのみを更新します。また変数を前の値と同じ値に変更しても、それが状態の変化を意味しない場合はメモリとCPUサイクルを節約するためにWidgetを更新しません (画面に 3 が表示されているときに、変数を再び 3 に変更したとします。このような場合にWidgetを更新する状態管理ソリューションも存在しますが、GetXでは実際に状態が変更された場合にのみ更新されます)。
715 714
716 -## Mixing the two state managers 715 +## 状態管理ソリューションを混在させる
717 716
718 -Some people opened a feature request, as they wanted to use only one type of reactive variable, and the other mechanics, and needed to insert an Obx into a GetBuilder for this. Thinking about it MixinBuilder was created. It allows both reactive changes by changing ".obs" variables, and mechanical updates via update(). However, of the 4 widgets he is the one that consumes the most resources, since in addition to having a Subscription to receive change events from his children, he subscribes to the update method of his controller. 717 +MixinBuilderはObxとGetBuilderを併用したいというリクエストから発想して作られました。これは ".obs" 変数の変更によるリアクティブな更新と、update() メソッドによるメカニカルな更新の両方を混在可能にします。ただし、GetBuiler / GetX / Obx / MixinBuilder の4つの中で最もリソースを消費するWidgetです。というのも、Widgetからのイベントを検知するためのSubscriptionに加えて、Controller自身のupdateメソッドも購読する必要があるからです。
719 718
720 -Extending GetxController is important, as they have life cycles, and can "start" and "end" events in their onInit() and onClose() methods. You can use any class for this, but I strongly recommend you use the GetxController class to place your variables, whether they are observable or not. 719 +MixinBuilderに使用するControllerクラスには、変数を `.obs`(Observable)とするかどうかに関わらず、GetxControllerを継承したものを使用してください。GetxControllerにはライフサイクルがあり、onInit() および onClose() メソッドでイベントを「開始」したり「終了」したりすることができます。
721 720
722 ## StateMixin 721 ## StateMixin
723 722
724 -Another way to handle your `UI` state is use the `StateMixin<T>` .  
725 -To implement it, use the `with` to add the `StateMixin<T>`  
726 -to your controller which allows a T model. 723 +`StateMixin<T>` を使うことでさらに `UI` の「状態」を便利に扱うことができます。
  724 +`with` を使って `StateMixin<T>` をControllerにミックスインしてください。Tにはモデルのクラス名が入ります。
727 725
728 ``` dart 726 ``` dart
729 class Controller extends GetController with StateMixin<User>{} 727 class Controller extends GetController with StateMixin<User>{}
730 ``` 728 ```
731 729
732 -The `change()` method change the State whenever we want.  
733 -Just pass the data and the status in this way: 730 +状態を変更するには `change()` メソッドを使ってください。
  731 +パラメーターにはビューに渡すデータと「状態」をセットします。
734 732
735 ```dart 733 ```dart
736 change(data, status: RxStatus.success()); 734 change(data, status: RxStatus.success());
737 ``` 735 ```
738 736
739 -RxStatus allow these status: 737 +RxStatus の「状態」は以下の4つです。
740 738
741 ``` dart 739 ``` dart
742 -RxStatus.loading();  
743 -RxStatus.success();  
744 -RxStatus.empty();  
745 -RxStatus.error('message'); 740 +RxStatus.loading(); // ロード中
  741 +RxStatus.success(); // ロード成功
  742 +RxStatus.empty(); // データが空
  743 +RxStatus.error('message'); // エラー
746 ``` 744 ```
747 745
748 -To represent it in the UI, use: 746 +それぞれの「状態」をUIで表すには以下のようにします。
749 747
750 ```dart 748 ```dart
751 class OtherClass extends GetView<Controller> { 749 class OtherClass extends GetView<Controller> {
@@ -755,35 +753,35 @@ class OtherClass extends GetView<Controller> { @@ -755,35 +753,35 @@ class OtherClass extends GetView<Controller> {
755 753
756 body: controller.obx( 754 body: controller.obx(
757 (state)=>Text(state.name), 755 (state)=>Text(state.name),
758 -  
759 - // here you can put your custom loading indicator, but  
760 - // by default would be Center(child:CircularProgressIndicator()) 756 +
  757 + // ここはカスタムのロードインジケーターでも可能ですが、
  758 + // デフォルトは Center(child:CircularProgressIndicator())
761 onLoading: CustomLoadingIndicator(), 759 onLoading: CustomLoadingIndicator(),
762 onEmpty: Text('No data found'), 760 onEmpty: Text('No data found'),
763 761
764 - // here also you can set your own error widget, but by  
765 - // default will be an Center(child:Text(error)) 762 + // ここもカスタムのエラーWidgetでも構いませんが、
  763 + // デフォルトは Center(child:Text(error))
766 onError: (error)=>Text(error), 764 onError: (error)=>Text(error),
767 ), 765 ),
768 ); 766 );
769 } 767 }
770 ``` 768 ```
771 769
772 -## GetBuilder vs GetX vs Obx vs MixinBuilder 770 +## GetBuilder VS GetX VS Obx VS MixinBuilder
773 771
774 -In a decade working with programming I was able to learn some valuable lessons. 772 +私は10年間プログラミングに携わってきて、いくつか貴重な教訓を得ることができました。
775 773
776 -My first contact with reactive programming was so "wow, this is incredible" and in fact reactive programming is incredible.  
777 -However, it is not suitable for all situations. Often all you need is to change the state of 2 or 3 widgets at the same time, or an ephemeral change of state, in which case reactive programming is not bad, but it is not appropriate. 774 +リアクティブプログラミングに初めて触れたとき、「おお、これはすごい」と感嘆せずにはいられませんでしたし、実際にすごいものでした。
  775 +しかし、リアクティブプログラミングはすべての状況に適しているわけではありません。多くの場合、必要なのは2,3のWidgetの状態を同時に更新すること、またはローカルでの一時的な状態の変更であり、これらの場合はリアクティブである必要はありません。
778 776
779 -Reactive programming has a higher RAM consumption that can be compensated for by the individual workflow, which will ensure that only one widget is rebuilt and when necessary, but creating a list with 80 objects, each with several streams is not a good one idea. Open the dart inspect and check how much a StreamBuilder consumes, and you'll understand what I'm trying to tell you. 777 +リアクティブプログラミングのRAM消費量の多さは、必要なときだけ、かつ1つのWidgetだけ同時に更新するようすることである程度補うことができます。ただ、たとえば80ものオブジェクトを持つリストがあったとして、それぞれが複数のStreamを持つのは得策ではありません。Dartのインスペクターを開いて、StreamBuilderがどれだけRAMを消費しているか見てみてください。私が伝えたいことを理解してもらえると思います。
780 778
781 -With that in mind, I created the simple state manager. It is simple, and that is exactly what you should demand from it: updating state in blocks in a simple way, and in the most economical way. 779 +そのことを念頭に私はシンプルな状態管理ソリューションを作りました。このシンプルさに期待することは、リソース面で経済的である点、Widget単位ではなくブロック単位で状態を更新できる点であるべきです。
782 780
783 -GetBuilder is very economical in RAM, and there is hardly a more economical approach than him (at least I can't imagine one, if it exists, please let us know). 781 +GetBuilderはRAM消費の面で最も経済的なソリューションだと信じています(もしあれば、ぜひ教えてください)。
784 782
785 -However, GetBuilder is still a mechanical state manager, you need to call update() just like you would need to call Provider's notifyListeners(). 783 +しかし、GetBuilderは依然として update() により更新がかかるスタイルのメカニカルな状態管理ソリューションであり、notifyListeners() と呼び出し回数は変わりありません。
786 784
787 -There are other situations where reactive programming is really interesting, and not working with it is the same as reinventing the wheel. With that in mind, GetX was created to provide everything that is most modern and advanced in a state manager. It updates only what is necessary and when necessary, if you have an error and send 300 state changes simultaneously, GetX will filter and update the screen only if the state actually changes. 785 +一方で、ここでリアクティブプログラミングを使わないのは車輪の再発明なんじゃないかと思えるような状況もあります。この点を考慮して、GetX() は先進的な状態管理の手法を提供するために作られました。必要なものを必要なときだけ更新し、エラーが発生してユーザーが300ものイベントを同時に送信したとしても、GetX() は状態の変化をフィルタリングして画面を更新してくれます。
788 786
789 -GetX is still more economical than any other reactive state manager, but it consumes a little more RAM than GetBuilder. Thinking about it and aiming to maximize the consumption of resources that Obx was created. Unlike GetX and GetBuilder, you will not be able to initialize a controller inside an Obx, it is just a Widget with a StreamSubscription that receives change events from your children, that's all. It is more economical than GetX, but loses to GetBuilder, which was to be expected, since it is reactive, and GetBuilder has the most simplistic approach that exists, of storing a widget's hashcode and its StateSetter. With Obx you don't need to write your controller type, and you can hear the change from multiple different controllers, but it needs to be initialized before, either using the example approach at the beginning of this readme, or using the Bindings class. 787 +GetX() は他のリアクティブな状態管理ソリューションに比べて経済的であることに変わりはありませんが、GetBuilder() よりは少しだけ多くのRAMを消費します。その点を考慮し、リソース消費を最大限活かすことを目指して Obx() は開発されました。GetX() や GetBuilder() と異なり、Obx() の中でControllerを初期化することはできません。Obx() は、子Widgetからの更新イベントを受け取る Stream購読Widgetでしかありません。GetX() よりは経済的ですが、GetBuilder() には負けます。GetBuilder() はWidgetのハッシュ値と状態のsetterを保持しているだけなので、これはある意味当然です。Obx() はControllerの型を指定する必要がなく、複数の異なるコントローラからの変更を聞くことができます。ただし、Obx() の外かBindingsで事前にControllerを初期化しておく必要があります。