Skip to content

Commit

Permalink
Removed MoveAndRotateResult in favour of a Record<bool, bool> (#1636
Browse files Browse the repository at this point in the history
)
  • Loading branch information
JaffaKetchup authored Sep 4, 2023
1 parent 40d213f commit 6f41b1f
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 23 deletions.
21 changes: 11 additions & 10 deletions lib/src/map/internal_controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -156,13 +156,13 @@ class FlutterMapInternalController extends ValueNotifier<_InternalState> {
}

if (degree == camera.rotation) {
return const MoveAndRotateResult(false, false);
return const (moveSuccess: false, rotateSuccess: false);
}

if (offset == Offset.zero) {
return MoveAndRotateResult(
true,
rotate(
return (
moveSuccess: true,
rotateSuccess: rotate(
degree,
hasGesture: hasGesture,
source: source,
Expand All @@ -178,8 +178,8 @@ class FlutterMapInternalController extends ValueNotifier<_InternalState> {
: Point(offset!.dx, offset.dy))
.rotate(camera.rotationRad);

return MoveAndRotateResult(
move(
return (
moveSuccess: move(
camera.unproject(
rotationCenter +
(camera.project(camera.center) - rotationCenter)
Expand All @@ -191,7 +191,7 @@ class FlutterMapInternalController extends ValueNotifier<_InternalState> {
source: source,
id: id,
),
rotate(
rotateSuccess: rotate(
camera.rotation + rotationDiff,
hasGesture: hasGesture,
source: source,
Expand All @@ -212,16 +212,17 @@ class FlutterMapInternalController extends ValueNotifier<_InternalState> {
required MapEventSource source,
required String? id,
}) =>
MoveAndRotateResult(
move(
(
moveSuccess: move(
newCenter,
newZoom,
offset: offset,
hasGesture: hasGesture,
source: source,
id: id,
),
rotate(newRotation, id: id, source: source, hasGesture: hasGesture),
rotateSuccess:
rotate(newRotation, id: id, source: source, hasGesture: hasGesture),
);

/// Note: All named parameters are required to prevent inconsistent default
Expand Down
8 changes: 4 additions & 4 deletions lib/src/map/map_controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,8 @@ abstract class MapController {
/// The emitted [MapEventRotate.source]/[MapEventMove.source] properties will
/// be [MapEventSource.mapController].
///
/// The operation was successful if [MoveAndRotateResult.moveSuccess] and
/// [MoveAndRotateResult.rotateSuccess] are `true`.
/// The operation was successful if both fields of the resulting record are
/// `true`.
MoveAndRotateResult rotateAroundPoint(
double degree, {
Point<double>? point,
Expand All @@ -125,8 +125,8 @@ abstract class MapController {
///
/// See documentation on those methods for more details.
///
/// The operation was successful if [MoveAndRotateResult.moveSuccess] and
/// [MoveAndRotateResult.rotateSuccess] are `true`.
/// The operation was successful if both fields of the resulting record are
/// `true`.
MoveAndRotateResult moveAndRotate(
LatLng center,
double zoom,
Expand Down
10 changes: 1 addition & 9 deletions lib/src/misc/move_and_rotate_result.dart
Original file line number Diff line number Diff line change
@@ -1,9 +1 @@
import 'package:meta/meta.dart';

@immutable
class MoveAndRotateResult {
final bool moveSuccess;
final bool rotateSuccess;

const MoveAndRotateResult(this.moveSuccess, this.rotateSuccess);
}
typedef MoveAndRotateResult = ({bool moveSuccess, bool rotateSuccess});

0 comments on commit 6f41b1f

Please sign in to comment.