### NumberPickerDialog Usage Example Source: https://github.com/andrezanna/numberpicker/blob/master/README.md Shows how to display a decimal NumberPickerDialog using showDialog and update the UI state with the selected value. Includes a FloatingActionButton to trigger the dialog. ```dart class _MyHomePageState extends State { double _currentPrice = 1.0; _showDialog() { showDialog( context: context, child: new NumberPickerDialog.decimal( minValue: 1, maxValue: 10, title: new Text("Pick a new price"), initialDoubleValue: _currentPrice), ).then((value) { if (value != null) { setState(() => _currentPrice = value); } }); } @override Widget build(BuildContext context) { return new Scaffold( body: new Center( child: new Text("Current price: $_currentPrice "), ), appBar: new AppBar( title: new Text(widget.title), ), floatingActionButton: new FloatingActionButton( child: new Icon(Icons.attach_money), onPressed: _showDialog, ), ); } } ``` -------------------------------- ### Decimal NumberPickerDialog Example Source: https://context7.com/andrezanna/numberpicker/llms.txt Shows how to use NumberPickerDialog.decimal for selecting a price with a specified number of decimal places. It returns the selected double or null if cancelled. The 'numberpicker' package must be imported. ```dart import 'package:flutter/material.dart'; import 'package:numberpicker/numberpicker.dart'; class DecimalDialogExample extends StatefulWidget { @override _DecimalDialogExampleState createState() => _DecimalDialogExampleState(); } class _DecimalDialogExampleState extends State { double _currentPrice = 1.0; _showPriceDialog() { showDialog( context: context, child: NumberPickerDialog.decimal( minValue: 1, maxValue: 10, initialDoubleValue: _currentPrice, decimalPlaces: 2, title: Text("Pick a new price"), ), ).then((value) { if (value != null) { setState(() => _currentPrice = value); } }); } @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar(title: Text('Price Selector')), body: Center( child: Text("Current price: $${_currentPrice.toStringAsFixed(2)}"), ), floatingActionButton: FloatingActionButton( child: Icon(Icons.attach_money), onPressed: _showPriceDialog, ), ); } } ``` -------------------------------- ### Integer NumberPickerDialog Example Source: https://context7.com/andrezanna/numberpicker/llms.txt Demonstrates how to use NumberPickerDialog.integer to create a dialog for selecting an age. It returns the selected integer or null if cancelled. Ensure the 'numberpicker' package is imported. ```dart import 'dart:async'; import 'package:flutter/material.dart'; import 'package:numberpicker/numberpicker.dart'; class IntegerDialogExample extends StatefulWidget { @override _IntegerDialogExampleState createState() => _IntegerDialogExampleState(); } class _IntegerDialogExampleState extends State { int _currentAge = 25; Future _showAgeDialog() async { await showDialog( context: context, child: NumberPickerDialog.integer( minValue: 0, maxValue: 120, initialIntegerValue: _currentAge, title: Text("Select your age"), ), ).then((value) { if (value != null) { setState(() => _currentAge = value); } }); } @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar(title: Text('Age Selector')), body: Center( child: Text("Current age: $_currentAge"), ), floatingActionButton: FloatingActionButton( child: Icon(Icons.edit), onPressed: _showAgeDialog, ), ); } } ``` -------------------------------- ### Standalone NumberPicker Widget Example Source: https://github.com/andrezanna/numberpicker/blob/master/README.md Demonstrates integrating an integer NumberPicker widget within a Flutter Scaffold's body. Updates a Text widget and the internal state upon value change. ```dart class _MyHomePageState extends State { int _currentValue = 1; @override Widget build(BuildContext context) { return new Scaffold( body: new Center( child: new Column( mainAxisAlignment: MainAxisAlignment.center, children: [ new NumberPicker.integer( initialValue: _currentValue, minValue: 0, maxValue: 100, onChanged: (newValue) => setState(() => _currentValue = newValue)), new Text("Current number: $_currentValue"), ], ), ), appBar: new AppBar( title: new Text(widget.title), ), ); } } ``` -------------------------------- ### Create Integer NumberPicker Widget Source: https://github.com/andrezanna/numberpicker/blob/master/README.md Instantiate an integer NumberPicker with initial value, min/max bounds, and a change handler. ```dart new NumberPicker.integer( initialValue: 50, minValue: 0, maxValue: 100, onChanged: _handleChange) ``` -------------------------------- ### Create Decimal NumberPickerDialog Source: https://github.com/andrezanna/numberpicker/blob/master/README.md Instantiate a decimal NumberPicker dialog with min/max bounds and an initial double value. This is intended for use with showDialog. ```dart new NumberPickerDialog.decimal( minValue: 1, maxValue: 10, initialDoubleValue: _currentPrice) ``` -------------------------------- ### Create Integer NumberPicker Source: https://context7.com/andrezanna/numberpicker/llms.txt Use NumberPicker.integer for selecting whole numbers. It requires an initial value, minimum and maximum bounds, and an onChanged callback. ```dart import 'package:flutter/material.dart'; import 'package:numberpicker/numberpicker.dart'; class IntegerPickerExample extends StatefulWidget { @override _IntegerPickerExampleState createState() => _IntegerPickerExampleState(); } class _IntegerPickerExampleState extends State { int _currentValue = 50; @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar(title: Text('Integer Picker')), body: Center( child: Column( mainAxisAlignment: MainAxisAlignment.center, children: [ NumberPicker.integer( initialValue: _currentValue, minValue: 0, maxValue: 100, onChanged: (newValue) => setState(() => _currentValue = newValue), ), Text("Selected value: $_currentValue"), ], ), ), ); } } ``` -------------------------------- ### Create Decimal NumberPicker Source: https://context7.com/andrezanna/numberpicker/llms.txt Use NumberPicker.decimal for selecting decimal numbers. Configure the number of decimal places with the 'decimalPlaces' parameter. It supports a range and an onChanged callback. ```dart import 'package:flutter/material.dart'; import 'package:numberpicker/numberpicker.dart'; class DecimalPickerExample extends StatefulWidget { @override _DecimalPickerExampleState createState() => _DecimalPickerExampleState(); } class _DecimalPickerExampleState extends State { double _currentDoubleValue = 3.0; @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar(title: Text('Decimal Picker')), body: Center( child: Column( mainAxisAlignment: MainAxisAlignment.center, children: [ NumberPicker.decimal( initialValue: _currentDoubleValue, minValue: 1, maxValue: 5, decimalPlaces: 2, // Shows values like 1.00, 1.01, 1.02, etc. onChanged: (value) => setState(() => _currentDoubleValue = value), ), Text("Selected value: $_currentDoubleValue"), ], ), ), ); } } ``` -------------------------------- ### Configure Custom Dimensions for NumberPicker Source: https://context7.com/andrezanna/numberpicker/llms.txt Customize the height of each item (`itemExtent`), the width of the list view (`listViewWidth`), and the height of the list view (`listViewHeight`) to match your specific UI design requirements. ```dart import 'package:flutter/material.dart'; import 'package:numberpicker/numberpicker.dart'; class CustomSizePickerExample extends StatefulWidget { @override _CustomSizePickerExampleState createState() => _CustomSizePickerExampleState(); } class _CustomSizePickerExampleState extends State { int _currentValue = 50; @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar(title: Text('Custom Size Picker')), body: Center( child: NumberPicker.integer( initialValue: _currentValue, minValue: 0, maxValue: 100, itemExtent: 60.0, // Height of each item (default: 50.0) listViewWidth: 120.0, // Width of the list view (default: 100.0) listViewHeight: 180.0, // Height of the list view (default: 150.0) onChanged: (value) => setState(() => _currentValue = value), ), ), ); } } ``` -------------------------------- ### Animate NumberPicker Programmatically Source: https://context7.com/andrezanna/numberpicker/llms.txt Use `animateInt()` for integer values, `animateDecimal()` for the decimal part, and `animateDecimalAndInteger()` for full decimal values. This is useful for synchronizing the picker with external controls or preset buttons. ```dart import 'dart:async'; import 'package:flutter/material.dart'; import 'package:numberpicker/numberpicker.dart'; class AnimatedPickerExample extends StatefulWidget { @override _AnimatedPickerExampleState createState() => _AnimatedPickerExampleState(); } class _AnimatedPickerExampleState extends State { int _currentIntValue = 10; double _currentDoubleValue = 3.0; NumberPicker integerNumberPicker; NumberPicker decimalNumberPicker; _handleValueChanged(num value) { if (value is int) { setState(() => _currentIntValue = value); } else { setState(() => _currentDoubleValue = value); } } // Programmatically set value and animate picker _handleExternalValueChange(num value) { if (value is int) { setState(() => _currentIntValue = value); integerNumberPicker.animateInt(value); // Animate to new integer value } else { setState(() => _currentDoubleValue = value); decimalNumberPicker.animateDecimalAndInteger(value); // Animate both parts } } @override Widget build(BuildContext context) { integerNumberPicker = NumberPicker.integer( initialValue: _currentIntValue, minValue: 0, maxValue: 100, onChanged: _handleValueChanged, ); decimalNumberPicker = NumberPicker.decimal( initialValue: _currentDoubleValue, minValue: 1, maxValue: 5, decimalPlaces: 2, onChanged: _handleValueChanged, ); return Scaffold( appBar: AppBar(title: Text('Animated Picker')), body: Column( mainAxisAlignment: MainAxisAlignment.spaceAround, children: [ integerNumberPicker, Row( mainAxisAlignment: MainAxisAlignment.center, children: [ RaisedButton( onPressed: () => _handleExternalValueChange(0), child: Text("Set to 0"), ), RaisedButton( onPressed: () => _handleExternalValueChange(50), child: Text("Set to 50"), ), RaisedButton( onPressed: () => _handleExternalValueChange(100), child: Text("Set to 100"), ), ], ), decimalNumberPicker, RaisedButton( onPressed: () => _handleExternalValueChange(2.50), child: Text("Set to 2.50"), ), ], ), ); } } ``` -------------------------------- ### Horizontal Layout NumberPicker Source: https://context7.com/andrezanna/numberpicker/llms.txt Configure NumberPicker for horizontal scrolling by setting the 'horizontal' parameter to true. This applies to both integer and decimal pickers. ```dart import 'package:flutter/material.dart'; import 'package:numberpicker/numberpicker.dart'; class HorizontalPickerExample extends StatefulWidget { @override _HorizontalPickerExampleState createState() => _HorizontalPickerExampleState(); } class _HorizontalPickerExampleState extends State { int _currentValue = 10; double _currentDoubleValue = 3.0; @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar(title: Text('Horizontal Pickers')), body: Center( child: Column( mainAxisAlignment: MainAxisAlignment.spaceAround, children: [ // Horizontal integer picker NumberPicker.integer( initialValue: _currentValue, minValue: 0, maxValue: 100, horizontal: true, onChanged: (value) => setState(() => _currentValue = value), ), Text("Integer: $_currentValue"), // Horizontal decimal picker NumberPicker.decimal( initialValue: _currentDoubleValue, minValue: 1, maxValue: 5, decimalPlaces: 2, horizontal: true, onChanged: (value) => setState(() => _currentDoubleValue = value), ), Text("Decimal: $_currentDoubleValue"), ], ), ), ); } } ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.