todos-contra-el-fuego-mobile/lib/compassMapPlugin.dart
vjrj f39bdbfaef feat: add compass button to reset map rotation to north
- Add new CompassMapPluginWidget for map north alignment control
- Position compass button at top-right of maps
- Reset rotation to 0° while maintaining center and zoom level
- Improve UX by allowing users to easily return to north orientation
- Integrate compass into both genericMap and monitoredAreas pages
2026-03-06 08:49:45 +01:00

41 lines
1.2 KiB
Dart

import 'package:comunes_flutter/comunes_flutter.dart';
import 'package:flutter/material.dart';
import 'package:flutter_map/flutter_map.dart';
/// Compass button widget for resetting map rotation to north
class CompassMapPluginWidget extends StatelessWidget {
@override
Widget build(BuildContext context) {
return LayoutBuilder(
builder: (context, constraints) =>
Stack(fit: StackFit.expand, children: <Widget>[
Positioned(
top: 10.0,
right: 10.0,
child: new CenteredRow(
children: <Widget>[
new Column(
children: <Widget>[
_compassButton(context),
],
)
],
),
)
]));
}
FloatingActionButton _compassButton(BuildContext context) {
return FloatingActionButton(
backgroundColor: Colors.black26,
mini: true,
heroTag: 'compass_button',
onPressed: () {
final controller = MapController.of(context);
// Reset rotation to 0 (north) while keeping center and zoom
controller.rotate(0);
},
child: Icon(Icons.explore),
);
}
}