Hello I'm making a site with Flutter Web. But I have a problem. I use the javascript value in index.html at dart file. It gives me a problem. When I run the project in release mode, I can see the grey screen. I think that the reason is the exactly of calling the javascript value. This is my index.html's script code.
window.onload = function() {
var isAndroid = /(android)/i.test(navigator.userAgent);
var isIOS = !!navigator.platform.match(/iPhone|iPod|iPad/);
var browse = navigator.userAgent.toLowerCase();
var kakaotalk = false;
if(browse.indexOf("kakaotalk") != -1) {
kakaotalk = true;
}
window.state = {
id: id,
isAndroid: isAndroid,
isIOS: isIOS,
browse: browse,
kakaotalk: kakaotalk,
};
}
And this is my flutter code. I call the js value in statefulwidget's initstate.
var state = js.JsObject.fromBrowserObject(js.context['state']);
var isAndroid;
var isIOS;
var browse;
var kakaotalk;
@override
void initState() {
super.initState();
isAndroid = state["isAndroid"];
isIOS = state["isIOS"];
browse = state["browse"];
kakaotalk = state["kakaotalk"];
}
How can I fix the grey screen error? I want to know the answer. I can't solved this error for a month.
result of 'flutter doctor -v'
[✓] Flutter (Channel stable, 2.2.0, on macOS 11.3 20E232 darwin-x64, locale ko-KR)
• Flutter version 2.2.0 at /Users/shinyoung/development/flutter
• Framework revision b22742018b (9일 전), 2021-05-14 19:12:57 -0700
• Engine revision a9d88a4d18
• Dart version 2.13.0
[✗] 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/macos#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.
[✓] Xcode - develop for iOS and macOS
• Xcode at /Applications/Xcode.app/Contents/Developer
• Xcode 12.5, Build version 12E262
• CocoaPods version 1.10.1
[✓] Chrome - develop for the web
• Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
[!] 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/macos#android-setup for detailed instructions).
[✓] VS Code (version 1.56.2)
• VS Code at /Applications/Visual Studio Code.app/Contents
• Flutter extension version 3.22.0
[✓] Connected device (1 available)
• Chrome (web) • chrome • web-javascript • Google Chrome 90.0.4430.212
! Doctor found issues in 2 categories.
Flutter version is 2.2.0 and dart version is 2.13.0!
The Yellow icon is just a loading image that I added in index.html file. grey screen
Aucun commentaire:
Enregistrer un commentaire