From a91054394b865459067e9556798ec9d21853e40e Mon Sep 17 00:00:00 2001 From: suresh Date: Mon, 24 Apr 2023 19:10:55 +0530 Subject: [PATCH] deliveryboy commit --- android/app/build.gradle | 4 + android/app/src/main/AndroidManifest.xml | 20 +++ assets/images/drop_marker.png | Bin 0 -> 4637 bytes assets/images/pickup_marker.png | Bin 0 -> 1288 bytes lib/app_colors.dart | 32 ++++ lib/app_images.dart | 4 + lib/app_sizes.dart | 23 +++ lib/delivrybookingdata.dart | 16 +- lib/helper.dart | 34 ++++ lib/location_controller.dart | 118 ++++++++++++++ lib/model/getdeliveryboy_model.dart | 5 +- lib/order_tracking_page.dart | 149 ++++++++++++++++++ lib/padding_type_enum.dart | 1 + lib/permission_alert.dart | 53 +++++++ lib/primary_button.dart | 65 ++++++++ lib/primary_text.dart | 88 +++++++++++ pubspec.lock | 49 ++++++ pubspec.yaml | 3 + .../flutter/generated_plugin_registrant.cc | 3 + windows/flutter/generated_plugins.cmake | 1 + 20 files changed, 665 insertions(+), 3 deletions(-) create mode 100644 assets/images/drop_marker.png create mode 100644 assets/images/pickup_marker.png create mode 100644 lib/app_colors.dart create mode 100644 lib/app_images.dart create mode 100644 lib/app_sizes.dart create mode 100644 lib/helper.dart create mode 100644 lib/location_controller.dart create mode 100644 lib/order_tracking_page.dart create mode 100644 lib/padding_type_enum.dart create mode 100644 lib/permission_alert.dart create mode 100644 lib/primary_button.dart create mode 100644 lib/primary_text.dart diff --git a/android/app/build.gradle b/android/app/build.gradle index dfa5b98..5829cfb 100644 --- a/android/app/build.gradle +++ b/android/app/build.gradle @@ -57,3 +57,7 @@ android { flutter { source '../..' } + +dependencies { + implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" +} diff --git a/android/app/src/main/AndroidManifest.xml b/android/app/src/main/AndroidManifest.xml index a170f52..2a79e4e 100644 --- a/android/app/src/main/AndroidManifest.xml +++ b/android/app/src/main/AndroidManifest.xml @@ -1,5 +1,23 @@ + + + + + + + + + + + + + + + + + + + diff --git a/assets/images/drop_marker.png b/assets/images/drop_marker.png new file mode 100644 index 0000000000000000000000000000000000000000..ae03626f82a632cdb348c18f185ed3719b2719b2 GIT binary patch literal 4637 zcmV+&65{QNP)U+Om-M#KDk;o{cj55k7ql_}jD5H!r$|$3ZGRi2U z^d~^{tM(I5&uniP@~`h)0k5^(Z29WC@r3WkbNu=G0| zL;b8^X*`N?EPX@4P<0B13I;=s8%n&|>Yp-iYZznORZMAs(QR!Frt3wIgYL^^!%&?HhC0Eu z$QBGX&TS`57xbG$>P=%rqfPj#<_S`akULgkKoA;@p+4bSC?}ocUSs(LslYYEFu8mC zgvs-w(WH(RY7WOx=L84A_OVl7%Pne~LZSh5z>pa{zvqyRC>|c|x-f<>;?WPQi#dyud)sJ_p{q9LR z7Cv^<`yB6URH)Ft7TqZ_cfDO~p4ndf7k>CzlN53~dZ;kIIGP0SIkvd-<=$bbdj@L_ zvS`HmEFP%ndceu4*F-|8t!`~JwWbn9?9!*kX&eD`U-pg?3h zSL3b1$brK$biE)guUmx{&)g|Cm-9f1%-`!hRmm|_$#6NtexfBhT4aI(IZ_zGH!5@s zPpu(7;O9x|O?Km?=r;y|!jwJ#yY@nJ3)G1IMfG^cWtlB0Q-{kL3&)QW6b7-k3L`)# zuhl6m$Iw5ZdHrH?9@ucbhh=lBkD_H9D;dI8rQ3j+73RS}UL+FPb6mojy za64n+s02bkAhVr<_c`=2%eQb80^y;sv`kPSWE4~%&R95lfpmbS%>)CYVCWBwK)3pv8QIBAx8|1>vG%&J!%r zCeS$6umEA{3WLJHr3wpOBX|F@44d5M>jc7e;=|mt#mj*of*+MY82Xk$hf@@CdabUJ ztIG)13Sjx8N)8boG`|35359TWBkT0pVDxO4oWrI&HGXoRH}4j89}q z@R>f1KbGRV49Bvg)xx=3PejO~8G@MqTpRe#nX2*Jc7F#n9@^1=`WZUHfIw)uEKDmn}v(Dsi3#4!>3eoSFYLPfFx&2xZ6&`ts>!p zv}B5r7wwOtum#Fv4KWgI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@_hm)|(GwM&jQ6w!s2K9?6 zAvWYJ^Rzt`?+3 with TickerProv color: primaryColor, ), onPressed: () { - /* showTankerBookingDialog( - tankersList[index]);*/ + + Navigator.push( + context, + new MaterialPageRoute( + builder: (__) => new OrderTrackingPage(lat:activeOrdersList[index].lat,lng:activeOrdersList[index].lng))); + + /* Navigator.push( + context, + MaterialPageRoute(builder: (context) => OrderTrackingPage()), + );*/ + + }, ), Text( diff --git a/lib/helper.dart b/lib/helper.dart new file mode 100644 index 0000000..635611e --- /dev/null +++ b/lib/helper.dart @@ -0,0 +1,34 @@ +import 'package:flutter/material.dart'; + +MaterialColor getSwatch(Color color) { + final hslColor = HSLColor.fromColor(color); + final lightness = hslColor.lightness; + + /// if [500] is the default color, there are at LEAST five + /// steps below [500]. (i.e. 400, 300, 200, 100, 50.) A + /// divisor of 5 would mean [50] is a lightness of 1.0 or + /// a color of #ffffff. A value of six would be near white + /// but not quite. + const lowDivisor = 6; + + /// if [500] is the default color, there are at LEAST four + /// steps above [500]. A divisor of 4 would mean [900] is + /// a lightness of 0.0 or color of #000000 + const highDivisor = 5; + + final lowStep = (1.0 - lightness) / lowDivisor; + final highStep = lightness / highDivisor; + + return MaterialColor(color.value, { + 50: (hslColor.withLightness(lightness + (lowStep * 5))).toColor(), + 100: (hslColor.withLightness(lightness + (lowStep * 4))).toColor(), + 200: (hslColor.withLightness(lightness + (lowStep * 3))).toColor(), + 300: (hslColor.withLightness(lightness + (lowStep * 2))).toColor(), + 400: (hslColor.withLightness(lightness + lowStep)).toColor(), + 500: (hslColor.withLightness(lightness)).toColor(), + 600: (hslColor.withLightness(lightness - highStep)).toColor(), + 700: (hslColor.withLightness(lightness - (highStep * 2))).toColor(), + 800: (hslColor.withLightness(lightness - (highStep * 3))).toColor(), + 900: (hslColor.withLightness(lightness - (highStep * 4))).toColor(), + }); +} diff --git a/lib/location_controller.dart b/lib/location_controller.dart new file mode 100644 index 0000000..1df954f --- /dev/null +++ b/lib/location_controller.dart @@ -0,0 +1,118 @@ +import 'dart:developer'; +import 'dart:ui' as ui; + +import 'package:flutter/material.dart'; +import 'package:flutter/services.dart'; +import 'package:get/get.dart'; +import 'package:google_maps_flutter/google_maps_flutter.dart'; +import 'package:location/location.dart'; + +import 'app_images.dart'; +import 'app_sizes.dart'; +import 'permission_alert.dart'; + +class LocationController extends GetxController { + Location location = Location(); + + // final Rx locationPosition = const LatLng(0.0, 0.0).obs; + final Rx locationPosition = + const LatLng(12.90618717, 77.5844983).obs; + + bool locationServiceActive = true; + + BitmapDescriptor? pickupMarker; + BitmapDescriptor? dropMarker; + + @override + void onInit() async { + + await _getBytesFromAsset(AppImages.pickupMarker, AppSizes.mapPinSize * 0.2); + await _getBytesFromAsset(AppImages.dropMarker, AppSizes.mapPinSize * 0.2); + + super.onInit(); + refreshToLiveLocation(); + } + + Future _getBytesFromAsset(String path, double size) async { + ByteData data = await rootBundle.load(path); + ui.Codec codec = await ui.instantiateImageCodec( + data.buffer.asUint8List(), + targetWidth: size.toInt(), + allowUpscaling: true, + ); + ui.FrameInfo fi = await codec.getNextFrame(); + if (path == AppImages.pickupMarker) { + pickupMarker = BitmapDescriptor.fromBytes( + (await fi.image.toByteData(format: ui.ImageByteFormat.png))! + .buffer + .asUint8List()); + } else if (path == AppImages.dropMarker) { + dropMarker = BitmapDescriptor.fromBytes( + (await fi.image.toByteData(format: ui.ImageByteFormat.png))! + .buffer + .asUint8List()); + } else {} + } + + refreshToLiveLocation() async { + log("initiating"); + bool serviceEnabled; + + PermissionStatus permissionGranted; + + serviceEnabled = await location.serviceEnabled(); + + if (!serviceEnabled) { + serviceEnabled = await location.requestService(); + locationPosition.value = null; + return; + } + log("permission check"); + permissionGranted = await location.hasPermission(); + + if (permissionGranted == PermissionStatus.denied) { + permissionGranted = await location.requestPermission(); + if (permissionGranted != PermissionStatus.granted) { + showPermissionAlertDialog( + requestMsg: + "Location access needed. Go to Android settings, tap App permissions and tap Allow.", + barrierDismissible: false, + ); + } else { + await location.changeSettings( + accuracy: LocationAccuracy.balanced, + interval: 5000, + distanceFilter: 2); + + location.onLocationChanged.listen((LocationData currentLocation) async { + var lat = currentLocation.latitude; + var long = currentLocation.longitude; + if (lat != null && long != null) { + locationPosition.value = LatLng( + lat, + long, + ); + log("live location ${locationPosition.value}"); + } + }); + } + } else { + await location.changeSettings( + accuracy: LocationAccuracy.balanced, + interval: 5000, + distanceFilter: 2); + + location.onLocationChanged.listen((LocationData currentLocation) async { + var lat = currentLocation.latitude; + var long = currentLocation.longitude; + if (lat != null && long != null) { + locationPosition.value = LatLng( + lat, + long, + ); + log("live location ${locationPosition.value}"); + } + }); + } + } +} diff --git a/lib/model/getdeliveryboy_model.dart b/lib/model/getdeliveryboy_model.dart index 312e813..e1ab483 100644 --- a/lib/model/getdeliveryboy_model.dart +++ b/lib/model/getdeliveryboy_model.dart @@ -23,6 +23,8 @@ class GetDeliveryboyDetailsModel { String paymentMode = ''; String deliverdWater = ''; var tankerRunningStatus ; + double lat=0; + double lng=0; @@ -59,7 +61,8 @@ class GetDeliveryboyDetailsModel { rtvm.paymentMode = json['payment_mode'] ??''; rtvm.deliverdWater = json['quantityDelivered'] ??''; rtvm.tankerRunningStatus = json['tankerRunningStatus'] ??''; - + rtvm.lat = json['latitude'] ??0; + rtvm.lng = json['longitude'] ??0; return rtvm; } diff --git a/lib/order_tracking_page.dart b/lib/order_tracking_page.dart new file mode 100644 index 0000000..1eb6f40 --- /dev/null +++ b/lib/order_tracking_page.dart @@ -0,0 +1,149 @@ +import 'dart:async'; +import 'dart:developer'; + +import 'package:flutter/material.dart'; +import 'package:flutter_polyline_points/flutter_polyline_points.dart'; +import 'package:get/get.dart'; +import 'package:google_maps_flutter/google_maps_flutter.dart'; + +import 'location_controller.dart'; + + +class OrderTrackingPage extends StatefulWidget { + + var lat; + var lng; + OrderTrackingPage({ + this.lat,this.lng + }); + + @override + OrderTrackingPageState createState() => OrderTrackingPageState(); +} + +class OrderTrackingPageState extends State { + final Completer mapController = Completer(); + PolylinePoints polylinePoints = PolylinePoints(); + double latitude=0; + double longitude=0; + + String googleAPiKey = "AIzaSyBOigf-qg4v_aD0Jrx2wFOMNzObxXrfDEM"; + + Set markers = {}; + Map polylines = {}; + + LatLng startLocation = const LatLng(0,0); + + + LocationController locationController = Get.put(LocationController()); + + @override + void initState() { + super.initState(); + latitude=widget.lat; + longitude=widget.lng; + LatLng endLocation = LatLng(widget.lat,widget.lng); + + ever(locationController.locationPosition, (value) { + if (value != null) { + log("${value.latitude} ${value.longitude}"); + var latitude = value.latitude; + var longitude = value.longitude; + startLocation = LatLng(latitude, longitude); + getDirections(endLocation); + } + }); + + getDirections(endLocation); //fetch direction polylines from Google API + } + + getDirections(endLocation) async { + markers.clear(); + + markers.add(Marker( + markerId: MarkerId(startLocation.toString()), + position: startLocation, + infoWindow: const InfoWindow( + title: 'Starting Point ', + snippet: 'Start Marker', + ), + icon: locationController.pickupMarker ?? BitmapDescriptor.defaultMarker, + )); + + markers.add(Marker( + markerId: MarkerId(endLocation.toString()), + position: endLocation, //position of marker + infoWindow: const InfoWindow( + title: 'Destination Point ', + snippet: 'Destination Marker', + ), + icon: locationController.dropMarker ?? BitmapDescriptor.defaultMarker, + )); + + List polylineCoordinates = []; + + PolylineResult result = await polylinePoints.getRouteBetweenCoordinates( + googleAPiKey, + PointLatLng(startLocation.latitude, startLocation.longitude), + PointLatLng(endLocation.latitude, endLocation.longitude), + travelMode: TravelMode.driving, + ); + + if (result.points.isNotEmpty) { + for (var point in result.points) { + polylineCoordinates.add(LatLng(point.latitude, point.longitude)); + } + } else { + log(result.errorMessage ?? "Something went wrong"); + } + addPolyLine(polylineCoordinates); + } + + addPolyLine(List polylineCoordinates) async { + PolylineId id = const PolylineId("poly"); + Polyline polyline = Polyline( + polylineId: id, + color: Colors.blueAccent, + points: polylineCoordinates, + width: 8, + ); + polylines[id] = polyline; + + var position = CameraPosition( + target: LatLng(startLocation.latitude, startLocation.longitude), + zoom: 21); + + final GoogleMapController controller = await mapController.future; + controller.animateCamera(CameraUpdate.newCameraPosition(position)); + + setState(() {}); + } + + @override + Widget build(BuildContext context) { + return Scaffold( + body: GoogleMap( + //Map widget from google_maps_flutter package + zoomGesturesEnabled: true, + //enable Zoom in, out on map + initialCameraPosition: CameraPosition( + //innital position in map + target: startLocation, //initial position + zoom: 5.0, //initial zoom level + ), + markers: markers, + //markers to show on map + polylines: Set.of(polylines.values), + //polylines + mapType: MapType.normal, + //map type + onMapCreated: (controller) { + //method called when map is created + if (!mapController.isCompleted) { + mapController.complete(controller); + } + }, + ), + ); + } +} diff --git a/lib/padding_type_enum.dart b/lib/padding_type_enum.dart new file mode 100644 index 0000000..dd8ab72 --- /dev/null +++ b/lib/padding_type_enum.dart @@ -0,0 +1 @@ +enum PaddingType { symmetric, only } diff --git a/lib/permission_alert.dart b/lib/permission_alert.dart new file mode 100644 index 0000000..7a1fb34 --- /dev/null +++ b/lib/permission_alert.dart @@ -0,0 +1,53 @@ +import 'package:flutter/material.dart'; +import 'package:get/get_core/src/get_main.dart'; +import 'package:get/get_navigation/get_navigation.dart'; +import 'package:permission_handler/permission_handler.dart'; + +import 'app_colors.dart'; +import 'primary_button.dart'; +import 'primary_text.dart'; + +void showPermissionAlertDialog({ + String title = "Need Permission", + required String requestMsg, + bool barrierDismissible = true, +}) { + Get.defaultDialog( + title: title, + middleText: "", + backgroundColor: Colors.white, + contentPadding: const EdgeInsets.only(top: 30, bottom: 30.0), + radius: 10, + barrierDismissible: barrierDismissible, + titlePadding: const EdgeInsets.only(top: 15), + titleStyle: const TextStyle( + color: AppColors.grey900Color, + fontSize: 18, + fontWeight: FontWeight.w600, + ), + /*cancel: PrimaryButton( + title: "DISMISS", + onPressed: () {}, + textSize: AppSizes.font_13, + bgColor: AppColors.grey500Color, + ),*/ + confirm: PrimaryButton( + title: "GO TO SETTINGS", + onPressed: () { + openAppSettings(); + Get.back(); + }, + textSize: 13, + ), + content: Padding( + padding: const EdgeInsets.symmetric(horizontal: 8.0), + child: PrimaryText( + requestMsg, + textAlign: TextAlign.center, + fontColor: AppColors.grey800Color, + fontSize: 15, + fontWeight: FontWeight.w500, + ), + ), + ); +} diff --git a/lib/primary_button.dart b/lib/primary_button.dart new file mode 100644 index 0000000..cfe2beb --- /dev/null +++ b/lib/primary_button.dart @@ -0,0 +1,65 @@ +import 'package:flutter/material.dart'; + +import 'app_colors.dart'; +import 'primary_text.dart'; + + +class PrimaryButton extends StatelessWidget { + final String title; + final VoidCallback onPressed; + final double verticalPadding; + final bool textAllCaps; + final double textSize; + final FontWeight textWeight; + final Color textColor; + final TextDecoration textDecoration; + final int letterSpacing; + final bool isResponsive; + final Color bgColor; + final double horizontalPadding; + + const PrimaryButton({ + Key? key, + required this.title, + required this.onPressed, + this.verticalPadding = 10.0, + this.textAllCaps = true, + this.textSize = 14, + this.textWeight = FontWeight.w500, + this.textColor = Colors.white, + this.textDecoration = TextDecoration.none, + this.letterSpacing = 1, + this.isResponsive = true, + this.bgColor = AppColors.primaryColor, + this.horizontalPadding = 25.0, + }) : super(key: key); + + @override + Widget build(BuildContext context) { + return Card( + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(40), + ), + color: bgColor, + child: InkWell( + onTap: onPressed, + child: Padding( + padding: EdgeInsets.symmetric( + vertical: verticalPadding, + horizontal: horizontalPadding, + ), + child: PrimaryText( + textAllCaps ? title.toUpperCase() : title, + // title.toUpperCase(), + textAlign: TextAlign.center, + fontSize: textSize, + fontWeight: textWeight, + fontColor: textColor, + textDecoration: textDecoration, + isResponsive: isResponsive, + ), + ), + ), + ); + } +} diff --git a/lib/primary_text.dart b/lib/primary_text.dart new file mode 100644 index 0000000..ec70048 --- /dev/null +++ b/lib/primary_text.dart @@ -0,0 +1,88 @@ +import 'package:flutter/material.dart'; + +import 'app_sizes.dart'; +import 'padding_type_enum.dart'; + + +class PrimaryText extends StatelessWidget { + final String text; + final Color? fontColor; + final double fontSize; + final FontWeight fontWeight; + final double horizontalPadding; + final double verticalPadding; + final TextAlign textAlign; + final bool isResponsive; + final TextDecoration? textDecoration; + final PaddingType paddingType; + final double leftPadding; + final double rightPadding; + final double lineHeight; + final FontStyle fontStyle; + final TextOverflow textOverflow; + final bool textAllCaps; + final double letterSpacing; + + const PrimaryText( + this.text, { + Key? key, + this.fontColor = Colors.black, + this.fontSize = 16, + this.fontWeight = FontWeight.w600, + this.horizontalPadding = 0.0, + this.verticalPadding = 0.0, + this.textAlign = TextAlign.start, + this.isResponsive = true, + this.textDecoration, + this.paddingType = PaddingType.symmetric, + this.leftPadding = 0.0, + this.rightPadding = 0.0, + this.lineHeight = 1.5, + this.fontStyle = FontStyle.normal, + this.textOverflow = TextOverflow.visible, + this.textAllCaps = false, + this.letterSpacing = 0, + }) : super(key: key); + + @override + Widget build(BuildContext context) { + return Padding( + padding: paddingType == PaddingType.symmetric + ? EdgeInsets.symmetric( + horizontal: horizontalPadding, + vertical: verticalPadding, + ) + : EdgeInsets.only( + left: leftPadding, + right: rightPadding, + ), + child: Text( + textAllCaps ? text.toUpperCase() : text, + style: TextStyle( + fontSize: responsiveTextSize(), + fontWeight: fontWeight, + color: fontColor, + decoration: textDecoration, + height: lineHeight, + fontStyle: fontStyle, + letterSpacing: letterSpacing, + ), + textScaleFactor: 1, + textAlign: textAlign, + ), + ); + } + + double responsiveTextSize() { + if (isResponsive) { + if (AppSizes.deviceHeight < AppSizes.height490) { + return fontSize - 3; + } else if (AppSizes.deviceHeight < AppSizes.height740) { + return fontSize - 2; + } else if (AppSizes.deviceHeight < AppSizes.height880) { + return fontSize - 1; + } + } + return fontSize; + } +} diff --git a/pubspec.lock b/pubspec.lock index d02cf85..517ba11 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -172,6 +172,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "2.0.9" + flutter_polyline_points: + dependency: "direct main" + description: + name: flutter_polyline_points + url: "https://pub.dartlang.org" + source: hosted + version: "1.0.0" flutter_styled_toast: dependency: "direct dev" description: @@ -280,6 +287,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "0.1.1" + get: + dependency: "direct main" + description: + name: get + url: "https://pub.dartlang.org" + source: hosted + version: "4.6.5" google_api_headers: dependency: "direct main" description: @@ -518,6 +532,41 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "2.1.5" + permission_handler: + dependency: "direct main" + description: + name: permission_handler + url: "https://pub.dartlang.org" + source: hosted + version: "10.2.0" + permission_handler_android: + dependency: transitive + description: + name: permission_handler_android + url: "https://pub.dartlang.org" + source: hosted + version: "10.2.0" + permission_handler_apple: + dependency: transitive + description: + name: permission_handler_apple + url: "https://pub.dartlang.org" + source: hosted + version: "9.0.8" + permission_handler_platform_interface: + dependency: transitive + description: + name: permission_handler_platform_interface + url: "https://pub.dartlang.org" + source: hosted + version: "3.9.0" + permission_handler_windows: + dependency: transitive + description: + name: permission_handler_windows + url: "https://pub.dartlang.org" + source: hosted + version: "0.1.2" petitparser: dependency: transitive description: diff --git a/pubspec.yaml b/pubspec.yaml index d27e58f..148dea6 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -15,6 +15,9 @@ dependencies: cupertino_icons: ^1.0.2 location: ^4.4.0 + flutter_polyline_points: ^1.0.0 + get: ^4.6.5 + permission_handler: ^10.2.0 geolocator: ^9.0.2 google_api_headers: ^1.5.0+1 google_maps_flutter: ^2.2.3 diff --git a/windows/flutter/generated_plugin_registrant.cc b/windows/flutter/generated_plugin_registrant.cc index 94586cc..ce843bc 100644 --- a/windows/flutter/generated_plugin_registrant.cc +++ b/windows/flutter/generated_plugin_registrant.cc @@ -7,11 +7,14 @@ #include "generated_plugin_registrant.h" #include +#include #include void RegisterPlugins(flutter::PluginRegistry* registry) { GeolocatorWindowsRegisterWithRegistrar( registry->GetRegistrarForPlugin("GeolocatorWindows")); + PermissionHandlerWindowsPluginRegisterWithRegistrar( + registry->GetRegistrarForPlugin("PermissionHandlerWindowsPlugin")); UrlLauncherWindowsRegisterWithRegistrar( registry->GetRegistrarForPlugin("UrlLauncherWindows")); } diff --git a/windows/flutter/generated_plugins.cmake b/windows/flutter/generated_plugins.cmake index f0bcafd..b3ea692 100644 --- a/windows/flutter/generated_plugins.cmake +++ b/windows/flutter/generated_plugins.cmake @@ -4,6 +4,7 @@ list(APPEND FLUTTER_PLUGIN_LIST geolocator_windows + permission_handler_windows url_launcher_windows )