#2832 まで解決
This commit is contained in:
@ -25,7 +25,8 @@ class MapWidget extends StatefulWidget {
|
||||
State<MapWidget> createState() => _MapWidgetState();
|
||||
}
|
||||
|
||||
class _MapWidgetState extends State<MapWidget> {
|
||||
class _MapWidgetState extends State<MapWidget> with WidgetsBindingObserver {
|
||||
//class _MapWidgetState extends State<MapWidget> {
|
||||
final IndexController indexController = Get.find<IndexController>();
|
||||
final DestinationController destinationController =
|
||||
Get.find<DestinationController>();
|
||||
@ -46,6 +47,11 @@ class _MapWidgetState extends State<MapWidget> {
|
||||
_startIdleTimer();
|
||||
mapController = MapController();
|
||||
indexController.mapController = mapController;
|
||||
|
||||
// added by Akira
|
||||
WidgetsBinding.instance.addObserver(this);
|
||||
_startIdleTimer();
|
||||
|
||||
//_initMarkers();
|
||||
|
||||
// indexController.mapController = MapController(initCompleter: mapControllerCompleter);
|
||||
@ -54,22 +60,37 @@ class _MapWidgetState extends State<MapWidget> {
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
WidgetsBinding.instance.removeObserver(this); // added
|
||||
|
||||
mapController?.dispose();
|
||||
_timer?.cancel();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
// added by Akira
|
||||
@override
|
||||
void didChangeAppLifecycleState(AppLifecycleState state) {
|
||||
if (state == AppLifecycleState.resumed) {
|
||||
_resetTimer();
|
||||
}
|
||||
}
|
||||
|
||||
// _centerMapOnUser を10秒間でコール
|
||||
void _startIdleTimer() {
|
||||
_timer = Timer(const Duration(milliseconds: (1000 * 10)), _centerMapOnUser);
|
||||
}
|
||||
|
||||
// タイマーをリセットして_startIdleTimer をコール
|
||||
void _resetTimer() {
|
||||
_timer?.cancel();
|
||||
_startIdleTimer();
|
||||
}
|
||||
|
||||
// マッぷを現在位置を中心にする。
|
||||
void _centerMapOnUser() {
|
||||
destinationController.centerMapToCurrentLocation();
|
||||
if (mounted) {
|
||||
destinationController.centerMapToCurrentLocation();
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> _initMarkers() async {
|
||||
@ -172,8 +193,7 @@ class _MapWidgetState extends State<MapWidget> {
|
||||
context: context,
|
||||
isScrollControlled: true,
|
||||
isDismissible: true,
|
||||
builder: ((context) => BottomSheetNew(
|
||||
destination: des, isAlreadyCheckedIn: value.isNotEmpty)),
|
||||
builder: ((context) => BottomSheetNew(destination: des, isAlreadyCheckedIn: value.isNotEmpty)),
|
||||
).whenComplete(() {
|
||||
destinationController.shouldShowBottomSheet = true;
|
||||
destinationController.skipGps = false;
|
||||
@ -378,7 +398,7 @@ class _MapWidgetState extends State<MapWidget> {
|
||||
stream: locationController.locationMarkerPositionStream,
|
||||
builder: (context, snapshot) {
|
||||
if (!snapshot.hasData) {
|
||||
print("====== Not display current marker");
|
||||
debugPrint("====== Not display current marker");
|
||||
}
|
||||
return Container();
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user