segment_bar 0.0.3

SDKflutter
Platformandroidioswindowslinuxmacosweb

SegmentBar is a lightweight package for creating a customizable segment bar widget in Flutter, with support for different colors and percentage values for each segment.

Segment Bar

A flutter package that shows a different colored segments in a row, each color showing a percentage of the value.

Installation

Add the package to your pubspec.yaml dependencies:

dependencies:
segment_bar: ^0.0.3

Usage

import 'package:segment_bar/segment_bar.dart';

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        body: Center(
          child: SegmentBar(
            segmentData: [
              SegmentBarModel(value: 50, color: Colors.red),
              SegmentBarModel(value: 50, color: Colors.green),
            ],
          ),
        ),
      ),
    );
  }
}

properties

NameTypeDefaultDescription
segmentDataList[]The data to be shown in the widget.
heightdouble20Optional. The height of the widget. Default is 20.
radiusdouble0Optional. The radius of the widget. Default is 6.

SegmentBarModel

This model is used to represent each segment of the bar

NameTypeDefaultDescription
valuedouble0The value of the segment.
colorColorColors.blackThe color of the segment.

Example

SegmentBar(
  segmentData: [
    SegmentBarModel(value: 50, color: Colors.red),
    SegmentBarModel(value: 50, color: Colors.green),
  ],
  height: 20,
  radius: 6,
)

In this example, the widget will show a red and green segment, each taking up 50% of the total width.