ScopedQueryBase<Result, TRef extends Ref> class abstract

Base class that can specify the type of the provider part of ScopedQuery.

Used to create frameworks.

ScopedQueryprovider部分の型を指定することができるベースクラス。

フレームワークの作成に利用します。

ScopedQuery makes it possible to define values globally and manage state individually and safely.

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 name.

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

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

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

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

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

final stateQuery = ScopedQuery(
  () => "state",
);

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

    return Scaffold(
      body: Center(child: Text("${state}")), // `state`
    );
  }
}
Implementers
Annotations

Constructors

ScopedQueryBase(Result provider(QueryScopedValueRef<TRef> ref), {Object? name, bool autoDisposeWhenUnreferenced = false})
Base class that can specify the type of the provider part of ScopedQuery.
const

Properties

autoDisposeWhenUnreferenced bool
Returns true if ScopedQuery should be automatically discarded when it is no longer referenced by any widget.
final
hashCode int
The hash code for this object.
no setterinherited
listen bool
Returns true if the value is monitored for update notification.
no setter
provider → Result Function(QueryScopedValueRef<TRef> ref)
A callback that returns the value you want to manage.
final
queryName Object
Returns a name to identify the state.
no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

call(QueryScopedValueRef<TRef> ref) → Result Function()
Returns a callback that returns the value you want to manage.
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