I updated Flutter
and Chrome
version but non of them worked for me! I still get the following error when I try to run a Flutter Web application on Chrome:
Launching lib/main.dart on Chrome in debug mode...
main.dart:1
This app is linked to the debug service: ws://127.0.0.1:43331/dCeVDxbe-OU=/ws
Debug service listening on ws://127.0.0.1:43331/dCeVDxbe-OU=/ws
Running with sound null safety
Connecting to VM Service at ws://127.0.0.1:43331/dCeVDxbe-OU=/ws
ChromeProxyService: Failed to evaluate expression '_secondaryCompleter?.completeError': InternalError: Expression evaluation in async frames is not supported. No frame with index 14..
This is the result for flutter doctor
:
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 3.7.10, on Ubuntu 22.04.2 LTS 5.19.0-35-generic,
locale en_US.UTF-8)
[✓] Android toolchain - develop for Android devices (Android SDK version 33.0.2)
[✓] Chrome - develop for the web
[✓] Linux toolchain - develop for Linux desktop
[!] Android Studio (not installed)
[✓] VS Code (version 1.77.0)
[✓] Connected device (3 available)
[✓] HTTP Host Availability
! Doctor found issues in 1 category.
The following is the page I do get the error when I click on Login
button:
import 'package:admin/modules/auth/providers/auth_provider.dart';
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
class AuthPage extends StatefulWidget {
const AuthPage({super.key});
static const routeName = '/auth';
@override
State<AuthPage> createState() => _AuthPageState();
}
class _AuthPageState extends State<AuthPage> {
final GlobalKey<FormState> _formKey = GlobalKey();
final Map<String, String> _authData = {
'email': '',
'password': '',
};
var _isLoading = false;
Future<void> _submit() async {
if (!_formKey.currentState!.validate()) {
return;
}
_formKey.currentState!.save();
setState(() {
_isLoading = true;
});
try {
await Provider.of<AuthProvider>(context, listen: false).signin(
_authData['email'] as String,
_authData['password'] as String,
);
} catch (error) {
print(error);
const errorMessage =
'Could not authenticate you. Please try again later.';
_showErrorDialog(error.toString());
}
setState(() {
_isLoading = false;
});
}
void _showErrorDialog(String message) {
showDialog(
context: context,
builder: (ctx) => AlertDialog(
title: const Text('An Error Occurred!'),
content: Text(message),
actions: <Widget>[
TextButton(
child: const Text('Okay'),
onPressed: () {
Navigator.of(ctx).pop();
},
)
],
),
);
}
@override
Widget build(BuildContext context) {
return Card(
elevation: 5,
child: Padding(
padding: const EdgeInsets.all(15),
child: Form(
child: Column(
children: [
TextFormField(
decoration: const InputDecoration(
labelText: 'E-Mail',
constraints: BoxConstraints(maxWidth: 500)),
keyboardType: TextInputType.emailAddress,
validator: (value) {
if (value!.isEmpty || !value.contains('@')) {
return 'Invalid email!';
}
},
onSaved: (value) {
_authData['email'] = value!;
},
),
TextFormField(
decoration: const InputDecoration(
labelText: 'Password',
constraints: BoxConstraints(maxWidth: 500)),
obscureText: true,
validator: (value) {
if (value!.isEmpty || value.length < 5) {
return 'Password is too short!';
}
},
onSaved: (value) {
_authData['password'] = value!;
},
),
if (_isLoading)
const CircularProgressIndicator()
else
ElevatedButton(onPressed: _submit, child: Text('Login')),
],
)),
),
);
}
}