zyzdev / flutter_street_view

10 stars 34 forks source link

Plugin seems abandoned - use this fork #39

Open liorboyango opened 3 months ago

liorboyango commented 3 months ago

Seems like this plugin is abandoned, so I forked it and enabled support for:

Android:
    compileSdk 34
    com.google.android.gms:play-services-maps:19.0.0
Flutter:
    v3.24.0 & Dart v3.5.0
    js_interop instead of js
Dependencies:
    google_maps: 8.0.0

To use it, replace pubspec.yaml lineflutter_google_street_view: ^3.1.4 with

  flutter_google_street_view:
    git:
      url: https://github.com/liorboyango/flutter_street_view.git
      path: flutter_google_street_view
      ref: master

!Important note! There is a bug with com.google.android.gms:play-services-maps:19.0.0 that will cause your Android app to crash if requesting to view a location that does not have Street View support. To workaround this bug, you can check first if the location has Street View support BEFORE trying to view it. Something like this:

final apiKey = 'YOUR API KEY'; /// Make sure your project has Street View Static API enabled in cloud console: https://console.cloud.google.com/apis/library/street-view-image-backend.googleapis.com
final latitude = 32.0;
final longitude = 35.0;
final uri = Uri.https('maps.googleapis.com', 'maps/api/streetview/metadata', {
        'key': apiKey,
        'location': '$latitude,$longitude',
      });
final response = await Dio().getUri(uri);
final success = response.data['status'] == 'OK';
if (success) {
    /// Safe to show Street View in latitude & longitude above
} else {
    /// Show some error message: 'Street View not available at this location'
}