HakoProvider<H extends BaseHako> class

A Provider widget that provides a specific Hako instance to its descendants and rebuilds dependents whenever a 'set' operation is correctly performed.

HakoProvider exposes a Hako instance to the widget tree, enabling descendants to access and react to state changes. It automatically rebuilds listening widgets when state modifications occur through the Hako's set method.

HakoProvider offers two constructors:

  • The default constructor for creating new Hako instances
  • The .value constructor for providing existing instances

When providing an existing instance using .value, the instance will not be automatically disposed when the provider is removed from the widget tree.

Example:

// Creating a new instance
HakoProvider<CounterHako>(
  create: (context) => CounterHako(),
  child: MyApp(),
)

// Providing an existing instance
HakoProvider<CounterHako>.value(
  value: existingCounterHako,
  child: MyApp(),
)

Lazy Initialization

Control when Hako instances are created using the lazy parameter:

// Lazy initialization (default) - created only when first accessed
HakoProvider<CounterHako>(
  lazy: true, // or omit since it's the default
  create: (context) => CounterHako(),
  child: MyApp(),
)

// Eager initialization - created immediately when provider is built
HakoProvider<CounterHako>(
  lazy: false,
  create: (context) => CounterHako(),
  child: MyApp(),
)
Inheritance
Implemented types

Constructors

HakoProvider({required Create<H> create, Widget? child, bool? lazy, Key? key})
Creates a new HakoProvider that creates and provides a Hako instance to its descendants.
HakoProvider.value({required H value, Widget? child, Key? key})
Creates a new HakoProvider that provides an existing Hako instance to its descendants.

Properties

builder TransitionBuilder?
Syntax sugar for obtaining a BuildContext that can read the provider created.
finalinherited
hashCode int
The hash code for this object.
no setterinherited
key Key?
Controls how one widget replaces another widget in the tree.
finalinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

build(BuildContext context) Widget
Describes the part of the user interface represented by this widget.
inherited
buildWithChild(BuildContext context, Widget? child) Widget
A build method that receives an extra child parameter.
inherited
createElement() → _InheritedProviderElement<_HakoNotifier<H>>
Creates a StatelessElement to manage this widget's 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
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
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, int wrapWidth = 65}) 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

Operators

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