Flutter 首次运行应用程序时显示黑屏的颤振
无法解决我的问题 在将颤振通道切换到Flutter 首次运行应用程序时显示黑屏的颤振,flutter,Flutter,无法解决我的问题 在将颤振通道切换到master并升级颤振后,我的应用程序无法解决此问题。我怎样才能解决这个问题 flutter doctor -v [√] Flutter (Channel master, 1.22.0-10.0.pre.139, on Microsoft Windows [Version 10.0.19041.450], locale en-US) • Flutter version 1.22.0-10.0.pre.139 at F:\software\flutter
master
并升级颤振后,我的应用程序无法解决此问题。我怎样才能解决这个问题
flutter doctor -v
[√] Flutter (Channel master, 1.22.0-10.0.pre.139, on Microsoft Windows [Version 10.0.19041.450], locale en-US)
• Flutter version 1.22.0-10.0.pre.139 at F:\software\flutter
• Framework revision 3dfbdac6f4 (3 hours ago), 2020-09-11 11:40:03 -0400
• Engine revision 983b0ef164
• Dart version 2.10.0 (build 2.10.0-116.0.dev)
[!] Android toolchain - develop for Android devices (Android SDK version 30.0.0)
• Android SDK at F:\software\sdk
• Platform android-30, build-tools 30.0.0
• ANDROID_HOME = F:\software\sdk
• Java binary at: C:\Program Files\Android\Android Studio\jre\bin\java
• Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b01)
[√] Android Studio (version 4.0)
• Android Studio at C:\Program Files\Android\Android Studio
• Flutter plugin version 49.0.2
• Dart plugin version 193.7547
• Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b01)
[√] Connected device (1 available)
• WAS LX1A (mobile) • 2XJDU17C14006203 • android-arm64 • Android 8.0.0 (API 26)
新颤振应用的内容:
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
theme: ThemeData(
primarySwatch: Colors.blue,
visualDensity: VisualDensity.adaptivePlatformDensity,
),
home: MyHomePage(title: 'Flutter Demo Home Page'),
);
}
}
class MyHomePage extends StatefulWidget {
MyHomePage({Key key, this.title}) : super(key: key);
final String title;
@override
_MyHomePageState createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
int _counter = 0;
void _incrementCounter() {
setState(() {
_counter++;
});
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text(widget.title),
),
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Text(
'You have pushed the button this many times:',
),
Text(
'$_counter',
style: Theme.of(context).textTheme.headline4,
),
],
),
),
floatingActionButton: FloatingActionButton(
onPressed: _incrementCounter,
tooltip: 'Increment',
child: Icon(Icons.add),
),
);
}
}
launch\u background.xml
<?xml version="1.0" encoding="utf-8"?>
<!-- Modify this file to customize your launch splash screen -->
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@android:color/white" />
<!-- You can insert your own image assets here -->
<item>
<bitmap
android:gravity="center"
android:src="@mipmap/ic_launcher" />
</item>
</layer-list>
<application
android:name="io.flutter.app.FlutterApplication"
android:label="instaluxury"
android:icon="@mipmap/ic_launcher">
<activity
android:name=".MainActivity"
android:launchMode="singleTop"
android:theme="@style/LaunchTheme"
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
android:hardwareAccelerated="true"
android:windowSoftInputMode="adjustResize">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
<!-- Don't delete the meta-data below.
This is used by the Flutter tool to generate GeneratedPluginRegistrant.java -->
<meta-data
android:name="io.flutter.app.android.SplashScreenUntilFirstFrame"
android:value="true" />
</application>
除非我遗漏了什么:你的应用程序会显示一个黑屏,直到它被加载并准备好显示我的主页。如果没有包含启动屏幕,这是正常行为。您可以在官方文档中阅读关于添加闪屏的内容:在我的代码中更改android实现后,我仍然有这个问题。根据您在链接问题中的评论和您在此处的评论,我只能得出结论,您没有包括闪屏。如果有,请更新您的问题,说明您是如何尝试这样做的,这样我们就可以看到问题所在。如果你还没有,那么请按照我答案中的链接。
<application
android:name="io.flutter.app.FlutterApplication"
android:label="instaluxury"
android:icon="@mipmap/ic_launcher">
<activity
android:name=".MainActivity"
android:launchMode="singleTop"
android:theme="@style/LaunchTheme"
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
android:hardwareAccelerated="true"
android:windowSoftInputMode="adjustResize">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
<!-- Don't delete the meta-data below.
This is used by the Flutter tool to generate GeneratedPluginRegistrant.java -->
<meta-data
android:name="io.flutter.app.android.SplashScreenUntilFirstFrame"
android:value="true" />
</application>