button_picker 0.1.6
button_picker: ^0.1.6 copied to clipboard
Customizable Flutter number picker using buttons instead of scroll.
ButtonPicker #
Customizable Flutter number picker using buttons instead of scroll.
Getting Started #
- Head to
/pubspec.yamland addbutton_picker: ^0.1.0below dependencies like this:
dependencies:
flutter:
sdk: flutter
button_picker: ^0.1.0
- Run
flutter packages getor use the GUI equivalent - Now in your code
import 'package:button_picker/button_picker.dart'; - 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.stepdefines how much the value should increase or decrease on tap.horizontalrenders a horizontal ButtonPicker when set totrue.looplets the ButtonPicker count from the beginning when passingmaxValueor from the end when passingminValuewhen set totrue.paddingdefines the space between the buttons and the value.iconUp,iconDown,iconLeftandiconRightare the actual icons.iconUpRightColoris the color of the upper button whenhorizontal == falseand the color of the right button whenhorizontal == true.iconDownLeftColoris the color of the lower button whenhorizontal == falseand the color of the left button whenhorizontal == true.styleis theTextStyleof the value.

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