rulers 1.0.3

Rulers #

A Flutter Widget to show Ruler with selected values Example code is here

Flutter Rulers

Getting Started #

Include #

You should ensure that you add the following dependency in your Flutter project.

dependencies:
 rulers: "^1.0.0"

You should then run flutter packages get in terminal.

Import #

In your Dart code, to use it:

import 'package:rulers/rulers.dart';

Example #

In your Dart code, to use it:

        Container(
                  margin: const EdgeInsets.only(top: 8.0),
                  child: RulerWidget(
                    scaleSize: 100,
                    scaleColor: Colors.yellow,
                    indicatorWidget: Image.asset(
                                         'assets/marker.png',
                                         color: Colors.red,
                                         height: 25,
                                         width: 25,
                                       ),
                    limit: 24,
                    interval: 3,
                    lowerLimit: 2,
                    midLimitLower: 4,
                    midLimitUpper: 7,
                    upperLimit: 8,
                    normalBarColor: Colors.grey,
                    inRangeBarColor: Colors.green,
                    behindRangeBarColor: Colors.orangeAccent,
                    outRangeBarColor: Colors.red,
                  ),
                ),

Project Created & Maintained By

Shivam Srivastava #

For help getting started with Flutter, view our online documentation.

[1.0.0]

  • initial release.

example/main.dart

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

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

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
          primarySwatch: Colors.blue,
          textTheme: TextTheme(
              title: TextStyle(
                  color: Colors.black,
                  fontWeight: FontWeight.bold,
                  fontSize: 20))),
      home: Demo(),
    );
  }
}

class Demo extends StatefulWidget {
  @override
  _DemoState createState() => _DemoState();
}

/*
As for Example only here
              * Limit is 24 as time in hours
              * interval 3 as 15,30,45 min
              *
              *
              * */

class _DemoState extends State<Demo> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text('Rulers Example'),
      ),
      body: Padding(
        padding: const EdgeInsets.all(8.0),
        child: SingleChildScrollView(
          child: Padding(
            padding: const EdgeInsets.only(top: 20.0),
            child: Column(
              mainAxisSize: MainAxisSize.min,
              children: <Widget>[
                Text(
                  'Normal Scale',
                  style: Theme.of(context).textTheme.title,
                ),
                Container(
                  margin: const EdgeInsets.only(top: 8.0),
                  child: RulerWidget(
                    scaleSize: 100,
                    scaleColor: Colors.grey[100],
                    indicatorWidget: Column(
                      children: <Widget>[
                        Icon(
                          Icons.arrow_drop_down,
                          color: Colors.red,
                        ),
                      ],
                    ),
                    limit: 24,
                    interval: 3,
                    normalBarColor: Colors.grey,
                  ),
                ),
                Padding(
                  padding: const EdgeInsets.only(top: 20.0),
                  child: Text(
                    'In and Out Range Scale',
                    style: Theme.of(context).textTheme.title,
                  ),
                ),
                Container(
                  margin: const EdgeInsets.only(top: 8.0),
                  child: RulerWidget(
                    scaleSize: 100,
                    scaleColor: Colors.grey[100],
                    indicatorWidget: Column(
                      children: <Widget>[
                        Icon(
                          Icons.arrow_drop_down,
                          color: Colors.red,
                        ),
                      ],
                    ),
                    limit: 24,
                    interval: 3,
                    lowerLimit: 2,
                    midLimitLower: 2,
                    midLimitUpper: 6,
                    upperLimit: 6,
                    normalBarColor: Colors.grey,
                    inRangeBarColor: Colors.green,
                    behindRangeBarColor: Colors.orangeAccent,
                    outRangeBarColor: Colors.red,
                  ),
                ),
                Padding(
                  padding: const EdgeInsets.only(top: 20.0),
                  child: Text(
                    'In,Out,Mid Range Scale',
                    style: Theme.of(context).textTheme.title,
                  ),
                ),
                Container(
                  margin: const EdgeInsets.only(top: 8.0),
                  child: RulerWidget(
                    scaleSize: 100,
                    scaleColor: Colors.yellow,
                    indicatorWidget: Icon(
                      Icons.arrow_drop_down,
                      color: Colors.red,
                    ),
                    limit: 24,
                    interval: 3,
                    lowerLimit: 2,
                    midLimitLower: 4,
                    midLimitUpper: 7,
                    upperLimit: 8,
                    normalBarColor: Colors.grey,
                    inRangeBarColor: Colors.green,
                    behindRangeBarColor: Colors.orangeAccent,
                    outRangeBarColor: Colors.red,
                  ),
                ),
                Padding(
                  padding: const EdgeInsets.only(top: 20.0),
                  child: Text(
                    'Custom Marker Scale',
                    style: Theme.of(context).textTheme.title,
                  ),
                ),
                Container(
                  margin: const EdgeInsets.only(top: 8.0),
                  child: RulerWidget(
                    scaleSize: 100,
                    scaleColor: Colors.blue[100],
                    indicatorWidget: Image.asset(
                      'assets/marker.png',
                      color: Colors.red,
                      height: 25,
                      width: 25,
                    ),
                    limit: 24,
                    interval: 3,
                    lowerLimit: 2,
                    midLimitLower: 2,
                    midLimitUpper: 7,
                    upperLimit: 7,
                    normalBarColor: Colors.grey,
                    inRangeBarColor: Colors.green,
                    behindRangeBarColor: Colors.orangeAccent,
                    outRangeBarColor: Colors.red,
                  ),
                ),
                Padding(
                  padding: const EdgeInsets.only(top: 20.0),
                  child: Text(
                    'Horizontal Scale',
                    style: Theme.of(context).textTheme.title,
                  ),
                ),
                Container(
                  margin: const EdgeInsets.only(top: 8.0),
                  alignment: Alignment.centerLeft,
                  child: RulerWidget(
                    scaleColor: Colors.grey[100],
                    scaleSize: 100,
                    indicatorWidget: Column(
                      children: <Widget>[
                        Icon(
                          Icons.arrow_drop_down,
                          color: Colors.red,
                        ),
                      ],
                    ),
                    limit: 20,
                    interval: 4,
                    lowerLimit: 0,
                    midLimitLower: 0,
                    midLimitUpper: 0,
                    upperLimit: 0,
                    normalBarColor: Colors.grey,
                    inRangeBarColor: Colors.green,
                    behindRangeBarColor: Colors.orangeAccent,
                    outRangeBarColor: Colors.red,
                    axis: Axis.vertical,
                  ),
                ),
              ],
            ),
          ),
        ),
      ),
    );
  }
}

Use this package as a library

1. Depend on it

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


dependencies:
  rulers: ^1.0.3

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:rulers/rulers.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
46
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
92
Overall:
Weighted score of the above. [more]
71
Learn more about scoring.

We analyzed this package on Aug 21, 2019, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.4.0
  • pana: 0.12.19
  • Flutter: 1.7.8+hotfix.4

Platforms

Detected platforms: Flutter

References Flutter, and has no conflicting libraries.

Health suggestions

Fix lib/src/RulerWidget.dart. (-0.50 points)

Analysis of lib/src/RulerWidget.dart reported 1 hint:

line 127 col 7: This class (or a class which this class inherits from) is marked as '@immutable', but one or more of its instance fields are not final: RulerBar.type, RulerBar.num, RulerBar.midInterval, RulerBar.lowerLimit, RulerBar.upperLimit, RulerBar.midLimitLower, RulerBar.midLimitUpper, RulerBar.normalBarColor, RulerBar.inRangeBarColor, RulerBar.outRangeBarColor, RulerBar.behindRangeBarColor, RulerBar.indicatorWidget, RulerBar.axis, RulerBar.spacing, RulerBar.children, RulerBar.show

Format lib/src/AppUtils.dart.

Run flutter format to format lib/src/AppUtils.dart.

Maintenance suggestions

The package description is too short. (-8 points)

Add more detail to the description field of pubspec.yaml. Use 60 to 180 characters to describe the package, what it does, and its target use case.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.1.0 <3.0.0
flutter 0.0.0
Transitive dependencies
collection 1.14.11 1.14.12
meta 1.1.6 1.1.7
sky_engine 0.0.99
typed_data 1.1.6
vector_math 2.0.8
Dev dependencies
flutter_test