As the title says, when I try to run my flutter web app from android studio on chrome, I only see a white screen. It’s been over half a year since I last worked on this project, I have already updated everything (flutter, dart, dependencies…).
I get this in the console output when running the app:
Launching lib/main.dart on Chrome in debug mode...
Waiting for connection from debug service on Chrome...
This app is linked to the debug service: ws://127.0.0.1:57531/eaZ7RkjmvoI=/ws
Debug service listening on ws://127.0.0.1:57531/eaZ7RkjmvoI=/ws
Debug service listening on ws://127.0.0.1:57531/eaZ7RkjmvoI=/ws
Rejecting promise with error: TypeError: Cannot set properties of undefined (setting 'nativeCommunication')
A message on the flutter/lifecycle channel was discarded before it could be handled.
This happens when a plugin sends messages to the framework side before the framework has had an opportunity to register a listener. See the ChannelBuffers API documentation for details on how to configure the channel to expect more messages, or to expect messages to get discarded:
https://api.flutter.dev/flutter/dart-ui/ChannelBuffers-class.html
A message on the flutter/lifecycle channel was discarded before it could be handled.
This happens when a plugin sends messages to the framework side before the framework has had an opportunity to register a listener. See the ChannelBuffers API documentation for details on how to configure the channel to expect more messages, or to expect messages to get discarded:
https://api.flutter.dev/flutter/dart-ui/ChannelBuffers-class.html
A message on the flutter/lifecycle channel was discarded before it could be handled.
This happens when a plugin sends messages to the framework side before the framework has had an opportunity to register a listener. See the ChannelBuffers API documentation for details on how to configure the channel to expect more messages, or to expect messages to get discarded:
https://api.flutter.dev/flutter/dart-ui/ChannelBuffers-class.html
Application finished.
I even added some print lines at the very top of my main() which I didn’t see in the output (see output above):
void main() async {
debugPrint('debugPrint');
log('log');
// print('print'); // "Don't invoke 'print' in production code."
...
This is what I see in Chrome DevTools:
One potential solution that solved the problem for other people was to change a certain value in web/index.html
.
I’m NOT planning to serve my web app in a path other than root (see here for more details), so I left this line in web/index.html
the way it was:
<base href="$FLUTTER_BASE_HREF">
This also didn’t help:
flutter clean
flutter pub get
Building and running a release build also didn’t work.
This is my pubspec.yaml
:
name: langit_admin
description: A new Flutter project.
# The following line prevents the package from being accidentally published to
# pub.dev using `pub publish`. This is preferred for private packages.
publish_to: 'none' # Remove this line if you wish to publish to pub.dev
# The following defines the version and build number for your application.
# A version number is three numbers separated by dots, like 1.2.43
# followed by an optional build number separated by a +.
# Both the version and the builder number may be overridden in flutter
# build by specifying --build-name and --build-number, respectively.
# In Android, build-name is used as versionName while build-number used as versionCode.
# Read more about Android versioning at https://developer.android.com/studio/publish/versioning
# In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion.
# Read more about iOS versioning at
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
version: 1.0.0+1
environment:
sdk: '>=2.12.0 <3.0.0'
dependencies:
flutter:
sdk: flutter
flutter_localizations:
sdk: flutter
# The following adds the Cupertino Icons font to your application.
# Use with the CupertinoIcons class for iOS style icons.
cupertino_icons: ^1.0.2
#by flutter/google
firebase_core: ^3.2.0
firebase_auth: ^5.1.2
cloud_firestore: ^5.1.0
cloud_functions: ^5.0.3
firebase_app_check: ^0.3.0+3
shared_preferences: ^2.2.0
provider: ^6.0.5
#other
flutter_spinkit: ^5.1.0
flutter_tts: ^4.0.2
html_editor_enhanced: ^2.6.0
#...
dev_dependencies:
flutter_test:
sdk: flutter
flutter_lints: ^4.0.0
# For information on the generic Dart part of this file, see the
# following page: https://dart.dev/tools/pub/pubspec
# The following section is specific to Flutter.
flutter:
# The following line ensures that the Material Icons font is
# included with your application, so that you can use the icons in
# the material Icons class.
uses-material-design: true
# To add assets to your application, add an assets section, like this:
assets:
#- assets/country_flags/
- assets/langit_learning_guide.png
- assets/langit_admin_learning_guide.png
- lang/
# An image asset can refer to one or more resolution-specific "variants", see
# https://flutter.dev/assets-and-images/#resolution-aware.
# For details regarding adding assets from package dependencies, see
# https://flutter.dev/assets-and-images/#from-packages
# To add custom fonts to your application, add a fonts section here,
# in this "flutter" section. Each entry in this list should have a
# "family" key with the font family name, and a "fonts" key with a
# list giving the asset and other descriptors for the font. For
# example:
# fonts:
# - family: Schyler
# fonts:
# - asset: fonts/Schyler-Regular.ttf
# - asset: fonts/Schyler-Italic.ttf
# style: italic
# - family: Trajan Pro
# fonts:
# - asset: fonts/TrajanPro.ttf
# - asset: fonts/TrajanPro_Bold.ttf
# weight: 700
#
# For details regarding fonts from package dependencies,
# see https://flutter.dev/custom-fonts/#from-packages
This is my output of flutter doctor -v
:
[✓] Flutter (Channel stable, 3.22.3, on macOS 14.5 23F79 darwin-x64, locale en-GB)
• Flutter version 3.22.3 on channel stable at /Users/cedricdiederich/flutter
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision b0850beeb2 (13 days ago), 2024-07-16 21:43:41 -0700
• Engine revision 235db911ba
• Dart version 3.4.4
• DevTools version 2.34.3
[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.3)
• Android SDK at /Users/cedricdiederich/Library/Android/sdk
• Platform android-34, build-tools 30.0.3
• ANDROID_HOME = /Users/cedricdiederich/Library/Android/sdk
• Java binary at: /Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build 17.0.11+0-17.0.11b1207.24-11852314)
• All Android licenses accepted.
[✓] Xcode - develop for iOS and macOS (Xcode 15.4)
• Xcode at /Applications/Xcode.app/Contents/Developer
• Build 15F31d
• CocoaPods version 1.15.2
[✓] Chrome - develop for the web
• Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
[✓] Android Studio (version 2024.1)
• Android Studio at /Applications/Android Studio.app/Contents
• Flutter plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/9212-flutter
• Dart plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/6351-dart
• Java version OpenJDK Runtime Environment (build 17.0.11+0-17.0.11b1207.24-11852314)
[✓] Android Studio (version 2021.3)
• Android Studio at /Users/cedricdiederich/Applications/Android Studio.app/Contents
• Flutter plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/9212-flutter
• Dart plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/6351-dart
• Java version OpenJDK Runtime Environment (build 11.0.13+0-b1751.21-8125866)
[✓] IntelliJ IDEA Ultimate Edition (version 2021.1)
• IntelliJ at /Applications/IntelliJ IDEA.app
• Flutter plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/9212-flutter
• Dart plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/6351-dart
[✓] VS Code (version 1.91.1)
• VS Code at /Applications/Visual Studio Code.app/Contents
• Flutter extension version 3.92.0
[✓] Connected device (2 available)
• macOS (desktop) • macos • darwin-x64 • macOS 14.5 23F79 darwin-x64
• Chrome (web) • chrome • web-javascript • Google Chrome 127.0.6533.73
[✓] Network resources
• All expected network resources are available.
• No issues found!