-
-
Notifications
You must be signed in to change notification settings - Fork 87
Expand file tree
/
Copy pathgeocoding.dart
More file actions
97 lines (88 loc) · 3.75 KB
/
geocoding.dart
File metadata and controls
97 lines (88 loc) · 3.75 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
import 'package:flutter/widgets.dart';
import 'package:plugin_platform_interface/plugin_platform_interface.dart';
import 'geocoding_platform_factory.dart';
import 'types/types.dart';
/// Interface for a platform implementation of a [Geocoding] instance.
///
/// Platform implementations should extend this class rather than implement it
/// as `geocoding` package does not consider newly added methods to be breaking
/// changes. Extending this class (using `extends`) ensures that the subclass
/// will get the default implementation, while platform implementations that
/// `implements` this interface will be broken by newly added
/// [Geocoding] methods.
abstract class Geocoding extends PlatformInterface {
/// Creates a new [PlatformWebViewController]
factory Geocoding(GeocodingCreationParams params) {
assert(
GeocodingPlatformFactory.instance != null,
'A platform implementation for `geocoding` has not been set. Please '
'ensure that an implementation of `GeocodingPlatformFactory` has been '
'set te `GeocodingPlatformFactory.instance` before use. For unit '
'testing, `GeocodingPlatformFactory.instance` can be set with your own '
'test implementation.',
);
final Geocoding geocoding = GeocodingPlatformFactory.instance!
.createGeocoding(params);
PlatformInterface.verify(geocoding, _token);
return geocoding;
}
/// Used by the platform implementation to create a new [Geocoding].
///
/// Should only be used by platform implementations because they can't extend
/// a class that only contains a factory constructor.
@protected
Geocoding.implementation(this.params) : super(token: _token);
static final Object _token = Object();
/// The parameters used to initialize the [Geocoding] instance.
final GeocodingCreationParams params;
/// Returns a list of [Location] instances found for the supplied address.
///
/// In most situations the returned list should only contain one entry.
/// However in some situations where the supplied address could not be
/// resolved into a single [Location], multiple [Location] instances may be
/// returned.
Future<List<Location>> locationFromAddress(String address, {Locale? locale}) {
throw UnimplementedError(
'locationFromAddress() has not been implementated.',
);
}
/// Returns true if there is a geocoder implementation present that may return results.
/// If true, there is still no guarantee that any individual geocoding attempt will succeed.
///
///
/// This method is only implemented on Android, calling this on iOS always
/// returns [true].
Future<bool> isPresent() {
throw UnimplementedError('isPresent() has not been implementated.');
}
/// Returns a list of [Placemark] instances found for the supplied
/// coordinates.
///
/// In most situations the returned list should only contain one entry.
/// However in some situations where the supplied coordinates could not be
/// resolved into a single [Placemark], multiple [Placemark] instances may be
/// returned.
Future<List<Placemark>> placemarkFromCoordinates(
double latitude,
double longitude, {
Locale? locale,
}) {
throw UnimplementedError(
'placemarkFromCoordinates() has not been implementated.',
);
}
/// Returns a list of [Placemark] instances found for the supplied address.
///
/// In most situations the returned list should only contain one entry.
/// However in some situations where the supplied address could not be
/// resolved into a single [Placemark], multiple [Placemark] instances may be
/// returned.
Future<List<Placemark>> placemarkFromAddress(
String address, {
Locale? locale,
}) {
throw UnimplementedError(
'placemarkFromAddress() has not been implementated.',
);
}
}