最近はまったポイントを共有させていただきます。
I would like to share a point that I have been stuck on recently.
白と透明のグラデーションが欲しかったので下記のように書いたら明らかにグレイが混ざって、期待と違うものになりました。
I wanted a gradation of white and transparent, so when I wrote the following, gray was clearly …
新しい回が出ましたね !
訳は文字起こしに日本語もありますのでそちらをご覧ください。
とりあえずざっくりまとめたいと思います。
=> ListView内の二つの項目を紐づけて、あるカードの特別なアイコンをクリックしたら別のカードへスクロールする場合。
=> AppBarをタップしたらListViewの最上部(top)に戻る挙動。
このような場合(他にもスクロール位置を取得したりコントロールしたり、プログラマティックにスクロールさせたりする場合)、ScrollControllerが必要になりますね、と。
基本的にスクロールするものは全てScrollControllerが必要。ListViewなどにScrollControllerを渡さずに生成した場合は、内部で自動的にScrollControllerが生成されている。
各Routeで自動的にPrimaryScrollControllerなるものを生成してInheritedWidgetの仕組みによってサブツリーと共有する。(Theme.of(context)やMediaQuery.of(context)などと同じように)
PrimaryScrollController.of(context,)
で取得できる。これを使ってスクロール位置の取得やスクロール操作を行うことができる。
ListViewなどにはprimaryプロパティがあり、
primary: true
にするとそのListViewはPrimaryScrollControllerを自身のcontrollerに設定する、という仕組み。
(PrimaryScrollControllerも含めて)ScrollControllerは、複数のScrollableと紐づけられることを嫌う。その場合、
“The ScrollController is attached to multiple scroll views.”…
MIT License Copyright (c) 2020 Remi Rousselet Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in…
MIT License Copyright (c) 2020 Remi Rousselet Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the…