android studio 不显示颤振项目的异常消息

时间:2021-03-10 11:36:24

标签: flutter android-studio

此代码未在“运行”窗口中显示异常消息:

import 'package:flutter/material.dart';

void main() {
  runApp(MaterialApp(
    home: MyHomePage(),
  ));
}

class MyHomePage extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: <Widget>[
            Text('Test:'),
            Text(null),
          ],
        ),
      ),
    );
  }
}

但是如果我将 MyHomePage() 替换为 Scaffold,android studio 确实会显示异常消息:

import 'package:flutter/material.dart';

void main() {
  runApp(MaterialApp(
    home: Scaffold(
      body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: <Widget>[
            Text('Test:'),
            Text(null),
          ],
        ),
      ),
    ),
  ));
}

它们看起来几乎相同,谁能告诉我第一个代码有什么问题?

我使用的是 Android studio 4.1.2,这是我的 flutter doctor 输出

Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 2.0.1, on Linux, locale en_US.UTF-8)                                                                                                                                                            [✓] Android toolchain - develop for Android devices (Android SDK version 29.0.3)
[✓] Chrome - develop for the web
[✓] Android Studio
[✓] IntelliJ IDEA Community Edition (version 2019.3)
[✓] VS Code (version 1.52.1)
[✓] Connected device (2 available)

0 个答案:

没有答案