Flutter在Android Studio中运行代码时不显示任何内容。

huangapple go评论84阅读模式
英文:

Flutter not diplaying anything when i run the code in android studio

问题

代码中的问题可能是文本颜色设置错误。您可以尝试以下修改:

将这行代码中的颜色从白色更改为蓝色:

color: Colors.blue,

这样应该能够在屏幕上显示"Hello World"的蓝色文本。

英文:

it is supposed to be showing "hello world" in blue color but when i run the code it does not show anything . only thing that is displayed is the project title and nothing else
can someone tell what's the problementer image description here

`import 'package:flutter/material.dart';
import 'package:firebase_core/firebase_core.dart';
Future main() async {
  WidgetsFlutterBinding.ensureInitialized();
  await Firebase.initializeApp();
  runApp(const MyApp());
}

 class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
    return const MaterialApp(
      home: Scaffold(
        backgroundColor: Colors.white,
        body: Center(
          child: Text('Hello World!',
          style: TextStyle(
            color: Colors.blue, // set the text color to blue
          ),
          ),
        ),
      ),
    );
  }}`

it is supposed to be showing "hello world" in blue color but when i run the code it does not show anything . only thing that is displayed is the project title and nothing else

答案1

得分: 1

你正在使用Firebase在Flutter web上。在运行你的应用程序之前,你需要对web/index.html文件进行一些更改。你必须导入Firebase Javascript SDK并初始化Firebase。

有关更详细的说明,请查看官方Firebase文档。

https://firebase.flutter.dev/docs/manual-installation/web/

或者因为这个可能已经过时,你可以查看更新的设置说明:

https://firebase.google.com/docs/flutter/setup?platform=web

英文:

You are using Firebase on Flutter web. You need to make some changes to the web/index.html file before running your app. You must import the Firebase Javascript SDK and initialize Firebase.

For a more detailed explanation, please check out the official Firebase documentation.

https://firebase.flutter.dev/docs/manual-installation/web/

Or because this one could be outdated take a look at the updated setup instructions:

https://firebase.google.com/docs/flutter/setup?platform=web

huangapple
  • 本文由 发表于 2023年4月19日 18:35:07
  • 转载请务必保留本文链接:https://go.coder-hub.com/76053504.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定