Testing
If you want to set a custom Location for testing you can use the Location.instance
property.
Here is an example with Mocktail
import 'package:flutter_test/flutter_test.dart';
import 'package:location/location.dart';
import 'package:mocktail/mocktail.dart';
class MockLocation extends Mock implements Location {}
void main() {
testWidgets('get location ...', (tester) async {
final mock = MockLocation();
when(mock.getLocation).thenAnswer(
(invocation) async => LocationData.fromMap({'latitude': 42, 'longitude': 2}),
);
Location.instance = mock;
});
}