Site icon Flutter Packages | Pub dev Packages – Flutter Mobile App World

Flutter Number Picker Widget

Flutter Number Picker is a custom widget designed for choosing an integer or decimal number by using add and minus buttons.

Getting Started

  1. 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
  1. Run flutter packages get or use the GUI equivalent
  2. Now in your code import 'package:flutter_number_picker/flutter_number_picker.dart';
  3. You’re ready to go!

Creating FlutterNumberPicker Widget

CustomNumberPicker(
              initialValue: 10000,
              maxValue: 1000000,
              minValue: 0,
              step: 10000,
              onValue: (value) {
                print(value.toString());
              },
            )

Attribute

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());
              },
            ),
          ),
        ),
      ),
    );
  }
}

Download Flutter Number Picker Widget source code on GitHub

https://github.com/phuongtinhbien/flutter_number_picker

Exit mobile version