Skip to content

Commit

Permalink
Merge 8f00b43 into f84c33e
Browse files Browse the repository at this point in the history
  • Loading branch information
hamaluik committed May 25, 2020
2 parents f84c33e + 8f00b43 commit 6fb6a8e
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions lib/numberpicker.dart
Expand Up @@ -3,6 +3,7 @@ import 'dart:math' as math;
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart';
import 'package:flutter/services.dart';
import 'package:infinite_listview/infinite_listview.dart';

/// Created by Marcin Szałek
Expand Down Expand Up @@ -34,6 +35,7 @@ class NumberPicker extends StatelessWidget {
this.zeroPad = false,
this.highlightSelectedValue = true,
this.decoration,
this.haptics = false,
}) : assert(initialValue != null),
assert(minValue != null),
assert(maxValue != null),
Expand Down Expand Up @@ -69,6 +71,7 @@ class NumberPicker extends StatelessWidget {
this.zeroPad = false,
this.highlightSelectedValue = true,
this.decoration,
this.haptics = false,
}) : assert(initialValue != null),
assert(minValue != null),
assert(maxValue != null),
Expand Down Expand Up @@ -106,6 +109,7 @@ class NumberPicker extends StatelessWidget {
this.listViewWidth = kDefaultListViewCrossAxisSize,
this.highlightSelectedValue = true,
this.decoration,
this.haptics = false,
}) : assert(initialValue != null),
assert(minValue != null),
assert(maxValue != null),
Expand Down Expand Up @@ -195,6 +199,9 @@ class NumberPicker extends StatelessWidget {
///Amount of items
final int integerItemCount;

///Whether to trigger haptic pulses or not
final bool haptics;

//
//----------------------------- PUBLIC ------------------------------
//
Expand Down Expand Up @@ -469,6 +476,9 @@ class NumberPicker extends StatelessWidget {
newValue = ((intValueInTheMiddle + decimalPart).toDouble());
}
}
if(haptics) {
HapticFeedback.selectionClick();
}
onChanged(newValue);
}
}
Expand All @@ -494,6 +504,9 @@ class NumberPicker extends StatelessWidget {
decimalValueInTheMiddle != selectedDecimalValue) {
double decimalPart = _toDecimal(decimalValueInTheMiddle);
double newValue = ((selectedIntValue + decimalPart).toDouble());
if(haptics) {
HapticFeedback.selectionClick();
}
onChanged(newValue);
}
}
Expand Down

0 comments on commit 6fb6a8e

Please sign in to comment.