Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Removed MoveAndRotateResult in favour of a Record<bool, bool> #1636

Merged
merged 2 commits into from
Sep 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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});