dencity_map_plugin 0.0.1 copy "dencity_map_plugin: ^0.0.1" to clipboard
dencity_map_plugin: ^0.0.1 copied to clipboard

An Android Native Plugin Support for Dencitylite Android Applications

example/lib/main.dart

import 'package:flutter/foundation.dart';
import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart';
import 'dart:async';
import 'package:flutter/services.dart';
import 'package:dencity_map_plugin/dencity_map_plugin.dart';
import 'package:permission_handler/permission_handler.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 _platformVersion = 'Unknown';
  final _dencityMapPlugin = DencityMapPlugin();

  @override
  void initState() {
    super.initState();
    requestLocationPermission();
  }

  Future<void> requestLocationPermission() async {
    PermissionStatus status = await Permission.location.request();

    if (status.isGranted) {
      // The location permission is granted. You can now access the user's location.
    } else if (status.isDenied) {
      // The location permission is denied. You can't access the user's location.
    } else if (status.isPermanentlyDenied) {
      // The location permission is permanently denied. The user needs to enable it in the settings.
    }
  }

  @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();
          },
        ),
      ),
    );
  }
}
1
likes
0
points
28
downloads

Publisher

unverified uploader

Weekly Downloads

An Android Native Plugin Support for Dencitylite Android Applications

Homepage

License

unknown (license)

Dependencies

flutter, plugin_platform_interface

More

Packages that depend on dencity_map_plugin

Packages that implement dencity_map_plugin