You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Geolocator.getCurrentPosition() works on debug run, but throws exception on profile/release build of Flutter Web on Flutter 2.2.3
Same code works both in debug/profile/release on Flutter 2.0.6 with --no-sound-null-safety
Uncaught TypeError: t2.get$coords is not a function
at main.dart.js:90729
at _wrapJsFunctionForAsync_closure.$protected (main.dart.js:10403)
at _wrapJsFunctionForAsync_closure.call$2 (main.dart.js:48313)
at _awaitOnObject_closure.call$1 (main.dart.js:48299)
at _RootZone.runUnary$2$2 (main.dart.js:49585)
at _RootZone.runUnary$2 (main.dart.js:49589)
at _Future__propagateToListeners_handleValueCallback.call$0 (main.dart.js:48891)
at Object._Future__propagateToListeners (main.dart.js:10645)
at _Future._completeWithValue$1 (main.dart.js:48746)
at _Future__asyncCompleteWithValue_closure.call$0 (main.dart.js:48828)
Expected behavior
...
Reproduction steps
example
import'package:flutter/material.dart';
import'package:geolocator/geolocator.dart';
voidmain() {
runApp(MyApp());
}
classMyAppextendsStatelessWidget {
// This widget is the root of your application.@overrideWidgetbuild(BuildContext context) {
returnMaterialApp(
title:'Flutter Demo',
theme:ThemeData(
// This is the theme of your application.//// Try running your application with "flutter run". You'll see the// application has a blue toolbar. Then, without quitting the app, try// changing the primarySwatch below to Colors.green and then invoke// "hot reload" (press "r" in the console where you ran "flutter run",// or simply save your changes to "hot reload" in a Flutter IDE).// Notice that the counter didn't reset back to zero; the application// is not restarted.
primarySwatch:Colors.blue,
),
home:MyHomePage(title:'Flutter Demo Home Page'),
);
}
}
classMyHomePageextendsStatefulWidget {
MyHomePage({Key? key, requiredthis.title}) :super(key: key);
// This widget is the home page of your application. It is stateful, meaning// that it has a State object (defined below) that contains fields that affect// how it looks.// This class is the configuration for the state. It holds the values (in this// case the title) provided by the parent (in this case the App widget) and// used by the build method of the State. Fields in a Widget subclass are// always marked "final".finalString title;
@override_MyHomePageStatecreateState() =>_MyHomePageState();
}
class_MyHomePageStateextendsState<MyHomePage> {
int _counter =0;
void_incrementCounter() {
setState(() {
// This call to setState tells the Flutter framework that something has// changed in this State, which causes it to rerun the build method below// so that the display can reflect the updated values. If we changed// _counter without calling setState(), then the build method would not be// called again, and so nothing would appear to happen.
_counter++;
});
}
@overrideWidgetbuild(BuildContext context) {
// This method is rerun every time setState is called, for instance as done// by the _incrementCounter method above.//// The Flutter framework has been optimized to make rerunning build methods// fast, so that you can just rebuild anything that needs updating rather// than having to individually change instances of widgets.returnScaffold(
appBar:AppBar(
// Here we take the value from the MyHomePage object that was created by// the App.build method, and use it to set our appbar title.
title:Text(widget.title),
),
body:Center(
// Center is a layout widget. It takes a single child and positions it// in the middle of the parent.
child:Column(
// Column is also a layout widget. It takes a list of children and// arranges them vertically. By default, it sizes itself to fit its// children horizontally, and tries to be as tall as its parent.//// Invoke "debug painting" (press "p" in the console, choose the// "Toggle Debug Paint" action from the Flutter Inspector in Android// Studio, or the "Toggle Debug Paint" command in Visual Studio Code)// to see the wireframe for each widget.//// Column has various properties to control how it sizes itself and// how it positions its children. Here we use mainAxisAlignment to// center the children vertically; the main axis here is the vertical// axis because Columns are vertical (the cross axis would be// horizontal).
mainAxisAlignment:MainAxisAlignment.center,
children:<Widget>[
ElevatedButton(
child:Text('_determinePosition'),
onPressed: () async {
var position =await_determinePosition();
print('position $position');
},
)
],
),
),
floatingActionButton:FloatingActionButton(
onPressed: _incrementCounter,
tooltip:'Increment',
child:Icon(Icons.add),
), // This trailing comma makes auto-formatting nicer for build methods.
);
}
}
/// Determine the current position of the device.////// When the location services are not enabled or permissions/// are denied the `Future` will return an error.Future<Position> _determinePosition() async {
bool serviceEnabled;
LocationPermission permission;
// Test if location services are enabled.
serviceEnabled =awaitGeolocator.isLocationServiceEnabled();
if (!serviceEnabled) {
// Location services are not enabled don't continue// accessing the position and request users of the// App to enable the location services.returnFuture.error('Location services are disabled.');
}
permission =awaitGeolocator.checkPermission();
if (permission ==LocationPermission.denied) {
permission =awaitGeolocator.requestPermission();
if (permission ==LocationPermission.denied) {
// Permissions are denied, next time you could try// requesting permissions again (this is also where// Android's shouldShowRequestPermissionRationale// returned true. According to Android guidelines// your App should show an explanatory UI now.returnFuture.error('Location permissions are denied');
}
}
if (permission ==LocationPermission.deniedForever) {
// Permissions are denied forever, handle appropriately.returnFuture.error(
'Location permissions are permanently denied, we cannot request permissions.');
}
// When we reach here, permissions are granted and we can// continue accessing the position of the device.returnawaitGeolocator.getCurrentPosition();
}
Configuration
Version: 7.4.0
Platform:
📱 iOS
🤖 Android
🌐 Web
Flutter
flutter doctor -v
C:\Users\sunbr\Sunbreak\web_geolocation.2.2>%flutter-2.2.x% doctor -v
[✓] Flutter (Channel stable, 2.2.3, on Microsoft Windows [Version 10.0.19043.1110], locale en-US)
• Flutter version 2.2.3 at C:\Users\sunbr\flutter\flutter-2.2.x
• Framework revision f4abaa0735 (6 weeks ago), 2021-07-01 12:46:11 -0700
• Engine revision 241c87ad80
• Dart version 2.13.4
• Pub download mirror https://pub.flutter-io.cn
• Flutter download mirror https://storage.flutter-io.cn
[✗] Android toolchain - develop for Android devices
✗ Unable to locate Android SDK.
Install Android Studio from: https://developer.android.com/studio/index.html
On first launch it will assist you in installing the Android SDK components.
(or visit https://flutter.dev/docs/get-started/install/windows#android-setup for detailed instructions).
If the Android SDK has been installed to a custom location, please use
`flutter config --android-sdk` to update to that location.
[✓] Chrome - develop for the web
• Chrome at C:\Program Files (x86)\Google\Chrome\Application\chrome.exe
[!] Android Studio (not installed)
• Android Studio not found; download from https://developer.android.com/studio/index.html
(or visit https://flutter.dev/docs/get-started/install/windows#android-setup for detailed instructions).
[✓] VS Code (version 1.57.1)
• VS Code at C:\Users\sunbr\AppData\Local\Programs\Microsoft VS Code
• Flutter extension version 3.23.0
[✓] Connected device (2 available)
• Chrome (web) • chrome • web-javascript • Google Chrome 92.0.4515.131
• Edge (web) • edge • web-javascript • Microsoft Edge 92.0.902.67
! Doctor found issues in 2 categories.
The text was updated successfully, but these errors were encountered:
🐛 Bug Report
Geolocator.getCurrentPosition()
works on debug run, but throws exception on profile/release build of Flutter Web onFlutter 2.2.3
Same code works both in debug/profile/release on
Flutter 2.0.6
with--no-sound-null-safety
Expected behavior
...
Reproduction steps
example
Configuration
Version: 7.4.0
Platform:
Flutter
flutter doctor -v
The text was updated successfully, but these errors were encountered: