diff --git a/lib/spinner_input.dart b/lib/spinner_input.dart index fa3e9ad..0ee5892 100644 --- a/lib/spinner_input.dart +++ b/lib/spinner_input.dart @@ -1,7 +1,6 @@ import 'package:flutter/material.dart'; import 'dart:async'; - /// Spinner Input like HTML5 spinners class SpinnerButtonStyle { Color color; @@ -80,7 +79,6 @@ class _SpinnerInputState extends State final _focusNode = FocusNode(); Timer timer; - double _spinnerValue; SpinnerButtonStyle _plusSpinnerStyle; SpinnerButtonStyle _minusSpinnerStyle; @@ -88,10 +86,6 @@ class _SpinnerInputState extends State @override void initState() { - - /// initializing variables - _spinnerValue = widget.spinnerValue; - /// popup textfield textEditingController = TextEditingController( text: widget.spinnerValue.toStringAsFixed(widget.fractionDigits)); @@ -108,7 +102,6 @@ class _SpinnerInputState extends State } }); - // initialize buttons _plusSpinnerStyle = widget.plusButton ?? SpinnerButtonStyle(); _plusSpinnerStyle.child ??= Icon(Icons.add); @@ -257,11 +250,10 @@ class _SpinnerInputState extends State } void increase() { - double value = _spinnerValue; + double value = widget.spinnerValue; value += widget.step; if (value <= widget.maxValue) { textEditingController.text = value.toStringAsFixed(widget.fractionDigits); - _spinnerValue = value; setState(() { widget.onChange(value); }); @@ -269,11 +261,10 @@ class _SpinnerInputState extends State } void decrease() { - double value = _spinnerValue; + double value = widget.spinnerValue; value -= widget.step; if (value >= widget.minValue) { textEditingController.text = value.toStringAsFixed(widget.fractionDigits); - _spinnerValue = value; setState(() { widget.onChange(value); }); @@ -337,16 +328,15 @@ class _SpinnerInputState extends State double value = double.parse(textEditingController.text); if (value <= widget.maxValue && value >= widget.minValue) { - _spinnerValue = value; setState(() { widget.onChange(value); }); } else { - textEditingController.text = _spinnerValue + textEditingController.text = widget.spinnerValue .toStringAsFixed(widget.fractionDigits); } } catch (e) { - textEditingController.text = _spinnerValue + textEditingController.text = widget.spinnerValue .toStringAsFixed(widget.fractionDigits); } popupAnimationController.reset(); diff --git a/pubspec.lock b/pubspec.lock index 224c7bb..9477cdd 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -1,5 +1,5 @@ # Generated by pub -# See https://www.dartlang.org/tools/pub/glossary#lockfile +# See https://dart.dev/tools/pub/glossary#lockfile packages: async: dependency: transitive @@ -7,28 +7,49 @@ packages: name: async url: "https://pub.dartlang.org" source: hosted - version: "2.0.8" + version: "2.4.2" boolean_selector: dependency: transitive description: name: boolean_selector url: "https://pub.dartlang.org" source: hosted - version: "1.0.4" + version: "2.0.0" + characters: + dependency: transitive + description: + name: characters + url: "https://pub.dartlang.org" + source: hosted + version: "1.0.0" charcode: dependency: transitive description: name: charcode url: "https://pub.dartlang.org" source: hosted - version: "1.1.2" + version: "1.1.3" + clock: + dependency: transitive + description: + name: clock + url: "https://pub.dartlang.org" + source: hosted + version: "1.0.1" collection: dependency: transitive description: name: collection url: "https://pub.dartlang.org" source: hosted - version: "1.14.11" + version: "1.14.13" + fake_async: + dependency: transitive + description: + name: fake_async + url: "https://pub.dartlang.org" + source: hosted + version: "1.1.0" flutter: dependency: "direct main" description: flutter @@ -45,28 +66,21 @@ packages: name: matcher url: "https://pub.dartlang.org" source: hosted - version: "0.12.3+1" + version: "0.12.8" meta: dependency: transitive description: name: meta url: "https://pub.dartlang.org" source: hosted - version: "1.1.6" + version: "1.1.8" path: dependency: transitive description: name: path url: "https://pub.dartlang.org" source: hosted - version: "1.6.2" - quiver: - dependency: transitive - description: - name: quiver - url: "https://pub.dartlang.org" - source: hosted - version: "2.0.1" + version: "1.7.0" sky_engine: dependency: transitive description: flutter @@ -78,49 +92,49 @@ packages: name: source_span url: "https://pub.dartlang.org" source: hosted - version: "1.4.1" + version: "1.7.0" stack_trace: dependency: transitive description: name: stack_trace url: "https://pub.dartlang.org" source: hosted - version: "1.9.3" + version: "1.9.5" stream_channel: dependency: transitive description: name: stream_channel url: "https://pub.dartlang.org" source: hosted - version: "1.6.8" + version: "2.0.0" string_scanner: dependency: transitive description: name: string_scanner url: "https://pub.dartlang.org" source: hosted - version: "1.0.4" + version: "1.0.5" term_glyph: dependency: transitive description: name: term_glyph url: "https://pub.dartlang.org" source: hosted - version: "1.0.1" + version: "1.1.0" test_api: dependency: transitive description: name: test_api url: "https://pub.dartlang.org" source: hosted - version: "0.2.1" + version: "0.2.17" typed_data: dependency: transitive description: name: typed_data url: "https://pub.dartlang.org" source: hosted - version: "1.1.6" + version: "1.2.0" vector_math: dependency: transitive description: @@ -129,4 +143,4 @@ packages: source: hosted version: "2.0.8" sdks: - dart: ">=2.0.0 <3.0.0" + dart: ">=2.9.0-14.0.dev <3.0.0"