From 186b97413c6edb2b0c9a2c31de6715ea2ce13900 Mon Sep 17 00:00:00 2001 From: Sukio99ns Date: Sat, 24 Apr 2021 11:35:23 +0700 Subject: [PATCH] =?UTF-8?q?S=E1=BB=ADa=20lib,=20m=E1=BB=9F=20r=E1=BB=99ng?= =?UTF-8?q?=20truy=E1=BB=81n=20v=C3=A0o=20widget=20input?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- example/lib/main.dart | 148 +++++++------- example/lib/main_material.dart | 116 ----------- example/lib/number_formatter.dart | 62 ++++++ lib/src/cupertino/spin_box.dart | 126 +----------- .../third_party/default_rounded_border.dart | 31 --- lib/src/material/spin_box.dart | 189 +----------------- pubspec.yaml | 1 + 7 files changed, 154 insertions(+), 519 deletions(-) delete mode 100644 example/lib/main_material.dart create mode 100644 example/lib/number_formatter.dart delete mode 100644 lib/src/cupertino/third_party/default_rounded_border.dart diff --git a/example/lib/main.dart b/example/lib/main.dart index 7c5c3d9..30895c8 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -1,5 +1,6 @@ import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; +import 'package:flutter_spinbox_example/number_formatter.dart'; import 'package:flutter_spinbox_fork_1224/cupertino.dart'; void main() => runApp( @@ -50,65 +51,54 @@ class HorizontalSpinBoxPage extends StatelessWidget { CupertinoSpinBox( value: 10, numOfDecimals: 1, + inputWidget: (controller, focusNode) { + return CupertinoTextField( + controller: controller, + keyboardType: + TextInputType.numberWithOptions(decimal: true), + textAlign: TextAlign.center, + inputFormatters: [ + NumericTextFormatter( + numOfInteger: 3, + decimals: 1, + ) + ], + prefix: Row( + mainAxisSize: MainAxisSize.min, + children: [ + Padding( + padding: + const EdgeInsets.symmetric(horizontal: 16), + child: Icon( + null, + ), + ), + ], + ), + suffix: Row( + mainAxisSize: MainAxisSize.min, + children: [ + Padding( + padding: + const EdgeInsets.symmetric(horizontal: 16), + child: Icon( + null, + ), + ), + ], + ), + padding: EdgeInsets.zero, + focusNode: focusNode, + onTap: () { + controller.selection = TextSelection.fromPosition( + TextPosition(offset: controller.text.length)); + }, + ); + }, ), ], ), ), - Padding( - padding: const EdgeInsets.symmetric(horizontal: 16), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Padding( - child: Text('Decimals', style: caption), - padding: const EdgeInsets.only(left: 16), - ), - CupertinoSpinBox( - min: 0.0, max: 999999999.0, value: 8888.0,numOfDecimals: 3, - ) - ], - ), - ), - Padding( - padding: const EdgeInsets.symmetric(horizontal: 16), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Padding( - child: Text('Accelerated', style: caption), - padding: const EdgeInsets.only(left: 16), - ), - CupertinoSpinBox( - min: -10.0, - max: 10000.0, - value: 0.25, - numOfDecimals: 3, - ), - ], - ), - ), - Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Padding( - child: Text('Decorated', style: caption), - padding: const EdgeInsets.only(left: 16, top: 16), - ), - CupertinoSpinBox( - value: 50, - prefix: Text('prefix'), - suffix: Text('suffix'), - decoration: const BoxDecoration( - border: Border.symmetric( - vertical: BorderSide( - width: 0, - color: CupertinoColors.inactiveGray, - ), - ), - ), - ), - ], - ), ], ), ), @@ -132,26 +122,36 @@ class VerticalSpinBoxPage extends StatelessWidget { max: 50, value: 15, spacing: 24, - direction: Axis.vertical, - textStyle: TextStyle(fontSize: 48), - incrementIcon: Icon(CupertinoIcons.up_arrow, size: 64), - decrementIcon: Icon(CupertinoIcons.down_arrow, size: 64), - padding: const EdgeInsets.all(24), - decoration: BoxDecoration( - color: CupertinoDynamicColor.withBrightness( - color: CupertinoColors.white, - darkColor: CupertinoColors.black, - ), - border: Border.all( - color: CupertinoDynamicColor.withBrightness( - color: Color(0x33000000), - darkColor: Color(0x33FFFFFF), + inputWidget: (controller, focusNode) { + return CupertinoTextField( + controller: controller, + focusNode: focusNode, + style: TextStyle(fontSize: 48), + padding: const EdgeInsets.all(24), + inputFormatters: [ + NumericTextFormatter( + numOfInteger: 2, + decimals: 1, + ) + ], + decoration: BoxDecoration( + color: CupertinoDynamicColor.withBrightness( + color: CupertinoColors.white, + darkColor: CupertinoColors.black, + ), + border: Border.all( + color: CupertinoDynamicColor.withBrightness( + color: Color(0x33000000), + darkColor: Color(0x33FFFFFF), + ), + style: BorderStyle.solid, + width: 0.0, + ), + borderRadius: BorderRadius.all(Radius.circular(5.0)), ), - style: BorderStyle.solid, - width: 0.0, - ), - borderRadius: BorderRadius.all(Radius.circular(5.0)), - ), + ); + }, + direction: Axis.vertical, ), ), ), diff --git a/example/lib/main_material.dart b/example/lib/main_material.dart deleted file mode 100644 index 82382bc..0000000 --- a/example/lib/main_material.dart +++ /dev/null @@ -1,116 +0,0 @@ -import 'package:flutter/material.dart'; -import 'package:flutter_spinbox_fork_1224/flutter_spinbox.dart'; - -void main() => runApp( - MaterialApp( - debugShowCheckedModeBanner: false, - home: DefaultTabController( - length: 2, - child: Scaffold( - appBar: AppBar( - title: Text('SpinBox for Flutter'), - bottom: TabBar( - tabs: [ - Tab(icon: Icon(Icons.swap_horiz)), - Tab(icon: Icon(Icons.swap_vert)), - ], - ), - ), - body: TabBarView( - children: [ - HorizontalSpinBoxPage(), - VerticalSpinBoxPage(), - ], - ), - ), - ), - ), - ); - -class HorizontalSpinBoxPage extends StatelessWidget { - @override - Widget build(BuildContext context) { - return Scrollbar( - child: ListView( - children: [ - Padding( - child: SpinBox( - value: 10, - decoration: InputDecoration(labelText: 'Basic'), - ), - padding: const EdgeInsets.all(16), - ), - Padding( - child: SpinBox( - max: 10.0, - value: 5.0, - step: 0.1, - decoration: InputDecoration(labelText: 'Decimals'), - ), - padding: const EdgeInsets.all(16), - ), - Padding( - child: SpinBox( - min: -1.0, - max: 1.0, - value: 0.25, - step: 0.001, - acceleration: 0.001, - decoration: InputDecoration(labelText: 'Accelerated'), - ), - padding: const EdgeInsets.all(16), - ), - Padding( - child: SpinBox( - value: 50, - decoration: InputDecoration( - hintText: 'Hint', - labelText: 'Decorated', - helperText: 'Helper', - prefixText: 'Prefix', - suffixText: 'Suffix', - counterText: 'Counter', - ), - validator: (text) => text.isEmpty ? 'Invalid' : null, - ), - padding: const EdgeInsets.all(16), - ), - ], - ), - ); - } -} - -class VerticalSpinBoxPage extends StatelessWidget { - @override - Widget build(BuildContext context) { - return Scrollbar( - child: Center( - child: ListView( - shrinkWrap: true, - children: [ - Center( - child: Container( - width: 128, - child: SpinBox( - min: -50, - max: 50, - value: 15, - spacing: 24, - direction: Axis.vertical, - textStyle: TextStyle(fontSize: 48), - incrementIcon: Icon(Icons.keyboard_arrow_up, size: 64), - decrementIcon: Icon(Icons.keyboard_arrow_down, size: 64), - decoration: InputDecoration( - border: OutlineInputBorder(), - contentPadding: const EdgeInsets.all(24), - ), - ), - ), - ), - ], - ), - ), - ); - } -} diff --git a/example/lib/number_formatter.dart b/example/lib/number_formatter.dart new file mode 100644 index 0000000..ca7d220 --- /dev/null +++ b/example/lib/number_formatter.dart @@ -0,0 +1,62 @@ +import 'package:flutter/services.dart'; +import 'package:intl/intl.dart'; + +class NumericTextFormatter extends TextInputFormatter { + final int numOfInteger; + final int decimals; + + NumericTextFormatter({this.numOfInteger = 3, this.decimals = 0}); + @override + TextEditingValue formatEditUpdate( + TextEditingValue oldValue, TextEditingValue newValue) { + if (newValue.text.isEmpty) { + return newValue.copyWith(text: ''); + } else if (newValue.text.compareTo(oldValue.text) != 0) { + if (newValue.text.replaceAll(RegExp("[0-9.,]"), '').isNotEmpty) { + return newValue = oldValue; + } + final newString = formatCurrencyForeign(newValue.text, + numOfInteger: numOfInteger, decimals: decimals); + + return TextEditingValue( + text: newString, + selection: TextSelection.collapsed(offset: newString.length), + ); + } else { + return newValue; + } + } +} + +double formatNumberCurrency(String text) { + if (text.isEmpty) return 0; + return double.tryParse(text.replaceAll(',', '')); +} + +String formatCurrencyForeign(dynamic number, + {int numOfInteger = 3, int decimals = 0}) { + String first = number.toString().substring( + 0, + number.toString().contains('.') + ? number.toString().lastIndexOf('.') + : null); + final int firstNumber = numOfInteger + + ((numOfInteger % 3 != 0) ? numOfInteger ~/ 3 : ((numOfInteger ~/ 3) - 1)); + if (first.length >= firstNumber) { + first = first.substring(0, firstNumber); + } + String last = number.toString().substring( + number.toString().contains('.') + ? number.toString().lastIndexOf('.') + : number.toString().length, + number.toString().length); + if (last.length >= decimals + 2) { + last = last.substring(0, decimals + 1); + } + final String result = + NumberFormat.currency(locale: 'en_US', symbol: '', decimalDigits: 0) + .format(formatNumberCurrency(first)) + .trim() + + last; + return result; +} diff --git a/lib/src/cupertino/spin_box.dart b/lib/src/cupertino/spin_box.dart index 2c1a4ae..1823526 100644 --- a/lib/src/cupertino/spin_box.dart +++ b/lib/src/cupertino/spin_box.dart @@ -21,15 +21,12 @@ // SOFTWARE. import 'package:flutter/cupertino.dart'; +import 'package:flutter/material.dart'; import 'package:flutter/rendering.dart'; -import 'package:flutter/services.dart'; -import 'package:flutter_spinbox_fork_1224/src/number_formatter.dart'; import '../base_spin_box.dart'; import 'spin_button.dart'; -part 'third_party/default_rounded_border.dart'; - /// An iOS-style spinbox. /// /// {@macro flutter_spinbox.SpinBox} @@ -59,37 +56,19 @@ class CupertinoSpinBox extends BaseSpinBox { this.interval = const Duration(milliseconds: 100), this.acceleration, this.numOfDecimals = 0, - bool enabled, - this.autofocus = false, - TextInputType keyboardType, - this.textInputAction, - this.padding = const EdgeInsets.all(6), - this.decoration = _kDefaultRoundedBorderDecoration, - this.keyboardAppearance, Icon incrementIcon, Icon decrementIcon, - this.prefix, - this.suffix, this.direction = Axis.horizontal, - this.textAlign = TextAlign.center, - this.textStyle, - this.toolbarOptions, - this.showCursor, - this.cursorColor, - this.enableInteractiveSelection = true, this.spacing = 8, this.onChanged, + bool enabled, + @required this.inputWidget, }) : assert(min != null), assert(max != null), assert(min <= max), assert(value != null), assert(interval != null), assert(direction != null), - keyboardType = keyboardType ?? - TextInputType.numberWithOptions( - signed: min < 0, - decimal: numOfDecimals > 0, - ), enabled = (enabled ?? true) && min < max, //decoration = decoration ?? const BoxDecoration(), incrementIcon = @@ -171,54 +150,14 @@ class CupertinoSpinBox extends BaseSpinBox { /// Defaults to [CupertinoIcons.minus_circled]. final Icon decrementIcon; - /// See [CupertinoTextField.prefix]. - final Widget prefix; - - /// See [CupertinoTextField.suffix]. - final Widget suffix; - /// Called when the user has changed the value. @override final ValueChanged onChanged; - /// See [CupertinoTextField.enabled]. final bool enabled; - /// See [CupertinoTextField.autofocus]. - final bool autofocus; - - /// See [CupertinoTextField.keyboardType]. - final TextInputType keyboardType; - - /// See [CupertinoTextField.textInputAction]. - final TextInputAction textInputAction; - - /// See [CupertinoTextField.padding]. - final EdgeInsetsGeometry padding; - - /// See [CupertinoTextField.decoration]. - final BoxDecoration decoration; - - /// See [CupertinoTextField.keyboardAppearance]. - final Brightness keyboardAppearance; - - /// See [CupertinoTextField.showCursor]. - final bool showCursor; - - /// See [CupertinoTextField.cursorColor]. - final Color cursorColor; - - /// See [CupertinoTextField.enableInteractiveSelection]. - final bool enableInteractiveSelection; - - /// See [CupertinoTextField.textAlign]. - final TextAlign textAlign; - - /// See [CupertinoTextField.style]. - final TextStyle textStyle; - - /// See [CupertinoTextField.toolbarOptions]. - final ToolbarOptions toolbarOptions; + final CupertinoTextField Function(TextEditingController, FocusNode) + inputWidget; @override _CupertinoSpinBoxState createState() => _CupertinoSpinBoxState(); @@ -247,62 +186,11 @@ class _CupertinoSpinBoxState extends BaseSpinBoxState { onStep: (step) => setValue(value - step), ); - final textField = CupertinoTextField( - controller: controller, - style: widget.textStyle, - textAlign: widget.textAlign, - keyboardType: widget.keyboardType, - textInputAction: widget.textInputAction, - toolbarOptions: widget.toolbarOptions, - keyboardAppearance: widget.keyboardAppearance, - inputFormatters: [ - NumericTextFormatter( - numOfInteger: widget.max.toInt().toString().length, - decimals: widget.numOfDecimals, - ) - ], - prefix: Row( - mainAxisSize: MainAxisSize.min, - children: [ - if (isHorizontal) - Padding( - padding: const EdgeInsets.symmetric(horizontal: kSpinPadding), - child: Icon(null, size: widget.decrementIcon.size), - ), - if (widget.prefix != null) widget.prefix, - ], - ), - suffix: Row( - mainAxisSize: MainAxisSize.min, - children: [ - if (widget.suffix != null) widget.suffix, - if (isHorizontal) - Padding( - padding: const EdgeInsets.symmetric(horizontal: kSpinPadding), - child: Icon(null, size: widget.incrementIcon.size), - ), - ], - ), - padding: widget.padding, - decoration: widget.decoration, - enableInteractiveSelection: widget.enableInteractiveSelection, - showCursor: widget.showCursor, - cursorColor: widget.cursorColor, - autofocus: widget.autofocus, - enabled: widget.enabled, - focusNode: focusNode, - onSubmitted: fixupValue, - onTap: () { - controller.selection = TextSelection.fromPosition( - TextPosition(offset: controller.text.length)); - }, - ); - if (isHorizontal) { return Stack( alignment: Alignment.center, children: [ - textField, + widget.inputWidget(controller, focusNode), Center( child: Align( alignment: Alignment.centerLeft, @@ -322,7 +210,7 @@ class _CupertinoSpinBoxState extends BaseSpinBoxState { children: [ incrementButton, SizedBox(height: widget.spacing), - textField, + widget.inputWidget(controller, focusNode), SizedBox(height: widget.spacing), decrementButton, ], diff --git a/lib/src/cupertino/third_party/default_rounded_border.dart b/lib/src/cupertino/third_party/default_rounded_border.dart deleted file mode 100644 index 7dadef6..0000000 --- a/lib/src/cupertino/third_party/default_rounded_border.dart +++ /dev/null @@ -1,31 +0,0 @@ -// Copyright 2014 The Flutter Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -part of '../spin_box.dart'; - -// Copied from flutter/lib/src/cupertino/text_field.dart: - -// Value inspected from Xcode 11 & iOS 13.0 Simulator. -const BorderSide _kDefaultRoundedBorderSide = BorderSide( - color: CupertinoDynamicColor.withBrightness( - color: Color(0x33000000), - darkColor: Color(0x33FFFFFF), - ), - width: 0.0, -); -const Border _kDefaultRoundedBorder = Border( - top: _kDefaultRoundedBorderSide, - bottom: _kDefaultRoundedBorderSide, - left: _kDefaultRoundedBorderSide, - right: _kDefaultRoundedBorderSide, -); - -const BoxDecoration _kDefaultRoundedBorderDecoration = BoxDecoration( - color: CupertinoDynamicColor.withBrightness( - color: CupertinoColors.white, - darkColor: CupertinoColors.black, - ), - border: _kDefaultRoundedBorder, - borderRadius: BorderRadius.all(Radius.circular(5.0)), -); diff --git a/lib/src/material/spin_box.dart b/lib/src/material/spin_box.dart index 2a38143..9227a06 100644 --- a/lib/src/material/spin_box.dart +++ b/lib/src/material/spin_box.dart @@ -20,12 +20,9 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE // SOFTWARE. -import 'dart:math'; import 'package:flutter/material.dart'; import 'package:flutter/rendering.dart'; -import 'package:flutter/services.dart'; -import 'package:flutter_spinbox_fork_1224/src/number_formatter.dart'; import '../base_spin_box.dart'; import 'spin_button.dart'; @@ -60,38 +57,16 @@ class SpinBox extends BaseSpinBox { this.acceleration, this.numOfDecimals = 0, bool enabled, - this.autofocus = false, - TextInputType keyboardType, - this.textInputAction, - InputDecoration decoration, - this.validator, - this.keyboardAppearance, Icon incrementIcon, Icon decrementIcon, this.direction = Axis.horizontal, - this.textAlign = TextAlign.center, - this.textDirection = TextDirection.ltr, - this.textStyle, - this.toolbarOptions, - this.showCursor, - this.cursorColor, - this.enableInteractiveSelection = true, this.spacing = 8, this.onChanged, - }) : keyboardType = keyboardType ?? - TextInputType.numberWithOptions( - signed: min < 0, - decimal: numOfDecimals > 0, - ), - enabled = (enabled ?? true) && min < max, - decoration = decoration ?? const InputDecoration(), + @required this.inputWidget, + }) : enabled = (enabled ?? true) && min < max, incrementIcon = incrementIcon ?? const Icon(Icons.add), decrementIcon = decrementIcon ?? const Icon(Icons.remove), super(key: key) { - assert(this.decoration.prefixIcon == null, - 'InputDecoration.prefixIcon is reserved for SpinBox decrement icon'); - assert(this.decoration.suffixIcon == null, - 'InputDecoration.suffixIcon is reserved for SpinBox increment icon'); } /// The minimum value the user can enter. @@ -174,122 +149,20 @@ class SpinBox extends BaseSpinBox { /// See [TextField.enabled]. final bool enabled; - /// See [TextField.autofocus]. - final bool autofocus; - - /// See [TextField.keyboardType]. - final TextInputType keyboardType; - - /// See [TextField.textInputAction]. - final TextInputAction textInputAction; - - /// See [TextField.decoration]. - final InputDecoration decoration; - - /// See [FormField.validator]. - final FormFieldValidator validator; - - /// See [TextField.keyboardAppearance]. - final Brightness keyboardAppearance; - - /// See [TextField.showCursor]. - final bool showCursor; - - /// See [TextField.cursorColor]. - final Color cursorColor; - - /// See [TextField.enableInteractiveSelection]. - final bool enableInteractiveSelection; - - /// See [TextField.textAlign]. - final TextAlign textAlign; - - /// See [TextField.textDirection]. - final TextDirection textDirection; - - /// See [TextField.style]. - final TextStyle textStyle; - - /// See [TextField.toolbarOptions]. - final ToolbarOptions toolbarOptions; + final TextField Function(TextEditingController, FocusNode) inputWidget; @override _SpinBoxState createState() => _SpinBoxState(); } class _SpinBoxState extends BaseSpinBoxState { - Color _activeColor(ThemeData theme) { - if (hasFocus) { - switch (theme.brightness) { - case Brightness.dark: - return theme.accentColor; - case Brightness.light: - return theme.primaryColor; - } - } - return theme.hintColor; - } - - Color _iconColor(ThemeData theme, String errorText) { - if (!widget.enabled) return theme.disabledColor; - if (hasFocus && errorText == null) return _activeColor(theme); - - switch (theme.brightness) { - case Brightness.dark: - return Colors.white70; - case Brightness.light: - return Colors.black45; - default: - return theme.iconTheme.color; - } - } - - double _textHeight(String text, TextStyle style) { - final painter = TextPainter( - textAlign: widget.textAlign, - textDirection: widget.textDirection, - text: TextSpan(style: style, text: text), - ); - painter.layout(); - return painter.height; - } - @override Widget build(BuildContext context) { - final theme = Theme.of(context); - final decoration = - widget.decoration.applyDefaults(theme.inputDecorationTheme); - - final errorText = - decoration.errorText ?? widget.validator?.call(controller.text); - final iconColor = _iconColor(theme, errorText); - - var bottom = 0.0; + final isHorizontal = widget.direction == Axis.horizontal; - if (isHorizontal) { - final caption = theme.textTheme.caption; - if (errorText != null) { - bottom = _textHeight(errorText, caption.merge(decoration.errorStyle)); - } - if (decoration.helperText != null) { - bottom = max( - bottom, - _textHeight( - decoration.helperText, caption.merge(decoration.helperStyle))); - } - if (decoration.counterText != null) { - bottom = max( - bottom, - _textHeight(decoration.counterText, - caption.merge(decoration.counterStyle))); - } - if (bottom > 0) bottom += 8.0; // subTextGap - } - final incrementButton = SpinButton( step: widget.step, - color: iconColor, icon: widget.incrementIcon, enabled: widget.enabled && value < widget.max, interval: widget.interval, @@ -299,7 +172,6 @@ class _SpinBoxState extends BaseSpinBoxState { final decrementButton = SpinButton( step: widget.step, - color: iconColor, icon: widget.decrementIcon, enabled: widget.enabled && value > widget.min, interval: widget.interval, @@ -307,60 +179,19 @@ class _SpinBoxState extends BaseSpinBoxState { onStep: (step) => setValue(value - step), ); - final inputDecoration = widget.decoration.copyWith( - errorText: errorText, - prefixIcon: - isHorizontal ? Icon(null, size: widget.decrementIcon.size) : null, - suffixIcon: - isHorizontal ? Icon(null, size: widget.incrementIcon.size) : null, - ); - - final textField = TextField( - controller: controller, - style: widget.textStyle, - textAlign: widget.textAlign, - textDirection: widget.textDirection, - keyboardType: widget.keyboardType, - textInputAction: widget.textInputAction, - toolbarOptions: widget.toolbarOptions, - keyboardAppearance: widget.keyboardAppearance, - inputFormatters: [ - NumericTextFormatter( - numOfInteger: widget.max.toInt().toString().length, - decimals: widget.numOfDecimals, - ) - ], - decoration: inputDecoration, - enableInteractiveSelection: widget.enableInteractiveSelection, - showCursor: widget.showCursor, - cursorColor: widget.cursorColor, - autofocus: widget.autofocus, - enabled: widget.enabled, - focusNode: focusNode, - onSubmitted: fixupValue, - onTap: () { - controller.selection = TextSelection.fromPosition( - TextPosition(offset: controller.text.length)); - }, - ); - if (isHorizontal) { return Stack( children: [ - textField, - Positioned.fill( - bottom: bottom, + widget.inputWidget(controller, focusNode), + Center( child: Align( alignment: Alignment.centerLeft, child: decrementButton, ), ), - Positioned.fill( - bottom: bottom, - child: Align( - alignment: Alignment.centerRight, - child: incrementButton, - ), + Align( + alignment: Alignment.centerRight, + child: incrementButton, ) ], ); @@ -371,7 +202,7 @@ class _SpinBoxState extends BaseSpinBoxState { children: [ incrementButton, SizedBox(height: widget.spacing), - textField, + widget.inputWidget(controller, focusNode), SizedBox(height: widget.spacing), decrementButton, ], diff --git a/pubspec.yaml b/pubspec.yaml index 3cdff52..65a762f 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -15,6 +15,7 @@ dependencies: sdk: flutter meta: ^1.2.4 intl: ^0.16.1 + auto_size_text: ^2.1.0 dev_dependencies: flutter_test: