I have a Flutter issue I can't resolve. I tried all common things like flutter clean
, restarting pc, wiping emulator data and few more things still getting stuck on white screen basically.
Launching lib\main.dart on Android SDK built for x86 in debug mode...
✓ Built build\app\outputs\flutter-apk\app-debug.apk.
Installing build\app\outputs\flutter-apk\app.apk...
Connecting to VM Service at ws://127.0.0.1:55863/xq7cW6jF1O8=/ws // this statement stays as its is
void main() => MaterialApp(
color: Colors.black,
home: Scaffold(
backgroundColor: Colors.black,
),
);
Basically connection to VM is not happening.
My dartDeveloperTool says unable to connect to vm service, but it opens in chrome and doesn't show any widget just clean dartDebugger tool.
Call to OpenGL ES API with no current context (logged once per thread).
On the right in the properties, there is the background attribute. Clicking on this and choosing custom will allow you to define the RGB value you'd like the colour of the white screen to now appear as. Running your app on Android and iOS will now no longer show the annoying white screen.
To compile in release mode, we just need to add the --release flag to the flutter run command and have a physical device connected. Although we can do so, we typically do not use the flutter run command with the --release flag.
Of course, it won't work.
Because you need to wrap it in runApp
method. Like this:
void main() {
runApp(
MaterialApp(
color: Colors.black,
home: Scaffold(
backgroundColor: Colors.black,
),
),
);
}
But it's kinda bad practice to put your MaterialApp
inside your main()
function. Try to move it into a StatelessWidget
or StatefulWidget
.
Here's the example:
import 'package:flutter/material.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
body: null, // Change null with your own widgets
),
);
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With