NeuToggle class
Create a new NeuToggle
, a StatefulWidget that builds a Neu.toggle
wrapped in a self-handling GestureDetector.
Similar in design to NeuContainer in that the resulting Widget
is
comprised of two stacked AnimatedContainers, the first of which holds the
base color and may employ insets to provide the inner Neu-design
container the opportunity to extrude or "rise" from the former.
The difference is that this StatefulWidget not only utilizes a
Neu.toggle to toggle neumorphic appearance states instead of manual
control over Curvature and Swell, but it also wraps the container with
a GestureDetector that will trigger its own Neu.toggle.isPressed
toggles
onTap/click and fire the onToggle callback with a bool of the new state.
See Neu.toggle for more information.
See also: AnimatedContainer, which this Widget
will render and from
which many if its parameters are copied.
- Inheritance
-
- Object
- DiagnosticableTree
- Widget
- StatefulWidget
- NeuToggle
Constructors
- NeuToggle({Key? key, Color color = lightWhite, int depth = defaultDepth, EdgeInsetsGeometry insets = EdgeInsets.zero, double spread = defaultSpread, Alignment lightSource = defaultLightSource, bool isFlat = false, bool isSuper = false, double depthMultiplier = defaultDepthMultiplier, double spreadMultiplier = defaultSpreadMultiplier, bool providesFeedback = false, AlignmentGeometry? alignment, double? width, double? height, EdgeInsetsGeometry? margin, EdgeInsetsGeometry? padding, BoxConstraints? constraints, ShapeBorder shape = defaultShape, Decoration? foregroundDecoration, Matrix4? transform, AlignmentGeometry? transformAlignment, Duration duration = defaultDuration, Curve curve = Curves.elasticOut, dynamic onToggle(bool)?, Widget? child})
-
A StatefulWidget that builds a Neu.toggle wrapped in a self-handling
GestureDetector.
const
Properties
- alignment → AlignmentGeometry?
-
Align the child within the container.
final
- child → Widget?
-
The child contained by the container.
final
- color → Color
-
With all Neu design the basis of these decorations is a color and a
depth. Color should ideally match with or be similar to the color of the
background behind the resulting decoration. The
depth
is the extent to which this decoration will appear "extruded" from its surface. A largerdepth
increases the contrast of the shading of colors on either side of the decoration.final - constraints → BoxConstraints?
-
Additional constraints to apply to the child.
final
- curve → Curve
-
The Curve by which to implicitly animate any changes to the properties
of this NeuToggle. Specifically, altering one of the fields in
constructor or toggling the state by tap/click will animate changes over
this animation curve.
final
- depth → int
-
With all Neu methods the basis of these decorations is a color and a
depth. Color should ideally match or be similar to the color of the
background behind the resulting decoration. The
depth
is the extent to which this decoration will appear "extruded" from its surface. A largerdepth
increases the contrast of the shading of colors on either side of the decoration.final - depthMultiplier → double
-
When in a state of
isToggled, [depthMultiplier] and [spreadMultiplier] are applied to [depth] and [spread] automatically. To remove this effect, pass a value of
1.0` for these multipliers.final - duration → Duration
-
How long any changes to the visual properties of this NeuToggle will
take to fully propagate and animate; changes could be either toggling its
state with a tap/click which will trigger onToggle with the current
status (
bool
) or by changing one of the fields, such as padding.final - foregroundDecoration → Decoration?
-
The Decoration to paint in front of the child.
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- height → double?
-
Limit the width or height of this NeuToggle, excluding any margin,
in logical pixels.
final
- insets → EdgeInsetsGeometry
-
A convenience to provide a padded, solid-color backdrop on which the true
container will be rendered. In a scenario where a background is not a
solid color that matches color, then insets may be initialized
non-negligibly (such as
EdgeInsets.all(25)
) to provide a small platform for the Neumorphic effect to be more visible.final - isFlat → bool
-
Further refine the appearance of the decorations with either
mutually-exclusive flag isFlat, which enforces the usage of
Curvature.flat regardless of
isToggled
state; or isSuper, which opts into using Curvatures and Swells that fit the Degree.SUPER description, increasing intensity and contrast.final - isSuper → bool
-
Further refine the appearance of the decorations with either
mutually-exclusive flag isFlat, which enforces the usage of
Curvature.flat regardless of
isToggled
state; or isSuper, which opts into using Curvatures and Swells that fit the Degree.SUPER description, increasing intensity and contrast.final - key → Key?
-
Controls how one widget replaces another widget in the tree.
finalinherited
- lightSource → Alignment
-
The lightSource is always set by default as
defaultLightSource
, which is Alignment.topLeft. This gives the illusion of lighting the entire neumorphic decoration from the top-left corner. All descriptions of gradient and shadow directionality and the illusion of being toggled or not toggled are based on this default light source. An overriding Alignment may be provided, however, to dynamically "relight" the decorations.final - margin → EdgeInsetsGeometry?
-
Empty space to surround the NeuToggle and any insets.
final
- onToggle → (dynamic Function(bool)?)
-
An optional function to perform any time the state of this NeuToggle
is toggled (tapped/clicked on).
final
- padding → EdgeInsetsGeometry?
-
Empty space to inscribe inside the Container. The child, if any, is
placed inside these EdgeInsets.
final
- providesFeedback → bool
-
A convenience flag for calling HapticFeedback.vibrate when triggering
onToggle as the state of this widget has been toggled (by tap or click).
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- shape → ShapeBorder
-
A ShapeBorder object provides a description of a shape for a decoration.
It can include information such as how round corners are to be or what the
border edges should look like.
final
- spread → double
-
In terms of Shadows, spread is responsible for determining how wide
an area the effect covers and how blurry the shadows appear.
final
- spreadMultiplier → double
-
When in a state of
isToggled, [depthMultiplier] and [spreadMultiplier] are applied to [depth] and [spread] automatically. To remove this effect, pass a value of
1.0` for these multipliers.final - transform → Matrix4?
-
The transformation matrix to apply before painting the container.
final
- transformAlignment → AlignmentGeometry?
-
The alignment of the origin, relative to the size of the container, if
transform is specified.
final
- width → double?
-
Limit the width or height of this NeuToggle, excluding any margin,
in logical pixels.
final
Methods
-
createElement(
) → StatefulElement -
Creates a StatefulElement to manage this widget's location in the tree.
inherited
-
createState(
) → _NeuToggleState -
Creates the mutable state for this widget at a given location in the tree.
override
-
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.
override
-
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}) → 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