dencity_map_plugin 0.0.2
dencity_map_plugin: ^0.0.2 copied to clipboard
An Android Native Plugin Support for Dencitylite Android Applications
dencity_map_plugin #
An Android Native Plugin Support for Dencitylite Android Applications
👋 Get started #
This is a plugin for Dencitylite Android Applications. This plugin is used to show the map in the Dencitylite Android Applications.
Prerequisites #
Add the following dependencies in your project level android/app/src/main/res/strings.xml file.
<string name="google_maps_key">GOOGLE_MAPS_API_KEY</string>
import com.dencity.dencity_map_plugin.NativeViewFactory
import io.flutter.embedding.android.FlutterActivity
import io.flutter.embedding.engine.FlutterEngine
class MainActivity : FlutterActivity() {
override fun configureFlutterEngine(flutterEngine: FlutterEngine) {
super.configureFlutterEngine(flutterEngine)
flutterEngine
.platformViewsController
.registry
.registerViewFactory("com.dencity.dencity_map_plugin/map_view",
NativeViewFactory(this)
)
}
}
🚀 Installation #
Add dependency #
Add the plugin to your pubspec.yaml file
dependencies:
dencity_map_plugin: <latest_version>
The latest version is:
The latest version including pre-releases is:
Usage #
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(
title: const Text('Plugin example app'),
),
body: PlatformViewLink(
viewType: 'com.dencity.dencity_map_plugin/map_view',
surfaceFactory: (context, controller) {
return AndroidViewSurface(
controller: controller as AndroidViewController,
gestureRecognizers: const <Factory<
OneSequenceGestureRecognizer>>{},
hitTestBehavior: PlatformViewHitTestBehavior.opaque,
);
},
onCreatePlatformView: (params) {
return PlatformViewsService.initSurfaceAndroidView(
id: params.id,
viewType: 'com.dencity.dencity_map_plugin/map_view',
layoutDirection: TextDirection.ltr,
creationParams: const <String, dynamic>{},
creationParamsCodec: const StandardMessageCodec(),
onFocus: () {
params.onFocusChanged(true);
},
)
..addOnPlatformViewCreatedListener(params.onPlatformViewCreated)
..create();
},
),
),
);
}
🔑 Generate App key #
- Go to the Google Maps Platform > Credentials page.
- On the Credentials page, click Create credentials > API key. The API key created dialog displays your newly created API key.
- Click Close.The new API key is listed on the Credentials page under API keys.(Remember to restrict the API key before using it in production.)