Open alamen-pgooja opened 3 months ago
Huawei Flutter Location Library depend on Huawei Android Location SDK, it is intended to be used with Android only and it is not compatible with web applications, as a workaround, consider using conditional import to exclude Huawei Location library from your web build:
this code was not tested
example path: lib/stubs/huawei_location_stub.dart
:
class FusedLocationProviderClient {
// Define the methods and properties used from Huawei Location library.
Future<void> getLastLocation() async {
// No implementation for web.
}
// Add other methods as needed.
}
example path: lib/location_service_selector.dart
:
export 'package:huawei_location/huawei_location.dart'
if (dart.library.html) 'stubs/huawei_location_stub.dart';
import 'package:flutter/material.dart';
import 'location_service_selector.dart';
class LocationScreen extends StatelessWidget {
LocationScreen({Key? key}) : super(key: key);
final FusedLocationProviderClient _locationService =
FusedLocationProviderClient();
getLastLocation() async {
final Location location = await _locationService.getLastLocation();
// ...
}
@override
Widget build(BuildContext context) {
return Scaffold(...);
}
}
Description I'm using the same codebase for mobile and web, and I use the Huawei location library. When I run
flutter build web
, the build crashes during the compilation of the library. Log:Expected Behavior The build should compile normally.
Current Behavior The build fails during compilation.
Logs
Environment