Segment display widget for Flutter

Overview

Segment display widget

Segment display

Pub Build Status Demo

Segment display widget for Flutter. Supports multiple types of segment displays and segment customization.

Contents

Features

  • 7-segment display
  • 14-segment display
  • 16-segment display
  • Customizable segment shapes (segment styles)
  • Supports . (decimal point) and : (colon) characters

See WEB DEMO.

Installation

  1. Depend on it

Add this to your package's pubspec.yaml file:

dependencies:
  segment_display: ^0.5.0
  1. 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.

  1. Import it

Now in your Dart code, you can use:

import 'package:segment_display/segment_display.dart';

Usage

Seven-segment display

CHARACTERS

Example:

SevenSegmentDisplay(
  value: "123",
  size: 12.0,
)

Seven-segment display

Fourteen-segment display

CHARACTERS

Example:

FourteenSegmentDisplay(
  value: "123",
  size: 12.0,
)

Fourteen-segment display

Sixteen-segment display

CHARACTERS

Example:

SixteenSegmentDisplay(
  value: "123",
  size: 12.0,
)

Sixteen-segment display

Styles and customization

You can customize segment display with:

  • characterSpacing- space between individual characters
  • backgroundColor - display background color
  • segmentStyle - style for segments (shape, color,...), see segment style

Example:

SevenSegmentDisplay(
  text: "123",
  textSize: 12.0,
  characterSpacing: 10.0,
  backgroundColor: Colors.transparent,
  segmentStyle: HexSegmentStyle(
    enabledColor: Colors.red,
    disabledColor: Colors.red.withOpacity(0.15),
  ),
)

Segment style

To change segment color, size or shape, use segment style.

There are following segment styles:

  • DefaultSegmentStyle
    DefaultSegmentStyle
  • HexSegmentStyle
    HexSegmentStyle
  • RectSegmentStyle
    RectSegmentStyle

and you can also create or own style (shape) - see custom segment styles

Example:

SevenSegmentDisplay(
  value: "13:37",
  size: 12.0,
  segmentStyle: HexSegmentStyle(
    enabledColor: const Color(0xFF00FF00),
    disabledColor: const Color(0xFF00FF00).withOpacity(0.15),
    segmentBaseSize: const Size(1.0, 2.0),
  ),
)

Style example

  • enabledColor - color of enabled segments
  • disabledColor - color of disabled segments
  • segmentBaseSize - 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.

class CustomSegmentStyle extends SegmentStyle {

  const CustomSegmentStyle({
    Size segmentBaseSize,
    Color enabledColor,
    Color disabledColor,
  }) : super(
          segmentBaseSize: segmentBaseSize,
          enabledColor: enabledColor,
          disabledColor: disabledColor,
        );
  @override
  Path createHorizontalPath(SegmentPosition position, Size segmentSize) {
    // ...
  }
  
  @override
  Path createVerticalPath(SegmentPosition position, Size segmentSize) {
    // ...
  }
  
  @override
  Path createDiagonalBackwardPath(SegmentPosition position, Size segmentSize) {
    // ...
  }
  
  @override
  Path createDiagonalForwardPath(SegmentPosition position, Size segmentSize) {
    // ...
  }
}

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.

class CustomSegmentStyle extends SegmentStyle {

  // ..
  
  @override
  Path createPath7A(Size segmentSize, double padding) {
    // ...
  }
  
  // ...
  
}

NOTE: createPath** methods use createHorizontalPath/createVerticalPath/createDiagonalBackwardPath/createDiagonalForwardPath by default so you don't have to override all createPath7* methods.

Features and bugs

Please file feature requests and bugs at the issue tracker.

You might also like...

Flutter package to get keyboard height. Can be used to display a sticker/emoji modal with correct height.

Flutter package to get keyboard height. Can be used to display a sticker/emoji modal with correct height.

flutter_persistent_keyboard_height Flutter package to get keyboard height. The height is persisted during app sessions and keyboard states (you can us

Oct 17, 2022

A simple modal progress HUD (heads-up display, or progress indicator) for flutter

A simple modal progress HUD (heads-up display, or progress indicator) for flutter

modal_progress_hud A simple widget wrapper to enable modal progress HUD (a modal progress indicator, HUD = Heads Up Display) Inspired by this article.

Nov 22, 2022

A Flutter plugin for IOS and Android providing a simple way to display PDFs.

A Flutter plugin for IOS and Android providing a simple way to display PDFs.

Pdf Viewer Plugin A Flutter plugin for IOS and Android providing a simple way to display PDFs. Features: Display PDF. Installation First, add pdf_view

Sep 26, 2022

A flutter application to show and display recipes of foods.

meals A new Flutter project. Getting Started This project is a starting point for a Flutter application. A few resources to get you started if this is

Jan 3, 2022

Flutter plugin to display a simple numeric keyboard on Android & iOS

Flutter plugin to display a simple numeric keyboard on Android & iOS

numeric_keyboard A simple numeric keyboard widget Installation Add numeric_keyboard: ^1.1.0 in your pubspec.yaml dependencies. And import it: import '

Sep 27, 2022

Voxxedapp - A Flutter app for iOS and Android that display details about upcoming Voxxed Days

Voxxedapp - A Flutter app for iOS and Android that display details about upcoming Voxxed Days

voxxedapp - a Voxxed Days schedule app made with Flutter What is voxxedapp? It's an app that displays info about upcoming Voxxed Days conferences, inc

Oct 10, 2020

A project made for the ECV Digital 2022. 🌐 The goal being to make a Flutter application to connect, register and display information of a given API.👨🏼🔧

not_netflix A new Flutter project. Getting Started This project is a starting point for a Flutter application. A few resources to get you started if t

May 7, 2022
Comments
  • Add

    Add "-" support in seven-segment display

    As seen in the sample image, a dash/minus/hyphen is not supported. Looking at the structure of a seven-segment display this could totally be a valid use case.

    Could this be added?

    opened by jdepypere 1
  • Is it possible to define custom digits?

    Is it possible to define custom digits?

    I am searching for a widget that allows me to enable only a symbols. E.g., taking the definition of a 16 segment display, it would be great, only to enable the three segments "a1", "g2" and "b", no matter that it is not mapped to any valid character.

    Is this possible?

    Next step would be to tap on an display segment and it would be enabled/disabled, giving out the tapped segment. E.g. If segment a is red, tap it -> turn into black and give out "a = false". Tap it again, enable it, give out "a = true".

    Now you would be able to handle the display in any way you like... Show random patterns, like rotating cursor or something like that...

    opened by S-Man42 0
Owner
Jan Štol
Work Time Tracking where automation works for you! - https://workvector.com/
Jan Štol
Flutter ticket pass - A Flutter Widget to display the details of a ticket/pass purchased by customers and display the details of the purchase

ticket_pass_package A Flutter package to display the purchase of a ticket/pass along with additional details such as list of buyers. The source code i

null 40 Aug 13, 2022
Display images flutter - Simple app to display images in flutter

Display Images In Flutter Simple app to display images in a flutter. In this dem

Manish Ahire 1 Jan 29, 2022
Flutter plugin to display a popup menu button widget with handsome design and easy to use.

menu_button Flutter widget to display a popup menu button very simply and easily customizable. Resources Documentation Pub Package GitHub Repository I

Hugo EXTRAT 63 Sep 27, 2022
Flutter plugin to display a simple steps indicator line widget

steps_indicator A simple steps indicator widget Installation Add steps_indicator: ^1.3.0 in your pubspec.yaml dependencies. And import it: import 'pac

Hugo EXTRAT 49 Oct 18, 2022
Flutter Widget to display gradient text

GradientText A Flutter Widget for displaying gradient text, text with a gradient drawn through it. Getting Started Add the plugin (pub coming soon): d

Tony Owen 28 Nov 4, 2022
🧾 Flutter widget allowing easy cache-based data display in a ListView featuring pull-to-refresh and error banners.

Often, apps just display data fetched from some server. This package introduces the concept of fetchable streams. They are just like normal Streams, b

Marcel Garus 17 Jan 18, 2022
This library provides a customizable Flutter widget that makes it easy to display text in the middle of a Divider.

1. About 1.1. Introduction 1.1.1. Install Library 1.1.2. Import It 1.1.3. Use TextDivider 1.2. Details 1.2.1. Customization Options 1.2.2. Horizontal

Kato Shinya 2 Feb 9, 2022
Clock loader - Highly versatile Widget display the smooth and creative loader named as clock loader

Clock Loader Highly versatile Widget display the smooth and creative loader name

MindInventory 20 Dec 30, 2022
Animated shimmer - A simple & lightweight widget to display an animated shimmer effect

Animated Shimmer Supports Null Safety A simple & lightweight widget to display a

Shubham Soni 7 Apr 27, 2022
Widget to count the amount of nested widget tree, useful in the dynamic construction of the interface when it is important to know the depth of widget.

widget_tree_depth_counter Widget Tree Depth Counter WidgetTreeDepthCounter is a simple widget to count the amount of nested widget tree, useful in the

Riccardo Cucia 4 Aug 1, 2022