RefHasWidget class abstract

Reference with widget scope Ref.

This can be extended with an extension to add a method to handle ScopedValue that stores a value for each widget.

For example, if you want to create a system where the text character is changed each time a button is tapped, the state should be stored in the widget. Therefore, by extending this class to explicitly limit the scope in which it is used, it is possible to specify how the data is held in a way that is easy for the developer to understand.

ウィジェットスコープのRefを持ったリファレンス。

これをextensionで拡張することでウィジェットごとに値を保存するScopedValueを扱うメソッドを追加することができます。

例えば、テキストの文字をボタンがタップされるごとに変更されるような仕組みを作りたい場合、ウィジェットの中に状態が保存されるべきです。そのためこのクラスを拡張して利用されるスコープを明示的に限定することで開発者に分かりやすくデータの持ち方を指定することが可能です。

extension WidgetRefValueExtensions on RefHasWidget {
  String useValue(
    String defaultValue
  ) {
    return widget.watch(() => ValueNotifier(defaultValue));
  }
}
Implemented types
Implementers
Available Extensions
Annotations

Constructors

RefHasWidget()

Properties

hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
widget WidgetScopedValueRef
Ref in the widget scope.
no setter

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited