mirror of
https://github.com/chenasraf/wheel_spinner.git
synced 2026-05-17 17:48:00 +00:00
chore: format dart files
This commit is contained in:
3
.vscode/settings.json
vendored
Normal file
3
.vscode/settings.json
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"dart.lineLength": 80
|
||||
}
|
||||
@@ -1,3 +1,7 @@
|
||||
## 0.6.1
|
||||
|
||||
- Update dark theme - remove border
|
||||
|
||||
## 0.6.0
|
||||
|
||||
- Use `WheelSpinnerTheme` and `WheelSpinnerThemeData` to define styles, similar to `Theme` and
|
||||
|
||||
@@ -41,7 +41,8 @@ class WheelSpinner extends StatefulWidget {
|
||||
final WheelSpinnerThemeData? theme;
|
||||
|
||||
/// The default min/max label builder.
|
||||
static ValueStringBuilder defaultMinMaxLabelBuilder = (v) => v.toStringAsFixed(2);
|
||||
static ValueStringBuilder defaultMinMaxLabelBuilder =
|
||||
(v) => v.toStringAsFixed(2);
|
||||
|
||||
const WheelSpinner({
|
||||
Key? key,
|
||||
@@ -60,7 +61,8 @@ class WheelSpinner extends StatefulWidget {
|
||||
_WheelSpinnerState createState() => _WheelSpinnerState();
|
||||
}
|
||||
|
||||
class _WheelSpinnerState extends State<WheelSpinner> with SingleTickerProviderStateMixin {
|
||||
class _WheelSpinnerState extends State<WheelSpinner>
|
||||
with SingleTickerProviderStateMixin {
|
||||
late double value;
|
||||
late double dragStartValue;
|
||||
Offset? dragStartOffset;
|
||||
@@ -137,7 +139,9 @@ class _WheelSpinnerState extends State<WheelSpinner> with SingleTickerProviderSt
|
||||
);
|
||||
},
|
||||
).toList() +
|
||||
(widget.childBuilder != null ? [widget.childBuilder!(value)] : []),
|
||||
(widget.childBuilder != null
|
||||
? [widget.childBuilder!(value)]
|
||||
: []),
|
||||
),
|
||||
),
|
||||
),
|
||||
@@ -177,7 +181,8 @@ class _WheelSpinnerState extends State<WheelSpinner> with SingleTickerProviderSt
|
||||
flingController.stop();
|
||||
final newValue = clamp(
|
||||
dragStartValue -
|
||||
(details.globalPosition - dragStartOffset).dy / (20.0 / widget._dragSpeedFactor),
|
||||
(details.globalPosition - dragStartOffset).dy /
|
||||
(20.0 / widget._dragSpeedFactor),
|
||||
widget.min,
|
||||
widget.max);
|
||||
setState(() {
|
||||
@@ -198,11 +203,12 @@ class _WheelSpinnerState extends State<WheelSpinner> with SingleTickerProviderSt
|
||||
final originalValue = value;
|
||||
currentFlingListener = flingListener(originalValue);
|
||||
flingController.duration = Duration(milliseconds: velocity.abs().toInt());
|
||||
flingAnimation = Tween(begin: 0.0, end: velocity / 100).animate(CurvedAnimation(
|
||||
flingAnimation =
|
||||
Tween(begin: 0.0, end: velocity / 100).animate(CurvedAnimation(
|
||||
curve: Curves.decelerate,
|
||||
parent: flingController,
|
||||
))
|
||||
..addListener(currentFlingListener);
|
||||
..addListener(currentFlingListener);
|
||||
flingController
|
||||
..reset()
|
||||
..forward();
|
||||
@@ -210,7 +216,8 @@ class _WheelSpinnerState extends State<WheelSpinner> with SingleTickerProviderSt
|
||||
|
||||
flingListener(double originalValue) {
|
||||
return () {
|
||||
final newValue = clamp(originalValue - flingAnimation.value, widget.min, widget.max);
|
||||
final newValue =
|
||||
clamp(originalValue - flingAnimation.value, widget.min, widget.max);
|
||||
if (newValue != value) {
|
||||
setState(() {
|
||||
value = newValue;
|
||||
|
||||
@@ -45,7 +45,8 @@ class WheelSpinnerThemeData {
|
||||
static const double defaultShadowOffset = 0.2;
|
||||
|
||||
/// default border radius for both light+dark themes
|
||||
static const BorderRadius defaultBorderRadius = BorderRadius.all(Radius.circular(8));
|
||||
static const BorderRadius defaultBorderRadius =
|
||||
BorderRadius.all(Radius.circular(8));
|
||||
|
||||
/// A default light theme
|
||||
WheelSpinnerThemeData.light()
|
||||
@@ -59,8 +60,18 @@ class WheelSpinnerThemeData {
|
||||
gradient = LinearGradient(
|
||||
begin: Alignment.topCenter,
|
||||
end: Alignment.bottomCenter,
|
||||
stops: const [0.0, defaultShadowOffset, 1.0 - defaultShadowOffset, 1.0],
|
||||
colors: [Colors.grey[350]!, Colors.grey[50]!, Colors.grey[50]!, Colors.grey[350]!],
|
||||
stops: const [
|
||||
0.0,
|
||||
defaultShadowOffset,
|
||||
1.0 - defaultShadowOffset,
|
||||
1.0
|
||||
],
|
||||
colors: [
|
||||
Colors.grey[350]!,
|
||||
Colors.grey[50]!,
|
||||
Colors.grey[50]!,
|
||||
Colors.grey[350]!
|
||||
],
|
||||
),
|
||||
borderRadius = defaultBorderRadius,
|
||||
boxDecoration = null,
|
||||
@@ -70,16 +81,17 @@ class WheelSpinnerThemeData {
|
||||
WheelSpinnerThemeData.dark()
|
||||
: dividerColor = Colors.grey[800],
|
||||
dividerCount = 10,
|
||||
border = Border.all(
|
||||
width: 1,
|
||||
style: BorderStyle.solid,
|
||||
color: Colors.grey[600]!,
|
||||
),
|
||||
border = null,
|
||||
gradient = LinearGradient(
|
||||
begin: Alignment.topCenter,
|
||||
end: Alignment.bottomCenter,
|
||||
stops: const [0.0, defaultShadowOffset, 1 - defaultShadowOffset, 1.0],
|
||||
colors: [Colors.black, Colors.grey[900]!, Colors.grey[900]!, Colors.black],
|
||||
colors: [
|
||||
Colors.black,
|
||||
Colors.grey[900]!,
|
||||
Colors.grey[900]!,
|
||||
Colors.black
|
||||
],
|
||||
),
|
||||
borderRadius = defaultBorderRadius,
|
||||
boxDecoration = null,
|
||||
@@ -121,7 +133,8 @@ class WheelSpinnerTheme extends InheritedWidget {
|
||||
});
|
||||
|
||||
@override
|
||||
bool updateShouldNotify(covariant WheelSpinnerTheme oldWidget) => oldWidget.data != data;
|
||||
bool updateShouldNotify(covariant WheelSpinnerTheme oldWidget) =>
|
||||
oldWidget.data != data;
|
||||
|
||||
/// Get the nearest wheel spinner theme data up the widget tree from the given context.
|
||||
static WheelSpinnerThemeData? of(BuildContext context) =>
|
||||
|
||||
Reference in New Issue
Block a user