MorphSwitch class
- Inheritance
-
- Object
- DiagnosticableTree
- Widget
- StatefulWidget
- MorphSwitch
Constructors
-
MorphSwitch.new({Key? key, required bool stateValue, void onSwitch(bool)?, void onSwipeLeft(bool)?, void onSwipeRight(bool)?, double borderWidth = 1.3, bool hasHover = true, String? offBgImage, String offLabel = "", String onLabel = "", TextStyle? onLabelStyle, TextStyle? offLabelStyle, String? onBgImage, IconData? thumbOnIcon, IconData? thumbOffIcon, Color borderColor = const Color(0xFF4B2B30), Color? onBgColor, Color? offBgColor, Color thumbBorderColor = const Color(0x00000000), Color thumbOnBgColor = const Color(0xFF2196F3), Color thumbOffBgColor = const Color(0xFF9E9E9E), double thumbRadius = 18.0, bool isVertical = false, Curve switchCurve = Curves.bounceOut, IconData? onBgIcon, IconData? offBgIcon, double? width, double? height, bool applyThumbRotationAnimation = true, EdgeInsetsGeometry margin = EdgeInsets.zero, double squareThumbRadius = 7.0, double thumbBorderWidth = 1.0, Color? thumbIconColor, int durationInMs = 1000, double offOpacity = 1.0, double textPadding = 12.0, TextDirection direction = TextDirection.ltr, List<
BoxShadow> ? boxShadow, ImageTransitionAnimationStyle imageTransitionStyle = ImageTransitionAnimationStyle.fade, SwitcherRadius switcherRadius = const SwitcherRadius.all(radius: 5.0), IconTransitionStyle iconTransitionStyle = IconTransitionStyle.scale, GlassProperties glassProperties = const GlassProperties.init(), ThumbType thumbType = ThumbType.circle, SwitcherSize size = SwitcherSize.xSmall, bool disabled = false, LinearGradient? onGradient, LinearGradient? offGradient})
Properties
- applyThumbRotationAnimation → bool
-
Whether to apply rotation animation to thumb
final
- borderColor → Color
-
Border color of the switch
final
- borderWidth → double
-
Border width of the switch
final
-
boxShadow
→ List<
BoxShadow> ? -
Box shadow effects on the outer part of the switch
final
- direction → TextDirection
-
TextDirection of the switch
Setting the value to TextDirection.rtl need to make some modifcation
final
- disabled → bool
-
Disable the button
This property also decrease the value of the
opacity
to 0.4final - durationInMs → int
-
Animation duration in milliseconds
final
- glassProperties → GlassProperties
-
Glass layer effect configuration
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- hasHover → bool
-
Whether to show hover effects
final
- height → double?
-
Custom height (if null, uses size preset from morphSwitchSizes)
final
- iconTransitionStyle → IconTransitionStyle
-
Animation style for icon transitions
final
- imageTransitionStyle → ImageTransitionAnimationStyle
-
Animation style for background image transitions
final
- isVertical → bool
-
Whether to display switch vertically
final
- key → Key?
-
Controls how one widget replaces another widget in the tree.
finalinherited
- margin → EdgeInsetsGeometry
-
External margin around the switch
final
- offBgColor → Color?
-
Background color when switch is OFF
final
- offBgIcon → IconData?
-
Background icon when switch is OFF
final
- offBgImage → String?
-
Background image path when switch is OFF
final
- offGradient → LinearGradient?
-
Gradient background of the MorphSwitch off state
final
- offLabel → String
-
Text label displayed when switch is OFF
final
- offLabelStyle → TextStyle?
-
Icon displayed on the thumb when switch is ON
final
- offOpacity → double
-
Opacity when switch is OFF (0.0 to 1.0)
final
- onBgColor → Color?
-
Background color when switch is ON
final
- onBgIcon → IconData?
-
Background icon when switch is ON
final
- onBgImage → String?
-
Background image path when switch is ON
final
- onGradient → LinearGradient?
-
Gradient background of the MorphSwitch on state
final
- onLabel → String
-
Text label displayed when switch is ON
final
- onLabelStyle → TextStyle?
-
Text style for the ON label
final
- onSwipeLeft → void Function(bool)?
-
Callback when switch is swiped left
Just in case another action with swiping left needed
By defualt it set the MorphSwitch to false by default (offState)
final
- onSwipeRight → void Function(bool)?
-
Callback when switch is swiped right
final
- onSwitch → void Function(bool)?
-
Callback when switch is tapped/clicked
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- size → SwitcherSize
-
Preset size configuration
According to the value passed to MorphSwitch
It will catch the size from morphSwitchSizes
CANNOT be, if custom size(width || height || thumbRadius)
Modify the needed and the size prperty will be ignored
final
- squareThumbRadius → double
-
Border radius for square thumb shape
final
- stateValue → bool
-
Current state of the switch (true = on, false = off)
final
- switchCurve → Curve
-
Animation curve for thumb movement
final
- switcherRadius → SwitcherRadius
-
Border radius configuration for the switch SwitcherRadius
final
- textPadding → double
-
Text || Icon in the background padding
This value gives the onLabel and offLabel moer padding
To expand the text in the MorphSwitch
When to change it ? => When
fontSize
needes to be increasedfinal - thumbBorderColor → Color
-
Border color of the thumb
final
- thumbBorderWidth → double
-
Border width of the thumb
final
- thumbIconColor → Color?
-
Color of the Icons on the Thumb
final
- thumbOffBgColor → Color
-
Thumb background color when OFF
final
- thumbOffIcon → IconData?
-
Icon displayed on the thumb when switch is OFF
final
- thumbOnBgColor → Color
-
Thumb background color when ON
final
- thumbOnIcon → IconData?
-
Icon displayed on the thumb when switch is ON
final
- thumbRadius → double
-
Radius of the thumb (affects size)
If width || height is not given MorphSwitch will skip the value
To modify thumbRadius width && height must be given
To give the thumbRadius other value with the same width && height
final
- thumbType → ThumbType
-
Shape of the thumb (circle or square)
final
- width → double?
-
Custom width (if null, uses size preset from morphSwitchSizes)
final
Methods
-
createElement(
) → StatefulElement -
Creates a StatefulElement to manage this widget's location in the tree.
inherited
-
createState(
) → State< MorphSwitch> -
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.
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