customgauge 1.0.1

  • Readme
  • Changelog
  • Example
  • Installing
  • 89

customgauge #

Fully customizable Gauge widget for Flutter

Installing: #

In your pubspec.yaml, add the following dependency

dependencies:
  customgauge: 1.0.0

Example Usage: #

import 'package:customgauge/customgauge.dart';

CustomGauge(
    gaugeSize: 200,
    segments: [
        GaugeSegment('Low', 20, Colors.red),
        GaugeSegment('Medium', 40, Colors.orange),
        GaugeSegment('High', 40, Colors.green),
    ],
    currentValue: 46,
    displayWidget: Text('Fuel in tank', style: TextStyle(fontSize: 12)),
),

Features: #

  • Fully featured Gauge widget that is built from scratch
  • Can have any number of segments in the Gauge with different segment length and colors
  • Gauge can have any dimension (square dimension only) with any minimum and maximum value
  • Needle color can be customized
  • Display and Value widget can be customized, so that you can display what you want on the Gauge
  • Can turn on/off markers that display Min and Max value on the Gauge. You can even style these markers!

License: #

This project is licensed under the BSD 2-Clause license - see the LICENSE file for details

1.0.1 #

  • Minor updates in response to Flutter pub suggestions

example/lib/main.dart

import 'package:flutter/material.dart';
import 'package:customgauge/customgauge.dart';

void main() => runApp(MyApp());

class MyApp extends StatefulWidget {
  @override
  _MyAppState createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      debugShowCheckedModeBanner: false,
        home: Scaffold(
      appBar: AppBar(
        title: const Text('CustomGauge example app'),
      ),
      body: Container(
          color: Colors.grey[200],
          child: Column(
            mainAxisAlignment: MainAxisAlignment.spaceEvenly,            
            children: <Widget>[
            Row(children: <Widget>[
              CustomGauge(
                gaugeSize: 200,
                segments: [
                  GaugeSegment('Low', 20, Colors.red),
                  GaugeSegment('Medium', 40, Colors.orange),
                  GaugeSegment('High', 40, Colors.green),
                ],
                currentValue: 60,
                displayWidget:
                    Text('Fuel in tank', style: TextStyle(fontSize: 12)),
              ),
              CustomGauge(
                gaugeSize: 200,
                segments: [
                  GaugeSegment('Critically Low', 10, Colors.red),
                  GaugeSegment('Low', 20, Colors.orange),
                  GaugeSegment('Medium', 20, Colors.yellow),
                  GaugeSegment('High', 50, Colors.green),
                ],
                currentValue: 45,
                needleColor: Colors.red,
                showMarkers: false,
                displayWidget:
                    Text('Fuel in tank', style: TextStyle(fontSize: 12)),
              ),
            ]),
            Row(children: <Widget>[
              CustomGauge(
                gaugeSize: 100,
                segments: [
                  GaugeSegment('Low', 20, Colors.blue[200]),
                  GaugeSegment('Medium', 40, Colors.blue),
                  GaugeSegment('High', 40, Colors.blue[800]),
                ],
                currentValue: 70,
                displayWidget:
                    Text('Temp', style: TextStyle(fontSize: 12)),
              ),
              CustomGauge(
                gaugeSize: 100,
                segments: [
                  GaugeSegment('Critically Low', 10, Colors.red),
                  GaugeSegment('Low', 20, Colors.orange),
                  GaugeSegment('Medium', 20, Colors.yellow),
                  GaugeSegment('High', 50, Colors.green),
                ],
                currentValue: 45,
                needleColor: Colors.blue,
                showMarkers: false,
                valueWidget: Container(),
                displayWidget:
                    Text('Fuel', style: TextStyle(fontSize: 12)),
              ),
              CustomGauge(
                gaugeSize: 100,
                minValue: 30,
                maxValue: 150,
                segments: [
                  GaugeSegment('Low', 20, Colors.red),
                  GaugeSegment('Slightly Low', 20, Colors.yellow),
                  GaugeSegment('Correct', 20, Colors.green),
                  GaugeSegment('High', 60, Colors.orange),
                ],
                currentValue: 72,
                displayWidget:
                    Text('Pulse', style: TextStyle(fontSize: 12)),
              ),
              CustomGauge(
                minValue: 0,
                maxValue: 150,
                gaugeSize: 100,
                segments: [
                  GaugeSegment('Good', 80, Colors.green),
                  GaugeSegment('High', 70, Colors.red),
                ],
                currentValue: 75,
                showMarkers: false,
                displayWidget:
                    Text('Speed', style: TextStyle(fontSize: 12)),
              ),
            ])
          ])),
    ));
  }
}

Use this package as a library

1. Depend on it

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


dependencies:
  customgauge: ^1.0.1

2. Install it

You can install packages from the command line:

with Flutter:


$ flutter pub get

Alternatively, your editor might support flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:customgauge/customgauge.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
77
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
100
Overall:
Weighted score of the above. [more]
89
Learn more about scoring.

We analyzed this package on Jul 14, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.8.4
  • pana: 0.13.15
  • Flutter: 1.17.5

Analysis suggestions

Package not compatible with SDK dart

Because:

  • customgauge that is a package requiring null.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.3.0 <3.0.0
flutter 0.0.0
Transitive dependencies
collection 1.14.12 1.14.13
meta 1.1.8 1.2.2
sky_engine 0.0.99
typed_data 1.1.6 1.2.0
vector_math 2.0.8 2.1.0-nullsafety
Dev dependencies
flutter_test