visiomoveessential_flutterbridge 0.0.1
visiomoveessential_flutterbridge: ^0.0.1 copied to clipboard
VisioMoveEssential Flutter bridge
example/lib/main.dart
import 'package:flutter/material.dart';
import 'dart:async';
import 'package:flutter/services.dart';
import 'package:visiomoveessential_flutterbridge/visiomoveessential_flutterbridge.dart';
import 'package:visiomoveessential_flutterbridge/visiomoveessential_flutterbridge_platform_interface.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatefulWidget {
const MyApp({super.key});
@override
State<MyApp> createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> {
String _sdkVersion = 'Unknown';
final _visiomoveessentialFlutterbridgePlugin = VisiomoveessentialFlutterbridge();
@override
void initState() {
super.initState();
initPlatformState();
}
// Platform messages are asynchronous, so we initialize in an async method.
Future<void> initPlatformState() async {
String version = '';
void onMapDataDidLoad (Object? result) async {
debugPrint("onMapDataDidLoad");
debugPrint(result.toString());
Map<Object?, Object?> venue = result as Map<Object?, Object?>;
String defaultBuildingId = venue["defaultBuildingId"] as String;
debugPrint(defaultBuildingId.toString());
try {
version = await _visiomoveessentialFlutterbridgePlugin.getVersion() ?? 'Unknown version';
_sdkVersion = version;
setState(() {});
} on PlatformException {
version = 'Failed to get version.';
}
}
void gotoPosition() {
Map<String, String> scene = {"buildingID": "B3", "floorID": "B3-UL01"};
Map<String, Object> lPos1 = {"latitude": 45.740876918853147, "longitude": 4.8805385544669795, "altitude": 3, "scene":scene};
Map<String, Object> lPos2 = {"latitude": 45.74079708627734, "longitude": 4.8810472180340518, "altitude": 3, "scene":scene};
Map<String, Object> lPos3 = {"latitude": 45.740555146004695, "longitude": 4.8806516436439189, "altitude": 3, "scene":scene};
var targets = [lPos1, lPos2 , lPos3, "B3-UL01-ID0021"];
Map<String, Object> animateCameraMap = {
"targets": targets,
"viewMode": "global",
"paddingTop":50.0,
"paddingBottom": 50.0,
"paddingLeft": 50.0,
"paddingRight": 50.0,
"duration": 2.0
};
_visiomoveessentialFlutterbridgePlugin.animateCamera(animateCameraMap);
}
void onMapViewDidLoad (Object? result) async {
debugPrint("onMapViewDidLoad");
debugPrint(result.toString());
Timer(const Duration(seconds: 1), () {
gotoPosition();
});
}
void onMapCameraDidMove (Object? result) async {
//debugPrint(result.toString());
}
void onAnimationDidFinish (Object? result) async {
debugPrint("onAnimationDidFinish");
debugPrint(result.toString());
}
_visiomoveessentialFlutterbridgePlugin.setOnMapDataDidLoad(onMapDataDidLoad);
_visiomoveessentialFlutterbridgePlugin.setOnMapViewDidLoad(onMapViewDidLoad);
_visiomoveessentialFlutterbridgePlugin.setMapHash("mb59995ef2012ff00e4e1ca8e93ebb0955685b269");
_visiomoveessentialFlutterbridgePlugin.loadMapData();
_visiomoveessentialFlutterbridgePlugin.loadMapView();
_visiomoveessentialFlutterbridgePlugin.setOnMapCameraDidMove(onMapCameraDidMove);
_visiomoveessentialFlutterbridgePlugin.setOnAnimationDidFinish(onAnimationDidFinish);
// If the widget was removed from the tree while the asynchronous platform
// message was in flight, we want to discard the reply rather than calling
// setState to update our non-existent appearance.
if (!mounted) return;
/*setState(() {
debugPrint("TOGTOG $version");
_sdkVersion = version;
});*/
}
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(
title: const Text('VMES Plugin example app'),
),
body: Center(
//child: VisiomoveessentialFlutterbridgePlatform.instance.buildView(),
child: Column(
children: [
Expanded(
child:
VisiomoveessentialFlutterbridgePlatform.instance.buildView(),
),
Text('Version: $_sdkVersion'),
]
)
),
),
);
}
}