ChangeNotifierWidgetScopedQueryFamily<Result extends Listenable?, Param> class

You can pass one parameter ChangeNotifierWidgetScopedQuery.

パラメーターを一つ渡すことができるChangeNotifierWidgetScopedQuery

ChangeNotifierScopedQuery makes it possible to define values globally and manage states individually and safely.

Only ChangeNotifier can be managed as a value. It is possible to monitor the status and send change notifications to the widget.

Specify in provider a callback that returns the value you wish to manage.

Normally hashCode is used to manage state names, but if you want to specify a special name, specify queryName.

If autoDisposeWhenUnreferenced is set to true, ScopedQuery will be automatically disposed of when it is no longer referenced by any widget.

ChangeNotifierScopedQueryを利用してグローバルに値を定義して個別に安全に状態を管理することが可能になります。

ChangeNotifierのみを値として管理できます。状態を監視し、変更通知をウィジェットに送信することが可能です。

providerに管理したい値を返すコールバックを指定してください。

通常はhashCodeを用いて状態の名前を管理しますが、特別に名前を指定したい場合はqueryNameを指定してください。

autoDisposeWhenUnreferencedtrueにすると、ScopedQueryがどのウィジェットからも参照されなくなった時に自動的に破棄されます。

final valueNotifierQuery = ChangeNotifierScopedQuery(
  () => ValueNotifier(0),
);

class TestPage extends PageScopedWidget {
  @override
  Widget build(BuildContext context, PageRef ref) {
    final valueNotifier = ref.page.query(valueNotifierQuery);

    return Scaffold(
      body: Center(child: Text("${valueNotifier.value}")),
    );
  }
}
Inheritance
Annotations

Constructors

ChangeNotifierWidgetScopedQueryFamily(Result provider(QueryScopedValueRef<WidgetScopedValueRef> ref, Param param), {Object? name, bool autoDisposeWhenUnreferenced = false})
You can pass one parameter ChangeNotifierWidgetScopedQuery.
const

Properties

autoDisposeWhenUnreferenced bool
Returns true if ScopedQueryFamily should be automatically discarded when it is no longer referenced by any widget.
finalinherited
hashCode int
The hash code for this object.
no setterinherited
provider → Result Function(QueryScopedValueRef<WidgetScopedValueRef> ref, Param param)
Returns a callback that returns the value you want to manage.
finalinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

call(Param param) ChangeNotifierWidgetScopedQuery<Result>
By passing param, the corresponding ScopedQuery is returned.
override
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