flutter number
flutter number picker is a custom widget designed for choosing an integer or decimal number by using add and minus buttons.
getting started
- head to
/pubspec.yaml
and add below dependencies like this:
dependencies:
flutter:
sdk: flutter
flutter_number_picker: <latest_version>
or
dependencies:
flutter:
sdk: flutter
flutter_number_picker:
git: https://github.com/phuongtinhbien/flutter_number_picker.git
- run
flutter packages get
or use the gui equivalent - now in your code
import 'package:flutter_number_picker/flutter_number_picker.dart';
- you’re ready to go!
creating flutternumberpicker widget
customnumberpicker(
initialvalue: 10000,
maxvalue: 1000000,
minvalue: 0,
step: 10000,
onvalue: (value) {
print(value.tostring());
},
)
attribute
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.onvalue
[required] returns the current value.step
defines how much the value should increase or decrease on tap.default
= 1.valuetextstyle
is thetextstyle
of the value.shape
is theshapeborder
of the picker.customaddbutton
is thewidget
.customaddbutton
is thewidget
.
usage examples
see examples directory for full examples.
standalone widget
class myapp extends statefulwidget {
@override
_myappstate createstate() => _myappstate();
}
class _myappstate extends state<myapp> {
@override
void initstate() {
super.initstate();
}
// platform messages are asynchronous, so we initialize in an async method.
@override
widget build(buildcontext context) {
return materialapp(
home: scaffold(
appbar: appbar(
title: const text('plutter number picker'),
),
body: center(
child: container(
child: customnumberpicker(
initialvalue: 10000,
maxvalue: 1000000,
minvalue: 0,
step: 10000,
onvalue: (value) {
print(value.tostring());
},
),
),
),
),
);
}
}
Comments are closed.