Skip to content

Commit

Permalink
rename and use pattern matching
Browse files Browse the repository at this point in the history
  • Loading branch information
nghiashiyi committed Oct 20, 2024
1 parent ba728e9 commit 68639c0
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions flutter_map_compass/lib/src/map_compass.dart
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class MapCompass extends StatefulWidget {
this.rotationDuration = const Duration(seconds: 1),
this.animationCurve = Curves.fastOutSlowIn,
this.onPressed,
this.disableOnPressedOverriding = false,
this.onPressedOverridesDefault = true,
this.hideIfRotatedNorth = false,
this.alignment = Alignment.topRight,
this.padding = const EdgeInsets.all(10),
Expand All @@ -27,7 +27,7 @@ class MapCompass extends StatefulWidget {
super.key,
this.onPressed,
this.hideIfRotatedNorth = false,
this.disableOnPressedOverriding = false,
this.onPressedOverridesDefault = true,
this.rotationDuration = const Duration(seconds: 1),
this.animationCurve = Curves.fastOutSlowIn,
this.alignment = Alignment.topRight,
Expand Down Expand Up @@ -75,10 +75,10 @@ class MapCompass extends StatefulWidget {
/// The curve of the rotation animation.
final Curve animationCurve;

/// When [disableOnPressedOverriding] is true, [onPressed] will be called
/// after default rotation.
/// When [onPressedOverridesDefault] is true, [onPressed] will be override
/// the default rotation.
///
final bool disableOnPressedOverriding;
final bool onPressedOverridesDefault;

@override
State<MapCompass> createState() => _MapCompassState();
Expand Down Expand Up @@ -109,15 +109,15 @@ class _MapCompassState extends State<MapCompass> with TickerProviderStateMixin {
padding: EdgeInsets.zero,
icon: widget.icon,
onPressed: () {
if (widget.disableOnPressedOverriding) {
_resetRotation(context, camera);
widget.onPressed?.call();
} else {
if (widget.onPressed != null) {
widget.onPressed!.call();
if (widget.onPressedOverridesDefault) {
if (widget.onPressed case final VoidCallback onPressed) {
onPressed();
} else {
_resetRotation(context, camera);
}
} else {
_resetRotation(context, camera);
widget.onPressed?.call();
}
},
),
Expand Down

0 comments on commit 68639c0

Please sign in to comment.