SingleControlWidget<T extends ControlModel?> class
abstract
ControlWidget with one main ControlModel.
Required ControlModel is returned by initControl - override this functions if Model is not in args
or ControlFactory can't return it.
ControlWidget maintains larger UI parts of App (Pages or complex Widgets). Widget is created with default ControlState to correctly reflect lifecycle of Widget to Models and Controls. So there is no need to create custom State. Widget will init all containing Models and pass arguments to them. ControlWidget is 'immutable' so all logic parts (even UI logic and animations) must be handled outside. This helps truly separate all 'code' from pure UI (also helps to reuse this code).
This Widget comes with few mixin
classes:
- RouteControl to abstract navigation and easily pass arguments and init other Pages.
- TickerControl and SingleTickerControl to create Ticker and provide access to
vsync
. Then use ControlModel with TickerComponent to get access to TickerProvider.
Typically one or more ControlModel objects handles all logic for ControlWidget. This solution helps to separate even Animation from Business Logic and UI Widgets part.
And comes with LocalizationProvider
to use BaseLocalization
without standard delegate solution.
ControlWidget - Basic Widget with manual ControlModel initialization.
SingleControlWidget - Focused to single ControlModel. But still can handle multiple Controls.
MountedControlWidget
- Automatically uses all ControlModels passed to Widget.
Also check ControllableWidget an abstract Widget focused to build smaller Widgets controlled by ObservableModel and BaseModel.
- Inheritance
-
- Object
- DiagnosticableTree
- Widget
- StatefulWidget
- CoreWidget
- ControlWidget
- SingleControlWidget
- Implementers
- Available Extensions
Constructors
- SingleControlWidget({Key? key, dynamic args})
-
If given
args
contains ControlModel of requested Type, it will be used as control, otherwise Control.get will provide requested ControlModel.
Properties
- autoMountControls → bool
-
Checks
args
and returns all ControlModels during initControls and these Models will be initialized by this Widget. By default set to 'false'.no setterinherited - context → BuildContext?
-
Returns BuildContext of current State if is available.
no setterinherited
- control → T
-
Initialized ControlModel, This objects is stored in controls List at first place.
no setter
-
controls
→ List<
ControlModel?> -
List of
ControlModel
s initialized via initControls. Set autoMountControls to automatically init all Models passed throughargs
.no setterinherited - factoryKey → dynamic
-
specific key under which is ControlModel stored in ControlFactory.
no setter
- hasControl → bool
-
Checks if controls is not empty.
no setterinherited
- hashCode → int
-
The hash code for this object.
no setterinherited
- holder → ControlArgHolder
-
finalinherited
- isInitialized → bool
-
Returns 'true' if State is hooked and
WidgetControlHolder
is initialized.no setterinherited - isValid → bool
-
Returns 'true' if Widget is active and
WidgetControlHolder
is not disposed. Widget is valid even when is not initialized yet.no setterinherited - key → Key?
-
Controls how one widget replaces another widget in the tree.
finalinherited
- localization → Localino
-
Instance of default Localino
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- scope → ControlScope
-
no setterinherited
-
state
→ ControlState<
ControlWidget> ? -
Widget's State
It's available just after ControlState is initialized.
no setterinherited
Methods
-
addArg(
dynamic args) → void -
Adds given
args
to this Widget's internal arg store.args
can be whatever - Map, List, Object, or any primitive.inherited -
build(
BuildContext context) → Widget -
StatelessWidget.build
StatefulWidget.build
inherited -
createElement(
) → StatefulElement -
Creates a StatefulElement to manage this widget's location in the tree.
inherited
-
createState(
) → ControlState< ControlWidget> -
Creates the mutable state for this widget at a given location in the tree.
inherited
-
debugDescribeChildren(
) → List< DiagnosticsNode> -
Returns a list of
DiagnosticsNode
objects describing this node's children.inherited -
debugFillProperties(
DiagnosticPropertiesBuilder properties) → void -
Add additional properties associated with the node.
inherited
-
dispose(
) → void -
Disposes and removes all controls.
Check DisposeHandler for different dispose strategies.
inherited
-
extractLocalization(
dynamic data, {String? locale, String? defaultLocale}) → String -
Localino.extractLocalization
inherited
-
getArg<
T> ({dynamic key, T? defaultValue}) → T? -
Returns value by given
key
and Type from this Widget's internal arg store.inherited -
getContext(
{bool root = false}) → BuildContext? -
Returns BuildContext of this Widget or 'root' context from ControlRootScope.
inherited
-
getControl<
T extends ControlModel?> ({dynamic key, dynamic args}) → T? -
Tries to find specific ControlModel. Looks up in current controls,
args
and dependency Store. Specific control is determined by Type andkey
.args
- Arguments to pass to ControlModel.inherited -
getScopeControl<
T extends ControlModel?> ({dynamic key, dynamic args}) → T? -
Returns ControlModel by given
T
orkey
from current UI Treeinherited -
init(
Map args) → void -
Init is typically called right after constructor by framework.
args
- Arguments passed from parent or through Factory.inherited -
initControl(
) → T? -
Tries to find or construct instance of requested Type.
If init
args
contains ControlModel of requested Type, it will be used as control, otherwise Control.get will provide requested ControlModel. Check initControls for more dependency possibilities. Returns ControlModel of given Type. -
initControls(
) → List< ControlModel> -
This is a place where to fill all required
ControlModel
s for this Widget. Called during Widget/State initialization phase.override -
localize(
String key) → String -
Localino.localize
inherited
-
localizeDynamic(
String key, {LocalizationParser? parser, dynamic defaultValue}) → dynamic -
Localino.localizeDynamic
inherited
-
localizeFormat(
String key, Map< String, String> params) → String -
Localino.localizeFormat
inherited
-
localizeList(
String key) → Iterable< String> -
Localino.localizeList
inherited
-
localizeOr(
String key, List< String> alterKeys) → String -
Localino.localizeOr
inherited
-
localizePlural(
String key, int plural, [Map< String, String> ? params]) → String -
Localino.localizePlural
inherited
-
localizeValue(
String key, String value) → String -
Localino.localizeValue
inherited
-
mount<
T> ({dynamic key, T init()?, bool stateNotifier = false}) → T? -
Returns value by given
key
and Type from this Widget's internal arg store. If object is not found, then widget willinit
and store it to args. Object is also registered for dispose.inherited -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
notifyState(
[dynamic state]) → void -
inherited
-
onDependencyChanged(
) → void -
Called whenever dependency of Widget is changed.
Check State.didChangeDependencies for more info.
inherited
-
onInit(
Map args) → void -
inherited
-
onInitState(
ControlState< ControlWidget> state) → void -
Called during State initialization.
Widget will subscribe to all controls.
Typically now need to override - check onInit and onUpdate functions.
inherited
-
onStateChanged(
dynamic state) → void -
Callback from State when state is notified.
inherited
-
onStateUpdate(
CoreWidget oldWidget, CoreState< CoreWidget> state) → void -
Executed when State is changed and new
state
is available. Widget will try to resurrect State and injects args from 'cache' in holder.inherited -
onUpdate(
CoreWidget oldWidget) → void -
Called whenever Widget needs update.
Check State.didUpdateWidget for more info.
inherited
-
register(
Disposable? object) → void -
Registers object to lifecycle of State.
inherited
-
registerStateNotifier(
dynamic object) → void -
inherited
-
removeArg<
T> ({dynamic key}) → void -
Removes given
arg
from this Widget's internal arg store.inherited -
setArg<
T> ({dynamic key, required dynamic value}) → void -
Adds given
args
to this Widget's internal arg store.args
can be whatever - Map, List, Object, or any primitive.inherited -
toDiagnosticsNode(
{String? name, DiagnosticsTreeStyle? style}) → DiagnosticsNode -
Returns a debug representation of the object that is used by debugging
tools and by DiagnosticsNode.toStringDeep.
inherited
-
toString(
{DiagnosticLevel minLevel = DiagnosticLevel.info}) → String -
A string representation of this object.
inherited
-
toStringDeep(
{String prefixLineOne = '', String? prefixOtherLines, DiagnosticLevel minLevel = DiagnosticLevel.debug}) → String -
Returns a string representation of this node and its descendants.
inherited
-
toStringShallow(
{String joiner = ', ', DiagnosticLevel minLevel = DiagnosticLevel.debug}) → String -
Returns a one-line detailed description of the object.
inherited
-
toStringShort(
) → String -
A short, textual description of this widget.
inherited
-
unregister(
Disposable? object) → void -
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited