android-emulator - 如何在没有 Flutter 脚手架的情况下在屏幕上获取简单文本?

标签 android-emulator dart flutter scaffolding

我已经从 Scafflod 和按钮中清除了 Flutter 示例,并期待我得到相同的内容,但没有标题栏和按钮:

void main() => runApp(new MyApp());

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return new MaterialApp(
      title: 'My app title',
      theme: new ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: new MyHomePage(),
    );
  }
}

class MyHomePage extends StatefulWidget {
  MyHomePage({Key key}) : super(key: key);


  @override
  _MyHomePageState createState() => new _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  int _counter = 0;

  @override
  Widget build(BuildContext context) {
    return new Center(
        child: new Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: <Widget>[
            new Text(
              'You have pushed the button this many times:',
            ),
            new Text(
              '$_counter',
              style: Theme.of(context).textTheme.display1,
            ),
          ],
        ),
      );

  }
}

不幸的是,我得到的东西不适合任何大门:

enter image description here

这是什么?怎么变这么大?如何修复?

最佳答案

您可以将文本包装在“ Material ”小部件中。此外,使用“style:”参数解决了这个问题。

Material(
        color: Colors.transparent,
        child: Text(
            "Your Text Here",
            style: TextStyle(
              fontFamily: 'custom font', // remove this if don't have custom font
              fontSize: 20.0, // text size
              color: Colors.white, // text color
            ),
        ),
      )

关于android-emulator - 如何在没有 Flutter 脚手架的情况下在屏幕上获取简单文本?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51618701/

相关文章:

android - 模拟器未显示在 adb 设备中

Android - 用 emma 生成覆盖(没有 Ant )

android - flutter 构建apk文件不能在http请求上工作?

dart - 如何正确地将数据提供给 StreamBuilder initialData 参数?

flutter 'owner!._debugCurrentBuildTarget == this' : is not true. #87

android-studio - 在 IntelHaxm.sys 蓝屏后,Android Studio 的 AVD 在启动时崩溃

Android Studio 未将应用程序安装到设备中

dom - 如何管理DOM元素依赖性

constructor - 关于 Dart 中的工厂构造函数

flutter - 如何在 Flutter 中圆滑 slider 的角