MiDivider
The MiDivider component is a Flutter widget that creates a customizable divider line, configurable via JSON.
Overview
MiDivider extends MiStatelessWidget, serving as a visual separator in user interfaces. It supports both solid and dotted styles, with customizable thickness, direction, and dash properties.
Component Name: divider
JSON key: "component": "divider".
Parameters
| Parameter Key | JSON Value Type | Flutter Type | Description | Default Value | Nullable | Requires Build |
|---|---|---|---|---|---|---|
direction | String | Axis | Specifies the direction of the divider. Accepts values "horizontal" or "vertical", determining the orientation of the divider line. Defaults to Axis.horizontal. | Axis.horizontal | Yes | No |
thickness | num | double | Sets the thickness of the divider line. Converted from JSON num to Flutter double using DoubleHelper.get. | 1.0 | Yes | No |
dotted | bool | bool | Determines whether the divider should be displayed as a dotted line. If true, a DottedLine widget is used; otherwise, a standard Divider is rendered. | false | Yes | No |
dashLength | num | double | Specifies the length of each dash in the dotted line. Converted from JSON num to Flutter double using DoubleHelper.get. | 4.0 | Yes | No |
dashGapLength | num | double | Specifies the gap length between dashes in the dotted line. Converted from JSON num to Flutter double using DoubleHelper.get. | 4.0 | Yes | No |
color | String | Color | The color of the divider. Can be a color name or hex code. (Inherited from MiStatelessWidget) | None (Intrinsic height) | Yes | No |
padding | List<num> | EdgeInsets | Padding to be applied around the divider. Expects a list of numbers representing padding values (e.g., [left, top, right, bottom]). (Inherited from MiStatelessWidget) | None | Yes | No |
margin | List<num> | EdgeInsets | Margin to be applied around the divider. Expects a list of numbers representing margin values (e.g., [left, top, right, bottom]). (Inherited from MiStatelessWidget) | None | Yes | No |
alignment | String | AlignmentGeometry | How the divider should be aligned within its allocated space. Accepts alignment keywords like 'topLeft', 'center', 'bottomRight', etc. (Inherited from MiStatelessWidget) | Defaults to topLeft | Yes | No |
Note:
- Inherited Parameters:
color,alignment,width,height,padding, andmarginare inherited parameters fromMiStatelessWidget(defined inMiStatelessWidget.dart), providing essential styling and positioning capabilities. - Dotted Line Behavior: When
dottedis set totrue, theMiDivideruses theDottedLinewidget, which requiresdashLengthanddashGapLengthto define the appearance of the dotted line. Ifdottedisfalse, a standardDivideris rendered with the specifiedthicknessandcolor. - Helper Classes: The
DoubleHelper.getis used for converting JSON values to the appropriate Flutter types forthickness,dashLength, anddashGapLength.
Example JSON Configurations
Example 1: Basic Horizontal Divider
{
"component": "divider",
"direction": "horizontal",
"thickness": 2,
"color": "grey"
}
Explanation of Example 1:
component: "divider"- Identifies this configuration as being for aMiDividercomponent.direction: "horizontal"- Specifies that the divider should be horizontal. This is the default behavior, but explicitly setting it clarifies intent.thickness: 2- Sets the thickness of the divider to2.0. This numeric JSON value is converted to a FlutterdoubleusingDoubleHelper.get.color: "grey"- Sets the color of the divider to grey. This string value is resolved to a FlutterColorobject.
Example 2: Dotted Vertical Divider
{
"component": "divider",
"direction": "vertical",
"dotted": true,
"dashLength": 6,
"dashGapLength": 3,
"color": "blue"
}
Explanation of Example 2:
component: "divider"- Identifies this configuration as being for aMiDividercomponent.direction: "vertical"- Specifies that the divider should be vertical, creating a vertical separation in the layout.dotted: true- Enables the dotted line style for the divider. This will render aDottedLinewidget instead of a standardDivider.dashLength: 6- Sets the length of each dash in the dotted line to6.0. This value is converted to a FlutterdoubleusingDoubleHelper.get.dashGapLength: 3- Sets the gap between dashes to3.0, also converted to a Flutterdouble.color: "blue"- Sets the color of the dotted line to blue, demonstrating color customization.