button_picker 0.1.2

ButtonPicker #

Customizable Flutter number picker using buttons instead of scroll.

Getting Started #

  1. Head to /pubspec.yaml and add button_picker: ^0.1.0 below dependencies like this:
dependencies:
  flutter:
    sdk: flutter
  button_picker: ^0.1.0
  1. Run flutter packages get or use the GUI equivalent
  2. Now in your code import 'package:button_picker/button_picker.dart';
  3. You're ready to go!

Example & Usage

ButtonPicker is designed to be customizable.

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

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

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        body: Center(
          child: ButtonPicker(
            minValue: 0,
            maxValue: 99,
            initialValue: 0,
            onChanged: (val) => print(val),
            step: 2.5,
            horizontal: false,
            loop: true,
            padding: 5.0,
            iconUp: Icons.keyboard_arrow_up,
            iconDown: Icons.keyboard_arrow_down,
            iconLeft: Icons.keyboard_arrow_left,
            iconRight: Icons.keyboard_arrow_right,
            iconUpRightColor: Colors.blue,
            iconDownLeftColor: Colors.blue,
            style: TextStyle(
              fontSize: 48.0,
              color: Colors.blue
            ),
          ),
        ),
      ),
    );
  }
}
  • minValue [required] is the minimum value of the ButtonPicker.
  • maxValue [required] is the maximum value of the ButtonPicker.
  • initialValue [required] is the value displayed on load.
  • onChanged [required] returns the current value.
  • step defines how much the value should increase or decrease on tap.
  • horizontal renders a horizontal ButtonPicker when set to true.
  • loop lets the ButtonPicker count from the beginning when passing maxValue or from the end when passing minValue when set to true.
  • padding defines the space between the buttons and the value.
  • iconUp, iconDown, iconLeft and iconRight are the actual icons.
  • iconUpRightColor is the color of the upper button when horizontal == false and the color of the right button when horizontal == true.
  • iconDownLeftColor is the color of the lower button when horizontal == false and the color of the left button when horizontal == true.
  • style is the TextStyle of the value.

ButtonPicker

Note: When both initialValue and step are integers, the value won't have any decimals.

License #

MIT

[0.1.0] - Initial Release

Nothing special here.

example/lib/main.dart

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

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

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        body: Center(
          child: ButtonPicker(
            minValue: 0, /// required
            maxValue: 99, /// required
            initialValue: 0, /// required
            onChanged: (val) => print(val), /// required
            step: 2.5,
            horizontal: false,
            loop: true,
            padding: 5.0,
            iconUp: Icons.keyboard_arrow_up,
            iconDown: Icons.keyboard_arrow_down,
            iconLeft: Icons.keyboard_arrow_left,
            iconRight: Icons.keyboard_arrow_right,
            iconUpRightColor: Colors.blue,
            iconDownLeftColor: Colors.blue,
            style: TextStyle(
              fontSize: 48.0,
              color: Colors.blue
            ),
          ),
        ),
      ),
    );
  }
}

Use this package as a library

1. Depend on it

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


dependencies:
  button_picker: ^0.1.2

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

We analyzed this package on Jul 17, 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.3

Platforms

Detected platforms: Flutter

References Flutter, and has no conflicting libraries.

Maintenance suggestions

Homepage URL is insecure. (-5 points)

Update the homepage field and use a secure (https) URL.

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
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

Admin