Flutter应用程序在设备上的白色屏幕上运行



我在flutter上开发了一个应用程序,尽管它在两天前就工作了,但当我在设备上运行该应用程序时,它并没有启动。它仍然显示在白色屏幕上,并且不会启动应用程序。我想当我同步gradle时发生了一些事情。

我的主要作品:

import 'package:my_firstapp/locator.dart';
import 'package:my_firstapp/models/user_model.dart';
import 'package:my_firstapp/screens/wrapper.dart';
import 'package:provider/provider.dart';
import 'package:my_firstapp/services/auth.dart';
import 'package:firebase_core/firebase_core.dart';
void main() async {
WidgetsFlutterBinding.ensureInitialized();
await Firebase.initializeApp();
setupServices();
runApp(MyApp());
}
class MyApp extends StatelessWidget {
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
return StreamProvider<UserModel>.value(
value: AuthService().user,
child: MaterialApp(
theme: ThemeData(
primaryColor: Color(0xff5FA55A),
accentColor: Color(0xff5FA55A),
),
home: Wrapper(),
),
);
}
}

我的manifest.xml:

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.example.my_firstapp">
<uses-permission android:name="android.permission.CAMERA"/>
<application
android:allowBackup="true"
android:label="food_track"
android:icon="@drawable/launch_background">
<activity
android:name="com.example.my_firstapp.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"
android:exported="true">
<!-- Specifies an Android theme to apply to this Activity as soon as
the Android process has started. This theme is visible to the user
while the Flutter UI initializes. After that, this theme continues
to determine the Window background behind the Flutter UI. -->
<meta-data
android:name="io.flutter.embedding.android.NormalTheme"
android:resource="@style/NormalTheme"
/>
<!-- Displays an Android View that continues showing the launch screen
Drawable until Flutter paints its first frame, then this splash
screen fades out. A splash screen is useful to avoid any visual
gap between the end of Android's launch screen and the painting of
Flutter's first frame. -->
<meta-data
android:name="io.flutter.embedding.android.SplashScreenDrawable"
android:resource="@drawable/launch_background"
/>
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
<activity android:name="com.aptreesoftware.barcodescan.BarcodeScannerActivity"/>
<!-- Don't delete the meta-data below.
This is used by the Flutter tool to generate GeneratedPluginRegistrant.java -->
<meta-data
android:name="flutterEmbedding"
android:value="2" />
</application>
</manifest>

我检查了一下,一切都升级了。你有什么想法吗?

打开终端,cd到你的flutter项目的android文件夹并运行:

$./gradlew build

相关内容

  • 没有找到相关文章

最新更新