We have released the 3.0 version of Situm Wayfinding, this time the Wayfinding is based on the Situm Map Viewer. This enhancement brings numerous advantages, such as providing a consistent user experience across multiple platforms and also improved usability.
Please note that this major version enhances not only the UI but also the API so there are some required changes to migrate to this new version. For instance, we have replaced Google Maps with Mapbox, eliminating the need for a Google Maps API key. It is important to mention that certain functionalities previously available may not be present in this new version. Rest assured, we are actively working on further development and enhancements for the module.
New repository and plugin name #
On the Flutter platform, we have changed the name of the Dart package, and also the name of the public repository that contains the code of the plugin. New name is shorter and suits better the purpose of the complete plugin.
Old | New | |
---|---|---|
Plugin name | Situm Flutter Wayfinding | Situm Flutter |
Package name | situm_flutter_wayfinding | situm_flutter |
Migrate from Situm Flutter Wayfinding to the new Situm Flutter plugin #
Before starting the migration process make sure you have a clean state on your project, and ensure you have a way to revert the process in case something goes wrong during the migration. A repository is almost always a good idea for that.
Migrating your app from Situm Flutter Wayfinding to Situm Flutter requires modifications in both the native and Dart parts of your app. However, the process is straightforward, and you will notice that your code becomes cleaner than before:
Flutter – Project configuration #
As a first step, you need to update the Situm dependency to use the new version
- Replace the library. Update your pubspec.yaml:
dependencies: ... # From: situm_flutter_wayfinding: x.y.z # To: situm_flutter: x.y.z
- Update your dependency manager: As usual, with flutter pub get, or with your IDE. In this point, the project won’t compile, but don’t worry, in a few minutes everything will be fine again.
Flutter – Android #
In Android, you’ll need to perform the following actions:
- Remove FlutterAppCompatActivity. This class has been removed from the repository. Therefore, your MainActivity no longer needs to extend it. Use the platform’s FlutterActivity or FlutterFragmentActivity.
- Remove androidx.appcompat. The androidx.appcompat dependency is no longer required. You can remove it from your app’s build.gradle file.
- Restore your styles.xml. Extending Theme.AppCompat.Light is also not necessary now. The previous version of Wayfinding did not have support for the Dark Theme, which is now a built-in feature. You no longer need to enforce the use of the Light Theme so you can use the default values provided by Flutter in your styles.xml file (or customize it as supported by the platform).
- Remove your Google Maps Api Key. Google Maps has been replaced by Mapbox. You no longer need to provide a Google Maps API Key: remove it from your AndroidManifest.
Flutter – iOS #
In iOS, you’ll just need to:
- Update pods. Run pod install or pod update if necessary.
Flutter – Dart #
- Update your imports. In the corresponding Dart file (e.g. main.dart or wherever you use our library):
// From: import 'package:situm_flutter_wayfinding/situm_flutter_sdk.dart'; import 'package:situm_flutter_wayfinding/situm_flutter_wayfinding.dart'; // To: import 'package:situm_flutter/sdk.dart'; import 'package:situm_flutter/wayfinding.dart';
- Rename SitumFlutterSDK. This has been renamed to SitumSdk, update your code accordingly.
- Rename SitumMapView. SitumMapView has been renamed to MapView.
- Rename the controller received in the onLoad callback to MapViewController. Update any reference in your code.
- Wrap the MapView configuration. All the parameters of the MapView widget have been encapsulated into a single MapViewConfiguration object. Additionally, you will notice that the number of parameters has decreased dramatically (since the new MapView can be configured remotely).
// Example: MapView( key: const Key("situm_map"), mapViewConfiguration: MapViewConfiguration( // Your Situm credentials. situmUser: situmUser, situmApiKey: situmApiKey, buildingIdentifier: buildingIdentifier, // ... ), loadCallback: _loadCallback, ) // ... void _onLoad(MapViewController controller) { // Use MapViewController to communicate with the map: methods and callbacks // are available to perform actions and listen to events (e.g., set the user // location, listen to POI selections, intercept navigation options, etc.). // You need to wait until the map is properly loaded to do so. mapViewController = controller; }
- Initialize geolocation and forward locations to the MapView. The new MapView is totally independent from the positioning system. Now, your are responsible of telling the widget where the user is. This means that you’ll need to start positioning by calling the method requestLocationUpdates. If you did use this method in the app in the past, you’ll need to migrate it slightly: this method has changed so that now it only receives a single LocationRequest parameter encapsulating positioning options.
// From: situmSdk.requestLocationUpdates( _MyLocationListener(echoer: _echo), // The LocationListener is not needed anymore. {"buildingIdentifier": buildingIdentifier}, ); // To: situmSdk.requestLocationUpdates(LocationRequest( buildingIdentifier: buildingIdentifier ));
- Update the positioning callbacks. These callbacks have been refactored to be more idiomatic, so you no longer need to create a custom class implementing the LocationListener (it has been removed). Now you simply register the callbacks as bellow:
// Set up location callbacks: situmSdk.onLocationUpdate((location) { // ... }); situmSdk.onLocationStatus((status) { // ... }); situmSdk.onLocationError((error) { // ... });
- Request permissions. Now you are responsible of requesting all the app permissions. Check the Situm documentation for more info on the permissions required, and our Quickstart guide for an example of how you might request them.