SlideShare ist ein Scribd-Unternehmen logo
1 von 29
Downloaden Sie, um offline zu lesen
Pin-point rebuildable and
non-rebuild custom widget
GDG meetup in Kyoto
2019/02/10 at Furyu
robo
Self-introduction
Name
robo (兼高理恵)
Favorite things
mobile computer
My work
From application design to implementation
2
We received Service Partner of the Year - Japan
from Google!
Building a better cloud with our partners at Next ‘18
https://blog.google/products/google-cloud/building-a-better-cloud-with-our-partners-at-next-18/
Pin-point rebuildable
and non-rebuild custom widget
ピンポイントで再構築可能と再構築不可なカスタムウィジェット
In this session, I will introduce my custom widgets
that 'RebuildableWidget' and 'ConstantWidget'.
自作の 'RebuildableWidget'と 'ConstantWidget' 
カスタムウィジェットについて紹介します。
Basics of creating a page display of Flutter
In Flutter, everything is a widget.
Flutter のページ表示作成の基本 
Flutterでは、全てが Widget です。
In Flutter, all UI display and essential functions of the
application are defined in Widget's tree structure.
and
The contents of the page display of Flutter is defined by the
tree structure of the UI parts with Widget for page display.
Flutterでは、アプリの全ての UI表示および必須機能を Widget のツリー構造で定義します。
ページ表示の内容は、ページ表示用の Widget での UIパーツ のツリー構造で定義します。
To create an updatable page view with Flutter,
use the StatefulWidget class.
Flutterで、更新可能なページ表示を作成するには、 StatefulWidget クラスを使います。
StatefulWidget has
arbitrary invariant information (class field),
variable information (class field),
and build(BuildContext context) method
for building page display contents.
StatefulWidget は、任意の不変情報 (クラス フィールド)と可変情報(クラスフィールド)と、
ページ表示内容を構築する build(BuildContext context) メソッドを持っています。
The build(context) method is executed to reflect invariant
information and variable information
when StatefulWidget is newly created or
when the setState(void Function () f) method is executed,
and the screen display is re-displayed it.
build(context) メソッドは、
StatefulWidget が新規生成されたか、 setState(void Function() f) が実行されると、
不変情報と可変情報を反映するために実行されて、画面表示が再構築されます。
これは、Flutter の代表的なカウンターアプリのメインページの表示です。
ページ表示内容は、 MyHomePage Widget で定義されています。
This is the display of the main page of
Flutter's typical counter application.
The page display content of the counter
application is defined by
MyHomePage Widget.
ページ表示内容の UIパーツのツリー構造 の定義は、
左のようになっています。
The definition of the tree structure of
the UI parts of the page display content
is as shown on the left.
build(context) {
return
 Scaffold(
  appBar: AppBar(
   Icon,
   Text
   )
  body: Container(
   Columen([
   Text, // message
   Text, // counter
   ]),
    )
  floatingActionButton: FAB(
   Icon,
   )
 );
}
ページ表示用 Widget の setState(f) を実行すると、build(context)が実行され、
ページ表示用の Widget のツリーの 各ノードである 
全 UIパーツ Widget が再生成されます。
これによりページ表示の外観は、可変情報である カウンタ値 の 
最新の内容が反映された外観に更新されます。
When setState(f) of the page display Widget is
executed, build(context) is executed and all the UI
parts widget which is each node of Widget's tree for
page display are regenerated.
As a result, the appearance of the page display is
updated to the appearance reflecting the latest
contents of the counter value which is variable
information.
The thing to note is that when you execute setState(f),
all widgets of UI widget for page display
will be regenerated.
注意しなくてはならないことは、setState(f) を実行すると、
ページ表示用の 全 UIパーツ Widget が再生成されることです。
The display appearance is updated only for
the UI part of the counter value,
but all UI widgets of the page display widget
are regenerated!
表示外観が更新されるのは、カウンタ値 の UIパーツだけですが、
ページ表示用の全ての UIパーツ Widget が再生成されてしまうのです。
これは、UIパーツのウィジェットの再生成で発生するフローをログ出力させたものです。
This is a log output of the flow generated
by the regeneration of the widget of the UI parts.
When you execute setState(f) of MyHomePage,
build related processing is executed so much.
MyHomePage の setState(f) を実行させると、
こんなにもビルド関連の処理が実行されてしまうのです。
How can we update only the UI part of the counter value?
カウンタ値の UIパーツだけを更新するには、どうしたら良いのでしょう。
Pinpoint display update idea
Since setState(f) executes
all the UI widgets of the page display widget,
it is only necessary to create a custom page display widget
having only the UI part of the counter value in the tree.
ピンポイント表示更新のアイディア
setState(f) は、ページ表示用 Widget の 全ての UIパーツ Widget を実行するのだから、
ツリーにカウンタ値 の UIパーツだけを持つカスタムなページ表示用 Widget を作れば 
良いことになります。
Then, how can you make sure that the display contents
do not change (do not regenerate) the UI parts widget
of immutable tree from the initial display?
それでは、表示内容が初期表示から不変のツリーの UIパーツ Widget を 
変更させない(再生成させない)ようにするには、どうしたら良いのでしょうか。
Pinpoint display no-update idea
For 'Performance considerations'
in the reference of the StatefulWidget class,
there are cases where regeneration of widget
does not occur if subtree without display change
returns cache value.
ピンポイント表示無更新のアイディア
StatefulWidget class のリファレンスの Performance considerations には、
キャッシュ値を返すようにすれば Widget の再生成が発生しないとあります。
これが使えそうです。
Reference: StatefulWidget class #Performance considerations
https://docs.flutter.io/flutter/widgets/StatefulWidget-class.html#performance-considerations
> If a subtree does not change, cache the widget that represents
> that subtree and re-use it each time it can be used.
> It is massively more efficient for a widget to be re-used
> than for a new (but identically-configured) widget to be created.
> Factoring out the stateful part into a widget
> that takes a child argument is a common way of doing this.
This seems to work.
Initial display object cache experiment
(I am sorry, but there is no slide for demonstration.)
初期表示オブジェクトのキャッシュ実験
(ごめんなさい実演のためスライドはありません )
So, there is a custom widget here!
(Graham Kerr's The Galloping Gourmet method)
では、こちらに出来上がったカスタムウィジェットがあります。
(グラハム・カー 世界の料理ショー メソッド)
Pin-point rebuildable and non-rebuild custom widget
To redraw RebuildableWidget arbitrarily,
set GlobalKey. Then let the event handler
execute the rebuild() method.
RebuildableWidget specifies the tree that you want
the builder property to display and update.
ConstantWidget specifies a tree that the builder
property does not display and update.
RebuildableWidget arbitrarily regenerates (display update)
child widgets using rebuild() method.
ConstnatWidget is a widget that does not allow rendering
of child widgets when regenerated.
これは、UIパーツのウィジェットの再生成で発生するフローをログ出力させたものです。
オリジナルの半分以下のフローで再描画できています。
This is a log output of the flow generated
by the regeneration of the widget of the UI parts.
Redrawing is possible with less than half of original flow.
The source of the custom widget will be here.
カスタムウィジェットのソースは、こちらになります。
https://github.com/cch-robo/basic_strategy_of_state_propagation_in_Flutter/blob/
master/lib/src/base/custom_widgets.dart
In addition, please refer to the session slide
and github sample of DroidKaigi 2019 which
became the basis of the announcement too.
併せて、発表のもとになった 
DroidKaigi 2019 のセッションスライドと github サンプルも参照ください。
Basic Strategy of State Propagation and Access Restriction in Flutter
https://www.slideshare.net/cch-robo/flutterwidget-130879555
cch-robo/basic_strategy_of_state_propagation_in_Flutter
https://github.com/cch-robo/basic_strategy_of_state_propagation_in_Flutter
thank you for your attention.
ご清聴、ありがとうございました。

Weitere ähnliche Inhalte

Was ist angesagt?

ARコンテンツ作成勉強会:UnityとVuforiaではじめるAR [主要部分]
ARコンテンツ作成勉強会:UnityとVuforiaではじめるAR [主要部分]ARコンテンツ作成勉強会:UnityとVuforiaではじめるAR [主要部分]
ARコンテンツ作成勉強会:UnityとVuforiaではじめるAR [主要部分]Takashi Yoshinaga
 
AndroidのUI設計で押さえておきたいポイント
AndroidのUI設計で押さえておきたいポイントAndroidのUI設計で押さえておきたいポイント
AndroidのUI設計で押さえておきたいポイントTakayuki Inoue
 
「宴」実装時に得られたUnityプログラムノウハウ
「宴」実装時に得られたUnityプログラムノウハウ「宴」実装時に得られたUnityプログラムノウハウ
「宴」実装時に得られたUnityプログラムノウハウRyohei Tokimura
 
Unity MARS導入セミナー(7月8日号) - Unityステーション
Unity MARS導入セミナー(7月8日号) - UnityステーションUnity MARS導入セミナー(7月8日号) - Unityステーション
Unity MARS導入セミナー(7月8日号) - UnityステーションUnity Technologies Japan K.K.
 
ウェアラブルVRの現状と未来
ウェアラブルVRの現状と未来ウェアラブルVRの現状と未来
ウェアラブルVRの現状と未来Naoji Taniguchi
 
Unity+Vuforia でARアプリを作ってみよう
Unity+Vuforia でARアプリを作ってみようUnity+Vuforia でARアプリを作ってみよう
Unity+Vuforia でARアプリを作ってみようhima_zinn
 
Megascansを使った効率化と楽しい絵作り ~Cutting-Edge Test Drive制作事例~
Megascansを使った効率化と楽しい絵作り ~Cutting-Edge Test Drive制作事例~Megascansを使った効率化と楽しい絵作り ~Cutting-Edge Test Drive制作事例~
Megascansを使った効率化と楽しい絵作り ~Cutting-Edge Test Drive制作事例~historia_Inc
 
Android pieの新機能紹介
Android pieの新機能紹介Android pieの新機能紹介
Android pieの新機能紹介Akira SUGIMOTO
 
UNITY5の地味だけど現場で 役に立つ新機能紹介 & 拡充されるクラウドサービス
UNITY5の地味だけど現場で 役に立つ新機能紹介 & 拡充されるクラウドサービスUNITY5の地味だけど現場で 役に立つ新機能紹介 & 拡充されるクラウドサービス
UNITY5の地味だけど現場で 役に立つ新機能紹介 & 拡充されるクラウドサービスMakotoItoh
 
【Unite 2018 Tokyo】エディター拡張マニアクス2018
【Unite 2018 Tokyo】エディター拡張マニアクス2018【Unite 2018 Tokyo】エディター拡張マニアクス2018
【Unite 2018 Tokyo】エディター拡張マニアクス2018Unity Technologies Japan K.K.
 
Unity5.3の機能まとめ
Unity5.3の機能まとめUnity5.3の機能まとめ
Unity5.3の機能まとめKeigo Ando
 
UE5制作事例 “The Market of Light” ~Nanite/Lumenへの挑戦~
UE5制作事例 “The Market of Light” ~Nanite/Lumenへの挑戦~UE5制作事例 “The Market of Light” ~Nanite/Lumenへの挑戦~
UE5制作事例 “The Market of Light” ~Nanite/Lumenへの挑戦~historia_Inc
 
【Unite 2018 Tokyo】Unityにおける疎結合設計 ~UIへの適用事例から学ぶ、テクニックとメリット~
【Unite 2018 Tokyo】Unityにおける疎結合設計 ~UIへの適用事例から学ぶ、テクニックとメリット~【Unite 2018 Tokyo】Unityにおける疎結合設計 ~UIへの適用事例から学ぶ、テクニックとメリット~
【Unite 2018 Tokyo】Unityにおける疎結合設計 ~UIへの適用事例から学ぶ、テクニックとメリット~UnityTechnologiesJapan002
 
デザイナーと一緒にコラボして仕上げるアニメーション実装とショーケース紹介
デザイナーと一緒にコラボして仕上げるアニメーション実装とショーケース紹介 デザイナーと一緒にコラボして仕上げるアニメーション実装とショーケース紹介
デザイナーと一緒にコラボして仕上げるアニメーション実装とショーケース紹介 Fumiya Sakai
 
Unity MARSハンズオンセミナー(7月15日号) - Unityステーション
Unity MARSハンズオンセミナー(7月15日号) - UnityステーションUnity MARSハンズオンセミナー(7月15日号) - Unityステーション
Unity MARSハンズオンセミナー(7月15日号) - UnityステーションUnity Technologies Japan K.K.
 
dotcle 経験0から Meteor iOS アプリを2ヶ月半で作ってリリースしてみた
dotcle 経験0から Meteor iOS アプリを2ヶ月半で作ってリリースしてみたdotcle 経験0から Meteor iOS アプリを2ヶ月半で作ってリリースしてみた
dotcle 経験0から Meteor iOS アプリを2ヶ月半で作ってリリースしてみたNobutaka OSHIRO
 
【Unity道場 名古屋SP】Unityのグラフィックス表現の進化とソリューションでの活用
【Unity道場 名古屋SP】Unityのグラフィックス表現の進化とソリューションでの活用【Unity道場 名古屋SP】Unityのグラフィックス表現の進化とソリューションでの活用
【Unity道場 名古屋SP】Unityのグラフィックス表現の進化とソリューションでの活用Unity Technologies Japan K.K.
 

Was ist angesagt? (20)

ARコンテンツ作成勉強会:UnityとVuforiaではじめるAR [主要部分]
ARコンテンツ作成勉強会:UnityとVuforiaではじめるAR [主要部分]ARコンテンツ作成勉強会:UnityとVuforiaではじめるAR [主要部分]
ARコンテンツ作成勉強会:UnityとVuforiaではじめるAR [主要部分]
 
AndroidのUI設計で押さえておきたいポイント
AndroidのUI設計で押さえておきたいポイントAndroidのUI設計で押さえておきたいポイント
AndroidのUI設計で押さえておきたいポイント
 
「宴」実装時に得られたUnityプログラムノウハウ
「宴」実装時に得られたUnityプログラムノウハウ「宴」実装時に得られたUnityプログラムノウハウ
「宴」実装時に得られたUnityプログラムノウハウ
 
Unity開発ロードマップ最新情報
Unity開発ロードマップ最新情報Unity開発ロードマップ最新情報
Unity開発ロードマップ最新情報
 
Unity MARS導入セミナー(7月8日号) - Unityステーション
Unity MARS導入セミナー(7月8日号) - UnityステーションUnity MARS導入セミナー(7月8日号) - Unityステーション
Unity MARS導入セミナー(7月8日号) - Unityステーション
 
ウェアラブルVRの現状と未来
ウェアラブルVRの現状と未来ウェアラブルVRの現状と未来
ウェアラブルVRの現状と未来
 
Unity+Vuforia でARアプリを作ってみよう
Unity+Vuforia でARアプリを作ってみようUnity+Vuforia でARアプリを作ってみよう
Unity+Vuforia でARアプリを作ってみよう
 
Megascansを使った効率化と楽しい絵作り ~Cutting-Edge Test Drive制作事例~
Megascansを使った効率化と楽しい絵作り ~Cutting-Edge Test Drive制作事例~Megascansを使った効率化と楽しい絵作り ~Cutting-Edge Test Drive制作事例~
Megascansを使った効率化と楽しい絵作り ~Cutting-Edge Test Drive制作事例~
 
Android pieの新機能紹介
Android pieの新機能紹介Android pieの新機能紹介
Android pieの新機能紹介
 
UNITY5の地味だけど現場で 役に立つ新機能紹介 & 拡充されるクラウドサービス
UNITY5の地味だけど現場で 役に立つ新機能紹介 & 拡充されるクラウドサービスUNITY5の地味だけど現場で 役に立つ新機能紹介 & 拡充されるクラウドサービス
UNITY5の地味だけど現場で 役に立つ新機能紹介 & 拡充されるクラウドサービス
 
【Unite 2018 Tokyo】エディター拡張マニアクス2018
【Unite 2018 Tokyo】エディター拡張マニアクス2018【Unite 2018 Tokyo】エディター拡張マニアクス2018
【Unite 2018 Tokyo】エディター拡張マニアクス2018
 
Unity5.3の機能まとめ
Unity5.3の機能まとめUnity5.3の機能まとめ
Unity5.3の機能まとめ
 
UE5制作事例 “The Market of Light” ~Nanite/Lumenへの挑戦~
UE5制作事例 “The Market of Light” ~Nanite/Lumenへの挑戦~UE5制作事例 “The Market of Light” ~Nanite/Lumenへの挑戦~
UE5制作事例 “The Market of Light” ~Nanite/Lumenへの挑戦~
 
【Unite 2018 Tokyo】Unityにおける疎結合設計 ~UIへの適用事例から学ぶ、テクニックとメリット~
【Unite 2018 Tokyo】Unityにおける疎結合設計 ~UIへの適用事例から学ぶ、テクニックとメリット~【Unite 2018 Tokyo】Unityにおける疎結合設計 ~UIへの適用事例から学ぶ、テクニックとメリット~
【Unite 2018 Tokyo】Unityにおける疎結合設計 ~UIへの適用事例から学ぶ、テクニックとメリット~
 
デザイナーと一緒にコラボして仕上げるアニメーション実装とショーケース紹介
デザイナーと一緒にコラボして仕上げるアニメーション実装とショーケース紹介 デザイナーと一緒にコラボして仕上げるアニメーション実装とショーケース紹介
デザイナーと一緒にコラボして仕上げるアニメーション実装とショーケース紹介
 
徹底解説 Unity Reflect【概要編 ver2.0】
徹底解説 Unity Reflect【概要編 ver2.0】徹底解説 Unity Reflect【概要編 ver2.0】
徹底解説 Unity Reflect【概要編 ver2.0】
 
Unity MARSハンズオンセミナー(7月15日号) - Unityステーション
Unity MARSハンズオンセミナー(7月15日号) - UnityステーションUnity MARSハンズオンセミナー(7月15日号) - Unityステーション
Unity MARSハンズオンセミナー(7月15日号) - Unityステーション
 
dotcle 経験0から Meteor iOS アプリを2ヶ月半で作ってリリースしてみた
dotcle 経験0から Meteor iOS アプリを2ヶ月半で作ってリリースしてみたdotcle 経験0から Meteor iOS アプリを2ヶ月半で作ってリリースしてみた
dotcle 経験0から Meteor iOS アプリを2ヶ月半で作ってリリースしてみた
 
【Unite Tokyo 2018】基調講演
【Unite Tokyo 2018】基調講演【Unite Tokyo 2018】基調講演
【Unite Tokyo 2018】基調講演
 
【Unity道場 名古屋SP】Unityのグラフィックス表現の進化とソリューションでの活用
【Unity道場 名古屋SP】Unityのグラフィックス表現の進化とソリューションでの活用【Unity道場 名古屋SP】Unityのグラフィックス表現の進化とソリューションでの活用
【Unity道場 名古屋SP】Unityのグラフィックス表現の進化とソリューションでの活用
 

Ähnlich wie Pin-point rebuildable and non-rebuild custom widget

RxDataSourceをNSDiffableDataSourceへ置き換える際のTips集紹介
RxDataSourceをNSDiffableDataSourceへ置き換える際のTips集紹介RxDataSourceをNSDiffableDataSourceへ置き換える際のTips集紹介
RxDataSourceをNSDiffableDataSourceへ置き換える際のTips集紹介Fumiya Sakai
 
Flutter のリアクティブ戦略 set state 〜 redux まで
Flutter のリアクティブ戦略 set state 〜 redux までFlutter のリアクティブ戦略 set state 〜 redux まで
Flutter のリアクティブ戦略 set state 〜 redux までcch-robo
 
.NET Core向けコンテナおよびデバッグ関連のVisual Studioの新機能
.NET Core向けコンテナおよびデバッグ関連のVisual Studioの新機能.NET Core向けコンテナおよびデバッグ関連のVisual Studioの新機能
.NET Core向けコンテナおよびデバッグ関連のVisual Studioの新機能Takayoshi Tanaka
 
WordPress widget api
WordPress widget apiWordPress widget api
WordPress widget apiTakami Kazuya
 
2021 01-30 Visual Studio 2019 知っているか!?この機能 in BuriKaigi2021
2021 01-30 Visual Studio 2019 知っているか!?この機能 in BuriKaigi20212021 01-30 Visual Studio 2019 知っているか!?この機能 in BuriKaigi2021
2021 01-30 Visual Studio 2019 知っているか!?この機能 in BuriKaigi2021Hiroyuki Mori
 
.NET Core向けコンテナおよびデバッグ関連のVisual Studio 2019の機能
.NET Core向けコンテナおよびデバッグ関連のVisual Studio 2019の機能.NET Core向けコンテナおよびデバッグ関連のVisual Studio 2019の機能
.NET Core向けコンテナおよびデバッグ関連のVisual Studio 2019の機能Takayoshi Tanaka
 
LabVIEW NXG Web Module Training Slide
LabVIEW NXG Web Module Training SlideLabVIEW NXG Web Module Training Slide
LabVIEW NXG Web Module Training SlideYusuke Tochigi
 
VSCodeで始めるAzure Static Web Apps開発
VSCodeで始めるAzure Static Web Apps開発VSCodeで始めるAzure Static Web Apps開発
VSCodeで始めるAzure Static Web Apps開発Yuta Matsumura
 
Extending the Unity Editor Extended
Extending the Unity Editor ExtendedExtending the Unity Editor Extended
Extending the Unity Editor ExtendedMasamitsu Ishikawa
 
Ma_gician (世界中のフロントエンダーの残業時間を減らす、新しいフロントエンドフレームワーク)<詳細版>
Ma_gician (世界中のフロントエンダーの残業時間を減らす、新しいフロントエンドフレームワーク)<詳細版>Ma_gician (世界中のフロントエンダーの残業時間を減らす、新しいフロントエンドフレームワーク)<詳細版>
Ma_gician (世界中のフロントエンダーの残業時間を減らす、新しいフロントエンドフレームワーク)<詳細版>Eucen Stew
 
Editor スクリプティング 入門
Editor スクリプティング 入門Editor スクリプティング 入門
Editor スクリプティング 入門Keigo Ando
 
ルーター自前実装の話
ルーター自前実装の話ルーター自前実装の話
ルーター自前実装の話Kazushi Kawamura
 
Introduction for Browser Side MVC
Introduction for Browser Side MVCIntroduction for Browser Side MVC
Introduction for Browser Side MVCRyunosuke SATO
 
ASP.NET MVC 2 ~新機能の紹介~
ASP.NET MVC 2 ~新機能の紹介~ASP.NET MVC 2 ~新機能の紹介~
ASP.NET MVC 2 ~新機能の紹介~Yoshitaka Seo
 
モバイルゲームの「大規模な開発」かつ「高頻度の更新」を実現するための開発環境整備の取り組み
モバイルゲームの「大規模な開発」かつ「高頻度の更新」を実現するための開発環境整備の取り組みモバイルゲームの「大規模な開発」かつ「高頻度の更新」を実現するための開発環境整備の取り組み
モバイルゲームの「大規模な開発」かつ「高頻度の更新」を実現するための開発環境整備の取り組みMorioImai
 
Let's build a simple app with .net 6 asp.net core web api, react, and elasti...
Let's build a simple app with  .net 6 asp.net core web api, react, and elasti...Let's build a simple app with  .net 6 asp.net core web api, react, and elasti...
Let's build a simple app with .net 6 asp.net core web api, react, and elasti...Shotaro Suzuki
 
【de:code 2020】 「あつまれ フロントエンドエンジニア」 Azure Static Web Apps がやってきた
【de:code 2020】 「あつまれ フロントエンドエンジニア」 Azure Static Web Apps がやってきた【de:code 2020】 「あつまれ フロントエンドエンジニア」 Azure Static Web Apps がやってきた
【de:code 2020】 「あつまれ フロントエンドエンジニア」 Azure Static Web Apps がやってきた日本マイクロソフト株式会社
 
.NET Core 3.0 で Blazor を使用した​フルスタック C# Web アプリ​の構築
.NET Core 3.0 で Blazor を使用した​フルスタック C# Web アプリ​の構築.NET Core 3.0 で Blazor を使用した​フルスタック C# Web アプリ​の構築
.NET Core 3.0 で Blazor を使用した​フルスタック C# Web アプリ​の構築Joni
 
Developing .NET 6 Blazor WebAssemby apps with Radzen Blazor component library...
Developing .NET 6 Blazor WebAssemby apps with Radzen Blazor component library...Developing .NET 6 Blazor WebAssemby apps with Radzen Blazor component library...
Developing .NET 6 Blazor WebAssemby apps with Radzen Blazor component library...Shotaro Suzuki
 

Ähnlich wie Pin-point rebuildable and non-rebuild custom widget (20)

RxDataSourceをNSDiffableDataSourceへ置き換える際のTips集紹介
RxDataSourceをNSDiffableDataSourceへ置き換える際のTips集紹介RxDataSourceをNSDiffableDataSourceへ置き換える際のTips集紹介
RxDataSourceをNSDiffableDataSourceへ置き換える際のTips集紹介
 
Flutter のリアクティブ戦略 set state 〜 redux まで
Flutter のリアクティブ戦略 set state 〜 redux までFlutter のリアクティブ戦略 set state 〜 redux まで
Flutter のリアクティブ戦略 set state 〜 redux まで
 
.NET Core向けコンテナおよびデバッグ関連のVisual Studioの新機能
.NET Core向けコンテナおよびデバッグ関連のVisual Studioの新機能.NET Core向けコンテナおよびデバッグ関連のVisual Studioの新機能
.NET Core向けコンテナおよびデバッグ関連のVisual Studioの新機能
 
WordPress widget api
WordPress widget apiWordPress widget api
WordPress widget api
 
2021 01-30 Visual Studio 2019 知っているか!?この機能 in BuriKaigi2021
2021 01-30 Visual Studio 2019 知っているか!?この機能 in BuriKaigi20212021 01-30 Visual Studio 2019 知っているか!?この機能 in BuriKaigi2021
2021 01-30 Visual Studio 2019 知っているか!?この機能 in BuriKaigi2021
 
.NET Core向けコンテナおよびデバッグ関連のVisual Studio 2019の機能
.NET Core向けコンテナおよびデバッグ関連のVisual Studio 2019の機能.NET Core向けコンテナおよびデバッグ関連のVisual Studio 2019の機能
.NET Core向けコンテナおよびデバッグ関連のVisual Studio 2019の機能
 
LabVIEW NXG Web Module Training Slide
LabVIEW NXG Web Module Training SlideLabVIEW NXG Web Module Training Slide
LabVIEW NXG Web Module Training Slide
 
VSCodeで始めるAzure Static Web Apps開発
VSCodeで始めるAzure Static Web Apps開発VSCodeで始めるAzure Static Web Apps開発
VSCodeで始めるAzure Static Web Apps開発
 
Extending the Unity Editor Extended
Extending the Unity Editor ExtendedExtending the Unity Editor Extended
Extending the Unity Editor Extended
 
Ma_gician (世界中のフロントエンダーの残業時間を減らす、新しいフロントエンドフレームワーク)<詳細版>
Ma_gician (世界中のフロントエンダーの残業時間を減らす、新しいフロントエンドフレームワーク)<詳細版>Ma_gician (世界中のフロントエンダーの残業時間を減らす、新しいフロントエンドフレームワーク)<詳細版>
Ma_gician (世界中のフロントエンダーの残業時間を減らす、新しいフロントエンドフレームワーク)<詳細版>
 
Editor スクリプティング 入門
Editor スクリプティング 入門Editor スクリプティング 入門
Editor スクリプティング 入門
 
Extending the Unity Editor
Extending the Unity EditorExtending the Unity Editor
Extending the Unity Editor
 
ルーター自前実装の話
ルーター自前実装の話ルーター自前実装の話
ルーター自前実装の話
 
Introduction for Browser Side MVC
Introduction for Browser Side MVCIntroduction for Browser Side MVC
Introduction for Browser Side MVC
 
ASP.NET MVC 2 ~新機能の紹介~
ASP.NET MVC 2 ~新機能の紹介~ASP.NET MVC 2 ~新機能の紹介~
ASP.NET MVC 2 ~新機能の紹介~
 
モバイルゲームの「大規模な開発」かつ「高頻度の更新」を実現するための開発環境整備の取り組み
モバイルゲームの「大規模な開発」かつ「高頻度の更新」を実現するための開発環境整備の取り組みモバイルゲームの「大規模な開発」かつ「高頻度の更新」を実現するための開発環境整備の取り組み
モバイルゲームの「大規模な開発」かつ「高頻度の更新」を実現するための開発環境整備の取り組み
 
Let's build a simple app with .net 6 asp.net core web api, react, and elasti...
Let's build a simple app with  .net 6 asp.net core web api, react, and elasti...Let's build a simple app with  .net 6 asp.net core web api, react, and elasti...
Let's build a simple app with .net 6 asp.net core web api, react, and elasti...
 
【de:code 2020】 「あつまれ フロントエンドエンジニア」 Azure Static Web Apps がやってきた
【de:code 2020】 「あつまれ フロントエンドエンジニア」 Azure Static Web Apps がやってきた【de:code 2020】 「あつまれ フロントエンドエンジニア」 Azure Static Web Apps がやってきた
【de:code 2020】 「あつまれ フロントエンドエンジニア」 Azure Static Web Apps がやってきた
 
.NET Core 3.0 で Blazor を使用した​フルスタック C# Web アプリ​の構築
.NET Core 3.0 で Blazor を使用した​フルスタック C# Web アプリ​の構築.NET Core 3.0 で Blazor を使用した​フルスタック C# Web アプリ​の構築
.NET Core 3.0 で Blazor を使用した​フルスタック C# Web アプリ​の構築
 
Developing .NET 6 Blazor WebAssemby apps with Radzen Blazor component library...
Developing .NET 6 Blazor WebAssemby apps with Radzen Blazor component library...Developing .NET 6 Blazor WebAssemby apps with Radzen Blazor component library...
Developing .NET 6 Blazor WebAssemby apps with Radzen Blazor component library...
 

Mehr von cch-robo

Flutter_Forward_Extended_Kyoto-Keynote_Summary
Flutter_Forward_Extended_Kyoto-Keynote_SummaryFlutter_Forward_Extended_Kyoto-Keynote_Summary
Flutter_Forward_Extended_Kyoto-Keynote_Summarycch-robo
 
go_router が隠してくれるもの
go_router が隠してくれるものgo_router が隠してくれるもの
go_router が隠してくれるものcch-robo
 
Introduction_on_designing_test_in_flutter
Introduction_on_designing_test_in_flutterIntroduction_on_designing_test_in_flutter
Introduction_on_designing_test_in_fluttercch-robo
 
Google I/O 2021 Flutter 全体報告
Google I/O 2021 Flutter 全体報告Google I/O 2021 Flutter 全体報告
Google I/O 2021 Flutter 全体報告cch-robo
 
Dart / Flutter コードファイルジェネレート入門
Dart / Flutter コードファイルジェネレート入門Dart / Flutter コードファイルジェネレート入門
Dart / Flutter コードファイルジェネレート入門cch-robo
 
フラッター開発におけるシークレット情報取扱考察
フラッター開発におけるシークレット情報取扱考察フラッター開発におけるシークレット情報取扱考察
フラッター開発におけるシークレット情報取扱考察cch-robo
 
Flutterを体験してみませんか
Flutterを体験してみませんかFlutterを体験してみませんか
Flutterを体験してみませんかcch-robo
 
Dart言語の進化状況
Dart言語の進化状況Dart言語の進化状況
Dart言語の進化状況cch-robo
 
明示的アニメで、Flutterアニメーション入門
明示的アニメで、Flutterアニメーション入門明示的アニメで、Flutterアニメーション入門
明示的アニメで、Flutterアニメーション入門cch-robo
 
DartPad+CodePenで、Flutterを体験してみよう
DartPad+CodePenで、Flutterを体験してみようDartPad+CodePenで、Flutterを体験してみよう
DartPad+CodePenで、Flutterを体験してみようcch-robo
 
Dartでサーバレスサービス
DartでサーバレスサービスDartでサーバレスサービス
Dartでサーバレスサービスcch-robo
 
FlutterでのWidgetツリーへの状態伝播とアクセス制限の基本戦略
FlutterでのWidgetツリーへの状態伝播とアクセス制限の基本戦略FlutterでのWidgetツリーへの状態伝播とアクセス制限の基本戦略
FlutterでのWidgetツリーへの状態伝播とアクセス制限の基本戦略cch-robo
 
Before lunch オプションを使って Flutterでstaging/release環境を切り替える
Before lunch オプションを使って Flutterでstaging/release環境を切り替えるBefore lunch オプションを使って Flutterでstaging/release環境を切り替える
Before lunch オプションを使って Flutterでstaging/release環境を切り替えるcch-robo
 
Android lint-srp-practice
Android lint-srp-practiceAndroid lint-srp-practice
Android lint-srp-practicecch-robo
 
Loose and fluffy_ddd_intro
Loose and fluffy_ddd_introLoose and fluffy_ddd_intro
Loose and fluffy_ddd_introcch-robo
 
Firebase Test Lab 無料枠を使ってみました。
Firebase Test Lab 無料枠を使ってみました。Firebase Test Lab 無料枠を使ってみました。
Firebase Test Lab 無料枠を使ってみました。cch-robo
 
ZTE OPEN を日本語化(バージョンアップ)してみる
ZTE OPEN を日本語化(バージョンアップ)してみるZTE OPEN を日本語化(バージョンアップ)してみる
ZTE OPEN を日本語化(バージョンアップ)してみるcch-robo
 
FirefoxOSで学ぶJavaScript作法
FirefoxOSで学ぶJavaScript作法FirefoxOSで学ぶJavaScript作法
FirefoxOSで学ぶJavaScript作法cch-robo
 

Mehr von cch-robo (18)

Flutter_Forward_Extended_Kyoto-Keynote_Summary
Flutter_Forward_Extended_Kyoto-Keynote_SummaryFlutter_Forward_Extended_Kyoto-Keynote_Summary
Flutter_Forward_Extended_Kyoto-Keynote_Summary
 
go_router が隠してくれるもの
go_router が隠してくれるものgo_router が隠してくれるもの
go_router が隠してくれるもの
 
Introduction_on_designing_test_in_flutter
Introduction_on_designing_test_in_flutterIntroduction_on_designing_test_in_flutter
Introduction_on_designing_test_in_flutter
 
Google I/O 2021 Flutter 全体報告
Google I/O 2021 Flutter 全体報告Google I/O 2021 Flutter 全体報告
Google I/O 2021 Flutter 全体報告
 
Dart / Flutter コードファイルジェネレート入門
Dart / Flutter コードファイルジェネレート入門Dart / Flutter コードファイルジェネレート入門
Dart / Flutter コードファイルジェネレート入門
 
フラッター開発におけるシークレット情報取扱考察
フラッター開発におけるシークレット情報取扱考察フラッター開発におけるシークレット情報取扱考察
フラッター開発におけるシークレット情報取扱考察
 
Flutterを体験してみませんか
Flutterを体験してみませんかFlutterを体験してみませんか
Flutterを体験してみませんか
 
Dart言語の進化状況
Dart言語の進化状況Dart言語の進化状況
Dart言語の進化状況
 
明示的アニメで、Flutterアニメーション入門
明示的アニメで、Flutterアニメーション入門明示的アニメで、Flutterアニメーション入門
明示的アニメで、Flutterアニメーション入門
 
DartPad+CodePenで、Flutterを体験してみよう
DartPad+CodePenで、Flutterを体験してみようDartPad+CodePenで、Flutterを体験してみよう
DartPad+CodePenで、Flutterを体験してみよう
 
Dartでサーバレスサービス
DartでサーバレスサービスDartでサーバレスサービス
Dartでサーバレスサービス
 
FlutterでのWidgetツリーへの状態伝播とアクセス制限の基本戦略
FlutterでのWidgetツリーへの状態伝播とアクセス制限の基本戦略FlutterでのWidgetツリーへの状態伝播とアクセス制限の基本戦略
FlutterでのWidgetツリーへの状態伝播とアクセス制限の基本戦略
 
Before lunch オプションを使って Flutterでstaging/release環境を切り替える
Before lunch オプションを使って Flutterでstaging/release環境を切り替えるBefore lunch オプションを使って Flutterでstaging/release環境を切り替える
Before lunch オプションを使って Flutterでstaging/release環境を切り替える
 
Android lint-srp-practice
Android lint-srp-practiceAndroid lint-srp-practice
Android lint-srp-practice
 
Loose and fluffy_ddd_intro
Loose and fluffy_ddd_introLoose and fluffy_ddd_intro
Loose and fluffy_ddd_intro
 
Firebase Test Lab 無料枠を使ってみました。
Firebase Test Lab 無料枠を使ってみました。Firebase Test Lab 無料枠を使ってみました。
Firebase Test Lab 無料枠を使ってみました。
 
ZTE OPEN を日本語化(バージョンアップ)してみる
ZTE OPEN を日本語化(バージョンアップ)してみるZTE OPEN を日本語化(バージョンアップ)してみる
ZTE OPEN を日本語化(バージョンアップ)してみる
 
FirefoxOSで学ぶJavaScript作法
FirefoxOSで学ぶJavaScript作法FirefoxOSで学ぶJavaScript作法
FirefoxOSで学ぶJavaScript作法
 

Pin-point rebuildable and non-rebuild custom widget

  • 1. Pin-point rebuildable and non-rebuild custom widget GDG meetup in Kyoto 2019/02/10 at Furyu robo
  • 2. Self-introduction Name robo (兼高理恵) Favorite things mobile computer My work From application design to implementation 2
  • 3. We received Service Partner of the Year - Japan from Google! Building a better cloud with our partners at Next ‘18 https://blog.google/products/google-cloud/building-a-better-cloud-with-our-partners-at-next-18/
  • 4. Pin-point rebuildable and non-rebuild custom widget ピンポイントで再構築可能と再構築不可なカスタムウィジェット
  • 5. In this session, I will introduce my custom widgets that 'RebuildableWidget' and 'ConstantWidget'. 自作の 'RebuildableWidget'と 'ConstantWidget'  カスタムウィジェットについて紹介します。
  • 6. Basics of creating a page display of Flutter In Flutter, everything is a widget. Flutter のページ表示作成の基本  Flutterでは、全てが Widget です。
  • 7. In Flutter, all UI display and essential functions of the application are defined in Widget's tree structure. and The contents of the page display of Flutter is defined by the tree structure of the UI parts with Widget for page display. Flutterでは、アプリの全ての UI表示および必須機能を Widget のツリー構造で定義します。 ページ表示の内容は、ページ表示用の Widget での UIパーツ のツリー構造で定義します。
  • 8. To create an updatable page view with Flutter, use the StatefulWidget class. Flutterで、更新可能なページ表示を作成するには、 StatefulWidget クラスを使います。
  • 9. StatefulWidget has arbitrary invariant information (class field), variable information (class field), and build(BuildContext context) method for building page display contents. StatefulWidget は、任意の不変情報 (クラス フィールド)と可変情報(クラスフィールド)と、 ページ表示内容を構築する build(BuildContext context) メソッドを持っています。
  • 10. The build(context) method is executed to reflect invariant information and variable information when StatefulWidget is newly created or when the setState(void Function () f) method is executed, and the screen display is re-displayed it. build(context) メソッドは、 StatefulWidget が新規生成されたか、 setState(void Function() f) が実行されると、 不変情報と可変情報を反映するために実行されて、画面表示が再構築されます。
  • 11. これは、Flutter の代表的なカウンターアプリのメインページの表示です。 ページ表示内容は、 MyHomePage Widget で定義されています。 This is the display of the main page of Flutter's typical counter application. The page display content of the counter application is defined by MyHomePage Widget.
  • 12. ページ表示内容の UIパーツのツリー構造 の定義は、 左のようになっています。 The definition of the tree structure of the UI parts of the page display content is as shown on the left. build(context) { return  Scaffold(   appBar: AppBar(    Icon,    Text    )   body: Container(    Columen([    Text, // message    Text, // counter    ]),     )   floatingActionButton: FAB(    Icon,    )  ); }
  • 13. ページ表示用 Widget の setState(f) を実行すると、build(context)が実行され、 ページ表示用の Widget のツリーの 各ノードである  全 UIパーツ Widget が再生成されます。 これによりページ表示の外観は、可変情報である カウンタ値 の  最新の内容が反映された外観に更新されます。 When setState(f) of the page display Widget is executed, build(context) is executed and all the UI parts widget which is each node of Widget's tree for page display are regenerated. As a result, the appearance of the page display is updated to the appearance reflecting the latest contents of the counter value which is variable information.
  • 14. The thing to note is that when you execute setState(f), all widgets of UI widget for page display will be regenerated. 注意しなくてはならないことは、setState(f) を実行すると、 ページ表示用の 全 UIパーツ Widget が再生成されることです。
  • 15. The display appearance is updated only for the UI part of the counter value, but all UI widgets of the page display widget are regenerated! 表示外観が更新されるのは、カウンタ値 の UIパーツだけですが、 ページ表示用の全ての UIパーツ Widget が再生成されてしまうのです。
  • 16. これは、UIパーツのウィジェットの再生成で発生するフローをログ出力させたものです。 This is a log output of the flow generated by the regeneration of the widget of the UI parts.
  • 17. When you execute setState(f) of MyHomePage, build related processing is executed so much. MyHomePage の setState(f) を実行させると、 こんなにもビルド関連の処理が実行されてしまうのです。
  • 18. How can we update only the UI part of the counter value? カウンタ値の UIパーツだけを更新するには、どうしたら良いのでしょう。
  • 19. Pinpoint display update idea Since setState(f) executes all the UI widgets of the page display widget, it is only necessary to create a custom page display widget having only the UI part of the counter value in the tree. ピンポイント表示更新のアイディア setState(f) は、ページ表示用 Widget の 全ての UIパーツ Widget を実行するのだから、 ツリーにカウンタ値 の UIパーツだけを持つカスタムなページ表示用 Widget を作れば  良いことになります。
  • 20. Then, how can you make sure that the display contents do not change (do not regenerate) the UI parts widget of immutable tree from the initial display? それでは、表示内容が初期表示から不変のツリーの UIパーツ Widget を  変更させない(再生成させない)ようにするには、どうしたら良いのでしょうか。
  • 21. Pinpoint display no-update idea For 'Performance considerations' in the reference of the StatefulWidget class, there are cases where regeneration of widget does not occur if subtree without display change returns cache value. ピンポイント表示無更新のアイディア StatefulWidget class のリファレンスの Performance considerations には、 キャッシュ値を返すようにすれば Widget の再生成が発生しないとあります。
  • 22. これが使えそうです。 Reference: StatefulWidget class #Performance considerations https://docs.flutter.io/flutter/widgets/StatefulWidget-class.html#performance-considerations > If a subtree does not change, cache the widget that represents > that subtree and re-use it each time it can be used. > It is massively more efficient for a widget to be re-used > than for a new (but identically-configured) widget to be created. > Factoring out the stateful part into a widget > that takes a child argument is a common way of doing this. This seems to work.
  • 23. Initial display object cache experiment (I am sorry, but there is no slide for demonstration.) 初期表示オブジェクトのキャッシュ実験 (ごめんなさい実演のためスライドはありません )
  • 24. So, there is a custom widget here! (Graham Kerr's The Galloping Gourmet method) では、こちらに出来上がったカスタムウィジェットがあります。 (グラハム・カー 世界の料理ショー メソッド)
  • 25. Pin-point rebuildable and non-rebuild custom widget To redraw RebuildableWidget arbitrarily, set GlobalKey. Then let the event handler execute the rebuild() method. RebuildableWidget specifies the tree that you want the builder property to display and update. ConstantWidget specifies a tree that the builder property does not display and update. RebuildableWidget arbitrarily regenerates (display update) child widgets using rebuild() method. ConstnatWidget is a widget that does not allow rendering of child widgets when regenerated.
  • 26. これは、UIパーツのウィジェットの再生成で発生するフローをログ出力させたものです。 オリジナルの半分以下のフローで再描画できています。 This is a log output of the flow generated by the regeneration of the widget of the UI parts. Redrawing is possible with less than half of original flow.
  • 27. The source of the custom widget will be here. カスタムウィジェットのソースは、こちらになります。 https://github.com/cch-robo/basic_strategy_of_state_propagation_in_Flutter/blob/ master/lib/src/base/custom_widgets.dart
  • 28. In addition, please refer to the session slide and github sample of DroidKaigi 2019 which became the basis of the announcement too. 併せて、発表のもとになった  DroidKaigi 2019 のセッションスライドと github サンプルも参照ください。 Basic Strategy of State Propagation and Access Restriction in Flutter https://www.slideshare.net/cch-robo/flutterwidget-130879555 cch-robo/basic_strategy_of_state_propagation_in_Flutter https://github.com/cch-robo/basic_strategy_of_state_propagation_in_Flutter
  • 29. thank you for your attention. ご清聴、ありがとうございました。