-
-
Notifications
You must be signed in to change notification settings - Fork 29
Closed
Labels
Milestone
Description
Platforms
iOS
Version of flutter-maplibre
0.3.2
Bug Description
On iOS, calling OfflineManager.listOfflineRegions() immediately after OfflineManager.createInstance() during a fresh app start causes a runtime crash.
The problem appears to be timing-related:
if there is a short delay between createInstance() and listOfflineRegions(), the issue disappears and the method works correctly.
This suggests that the iOS OfflineManager is not fully initialized when listOfflineRegions() is called right after instance creation.
Steps to Reproduce
- Go to the example app.
- Replace offline_page.dart with the code sample listed below.
- Go to the offline page (iOS).
Expected Results
listOfflineRegions() should be safe to call immediately after createInstance() without throwing an exception.
Actual Results
[ERROR:flutter/runtime/dart_vm_initializer.cc(40)] Unhandled Exception: Null check operator used on a null value
#0 OfflineManagerIos.listOfflineRegions (package:maplibre/src/platform/ios/offline_manager.dart:113:33)
offline_manager.dart:113
#1 _OfflinePageState.initState.<anonymous closure> (package:maplibre_example/offline_page.dart:24:22)
offline_page.dart:24
#2 Future._propagateToListeners.handleValueCallback (dart:async/future_impl.dart:948:45)
future_impl.dart:948
#3 Future._propagateToListeners (dart:async/future_impl.dart:977:13)
future_impl.dart:977
#4 Future._addListener.<anonymous closure> (dart:async/future_impl.dart:543:9)
future_impl.dart:543
#5 _microtaskLoop (dart:async/schedule_microtask.dart:40:35)
schedule_microtask.dart:40
#6 _startMicrotaskLoop (dart:async/schedule_microtask.dart:49:5)
schedule_microtask.dart:49
Code Sample
import 'package:flutter/material.dart';
import 'package:maplibre/maplibre.dart';
@immutable
class OfflinePage extends StatefulWidget {
const OfflinePage({super.key});
static const location = '/offline';
@override
State<OfflinePage> createState() => _OfflinePageState();
}
class _OfflinePageState extends State<OfflinePage> {
late OfflineManager offlineManager;
List<OfflineRegion> offlineRegions = [];
@override
void initState() {
OfflineManager.createInstance().then((m) {
offlineManager = m;
offlineManager.listOfflineRegions().then((value) {
print('value $value');
});
});
super.initState();
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: const Text('Offline Map')),
body: Center(child: Text('Regions length: ${offlineRegions.length}')),
);
}
}Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
Projects
Status
Done