Segment display widget
Segment display widget for Flutter. Supports multiple types of segment displays and segment customization.
Features
- 7-segment display
- 14-segment display
- 16-segment display
- Customizable segment shapes (segment styles)
- Supports
.
(decimal point) and:
(colon) characters
See WEB DEMO.
NOTE: Flutter web support is currently in beta, so you may experience some issues.
Installation
- Depend on it
Add this to your package's pubspec.yaml file:
- Install it
You can install packages from the command line:
$ flutter packages get
Alternatively, your editor might support flutter packages get. Check the docs for your editor to learn more.
- Import it
Now in your Dart code, you can use:
Usage
Seven-segment display
Example:
Fourteen-segment display
Example:
Sixteen-segment display
Example:
Styles and customization
You can customize segment display with:
characterSpacing
- space between individual charactersbackgroundColor
- display background colorsegmentStyle
- style for segments (shape, color,...), see segment style
Example:
Segment style
To change segment color, size or shape, use segment style.
There are following segment styles:
- DefaultSegmentStyle
- HexSegmentStyle
- RectSegmentStyle
and you can also create or own style (shape) - see custom segment styles
Example:
enabledColor
- color of enabled segmentsdisabledColor
- color of disabled segmentssegmentBaseSize
- size ratio for segments;Size(1.0, 2.0)
basically means that ratio will be 1:2 (width:length)
NOTE:
SegmentStyle.segmentBaseSize
*SegmentDisplay.textSize
= segmentSize
Custom segment styles
To create your own segment style (shape), extends SegmentStyle
class and implement methods
createHorizontalPath
, createVerticalPath
, createDiagonalBackwardPath
and createDiagonalForwardPath
.
You can also customize shape for individual segments by overriding createPath**
methods.
For 7-segment display, there are createPath7*
methods, for 14-segment display createPath14*
and so on.
Example: if you want to change the shape of the top segment in 7-segment display, you just have to override createPath7A
method.
NOTE:
createPath**
methods usecreateHorizontalPath
/createVerticalPath
/createDiagonalBackwardPath
/createDiagonalForwardPath
by default so you don't have to override allcreatePath7*
methods.