InMemoryLocationPlatform class
A LocationPlatform that lives in memory. It models the native side's behaviour — one merged stream request, native filtering, throttled last-known writes, pausing in the background — so tests run the real flow without a device.
- Implemented types
Constructors
- InMemoryLocationPlatform({LocationAccess access = LocationAccess.grantedPrecise, bool serviceEnabled = true, bool supported = true, bool inAppServicesDialog = true, DateTime clock()?})
Properties
- access ↔ LocationAccess
-
getter/setter pair
- activeRequest → StreamRequest?
-
no setter
-
attachedGenerations
→ List<
int> -
final
- background ↔ bool
-
getter/setter pair
- configuration ↔ ConfigurationCheck
-
getter/setter pair
- corruptStored ↔ String?
-
Set to make the next
lastKnownreport a corrupt stored value.getter/setter pair - currentFix ↔ Position?
-
What
currentPositionreturns when nothing else is scripted.null: no fix arrives (atimeout).getter/setter pair - currentPositionCalls ↔ int
-
getter/setter pair
-
diagnosticsFacts
↔ Map<
String, Object?> -
What
diagnostics()returns.getter/setter pair - disposeCount ↔ int
-
getter/setter pair
- forwardGeocodeCalls ↔ int
-
getter/setter pair
- geocodeDelay ↔ Duration
-
Delay before each geocode answers.
getter/setter pair
-
geocodeLocales
→ List<
String?> -
final
- geocoderAvailable ↔ bool
-
getter/setter pair
- geocodingFailure ↔ LocationFailureReason?
-
Every geocode call fails with this reason while set.
getter/setter pair
- hashCode → int
-
The hash code for this object.
no setterinherited
- inAppServicesDialog ↔ bool
-
Android with Play services shows an in-app "turn on location" dialog;
iOS and devices without Play services don't.
getter/setter pair
- isSupported → bool
-
falseon web and desktop, where every call returnsnotApplicable.no setteroverride - online ↔ bool?
-
null= online, as far as the platform can tell.getter/setter pair - openedAppSettings ↔ int
-
getter/setter pair
- openedLocationSettings ↔ int
-
getter/setter pair
- osLastKnown ↔ AgedPosition?
-
getter/setter pair
- persist ↔ bool
-
getter/setter pair
- playServicesResolvable ↔ bool
-
getter/setter pair
- positionSubscriptions ↔ int
-
getter/setter pair
- requestPreciseCalls ↔ int
-
getter/setter pair
- resolveServicesCalls ↔ int
-
getter/setter pair
- reverseGeocodeCalls ↔ int
-
getter/setter pair
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- serviceEnabled ↔ bool
-
getter/setter pair
- storedAddress → Address?
-
no setter
- storedLastKnown → Position?
-
no setter
- storeMinDistance ↔ double
-
getter/setter pair
- storeMinInterval ↔ Duration
-
getter/setter pair
- storeWrites ↔ int
-
Disk writes of the stored last known location.
getter/setter pair
- streaming → bool
-
Whether the native stream is running.
no setter
-
streamRequests
→ List<
StreamRequest> -
final
- supported ↔ bool
-
getter/setter pair
Methods
-
answerPermissionPrompt(
) → void - Answers the permission flow: applies the next scripted answer.
-
answerServicesPrompt(
) → bool - Answers a services prompt. Returns whether services are now on.
-
attach(
int generation, Map< String, Object?> settings) → Future<void> -
Called once per Dart isolate before anything else. A new
generationtells the native side a hot restart happened: drop every listener and pending callback from the previous isolate.override -
checkConfiguration(
) → Future< ConfigurationCheck> -
override
-
checkPermission(
) → Future< LocationAccess> -
override
-
clearStored(
) → Future< void> -
override
-
configure(
Map< String, Object?> settings) → Future<void> -
Pushes changed settings (store throttling, global filters).
override
-
currentPosition(
{required LocationAccuracy accuracy, required Duration timeout, Duration? maxAge}) → Future< PlatformFix> -
One fix. Reuses a native fix younger than
maxAge. Answers withintimeoutwith a fix or atimeout/noFixfailure.override -
diagnostics(
) → Future< Map< String, Object?> > -
Raw facts for
diagnose().override -
dispose(
) → Future< void> -
Stops native work started by this isolate.
override
-
emit(
Position p) → void - A fix from the "hardware". Goes through the native filters, the distance filter and the store, then to the stream if one is running. Dropped while paused (background, services off, no permission).
-
failNext(
LocationFailureReason reason) → void -
The next
currentPositionfails withreason. -
forwardGeocode(
String query, String? localeTag) → Future< PositionsResult> -
hangNext(
) → void -
The next
currentPositionnever answers; the caller's own timeout must end it. -
isGeocoderAvailable(
) → Future< bool> - The simulated platform geocoder; see InMemoryGeocodingProvider.
-
isOnline(
) → Future< bool?> -
true/falsewhen the platform can tell (validated network),nullwhen it can't (Android withoutACCESS_NETWORK_STATE).override -
isServiceEnabled(
) → Future< bool> -
override
-
lastKnown(
) → Future< PlatformLastKnown> -
override
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
openAppSettings(
) → Future< bool> -
override
-
openLocationSettings(
) → Future< bool> -
override
-
positionStream(
StreamRequest request) → Stream< PositionEvent> -
Native fixes for
request. Listening starts the platform request; cancelling stops it.override -
requestPrecise(
{String? purposeKey}) → Future< LocationAccess> -
Asks for precise location: Android re-request, iOS temporary full
accuracy with
purposeKey. Returns the access afterwards.override -
resolvePlayServices(
) → Future< bool> -
Android: shows Google's "update Google Play services" dialog. Returns
whether Play services is usable afterwards.
falseelsewhere.override -
resolveServices(
LocationAccuracy accuracy) → Future< ServicesResolution> -
override
-
reverseGeocode(
double latitude, double longitude, String? localeTag) → Future< AddressResult> -
setAccess(
LocationAccess value) → void -
setBackground(
bool value) → void - The app went to the background (streams pause, pending store flushes) or came back.
-
setServiceEnabled(
bool enabled) → void -
setStoredLastKnown(
Position? position, {Duration age = Duration.zero, Address? address, bool ageReliable = true}) → void -
simulateUserResponse(
FakeUserResponse response) → void - Queues how the user answers the next prompt of that kind.
-
statusStream(
) → Stream< LocationStatus> -
override
-
storeAddress(
Position position, Map< String, Object?> addressMap) → Future<void> -
Attaches
addressMapto the stored last known position if it is stillposition.override -
stubAddress(
double lat, double lng, Address address) → void -
stubPlaces(
String query, List< GeocodedPlace> places) → void -
toString(
) → String -
A string representation of this object.
inherited
-
updateStreamRequest(
StreamRequest request) → Future< void> -
Changes the running stream's request without re-subscribing.
override
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited