awesome_number_picker 0.0.4 copy "awesome_number_picker: ^0.0.4" to clipboard
awesome_number_picker: ^0.0.4 copied to clipboard

This app is a vertical or horizontal scroll selector for users who want to select a number

example/lib/main.dart

import 'package:awesome_number_picker/awesome_number_picker.dart';
import 'package:example/scroll_behaviour.dart';
import 'package:flutter/material.dart';

void main() {
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({Key? key}) : super(key: key);

  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return const MaterialApp(
      title: 'Flutter Demo',
      scrollBehavior: CustomScrollBehavior(), //For web Scrolling
      home: HomePage(),
    );
  }
}

class HomePage extends StatefulWidget {
  const HomePage({Key? key}) : super(key: key);

  @override
  State<HomePage> createState() => _HomePageState();
}

class _HomePageState extends State<HomePage> {
  int integerValue = 0;
  double decimalValue = 0;
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(title: const Text("Awesome Number Picker")),
      body: Column(
        mainAxisAlignment: MainAxisAlignment.center,
        crossAxisAlignment: CrossAxisAlignment.center,
        children: [
          Row(
            mainAxisAlignment: MainAxisAlignment.spaceAround,
            crossAxisAlignment: CrossAxisAlignment.center,
            children: [
              const Text("Integer Value"),
              Text(integerValue.toString()),
            ],
          ),
          SizedBox(
            height: 150,
            child: IntegerNumberPicker(
              initialValue: 5,
              minValue: 0,
              maxValue: 10,
              onChanged: (i) => setState(() {
                integerValue = i;
              }),
            ),
          ),
          SizedBox(
            height: 150,
            child: IntegerNumberPicker(
              initialValue: 75,
              minValue: 50,
              maxValue: 100,
              axis: Axis.horizontal,
              onChanged: (i) => setState(() {
                integerValue = i;
              }),
            ),
          ),
          Row(
            mainAxisAlignment: MainAxisAlignment.spaceAround,
            crossAxisAlignment: CrossAxisAlignment.center,
            children: [
              const Text("Decimal Value"),
              Text(decimalValue.toStringAsFixed(3)),
            ],
          ),
          SizedBox(
            height: 150,
            child: DecimalNumberPicker(
              initialValue: 25.75,
              minValue: 0,
              maxValue: 100,
              decimalPrecision: 3,
              otherItemsDecoration: BoxDecoration(
                boxShadow: [
                  BoxShadow(
                    color: Colors.grey.withOpacity(.5),
                    blurRadius: 20.0, // soften the shadow
                    spreadRadius: 0.0, //extend the shadow
                  )
                ],
              ),
              pickedItemDecoration: BoxDecoration(
                boxShadow: [
                  BoxShadow(
                    color: Colors.blue.withOpacity(.5),
                    blurRadius: 20.0, // soften the shadow
                    spreadRadius: 0.0, //extend the shadow
                  )
                ],
              ),
              onChanged: (i) => setState(() {
                decimalValue = i;
              }),
            ),
          ),
        ],
      ),
    );
  }
}
20
likes
160
pub points
80%
popularity

Publisher

unverified uploader

This app is a vertical or horizontal scroll selector for users who want to select a number

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (license)

Dependencies

flutter

More

Packages that depend on awesome_number_picker