首页 > 解决方案 > 我怎么能在这个屏幕的底部有文本?

问题描述

我目前有一个页面/屏幕在按下 FAB 后打开。在此页面/屏幕上,我想在最底部放置文本(尝试在此处显示日期),但我不确定如何使用我布置小部件的方式来做到这一点。

在页面上,我构建了 Widget,如下所示:

  Widget build(BuildContext context) {
    return WillPopScope(
      child: Scaffold(
        appBar: AppBar(title: const Text('Add Object')), body: body(context),
      ),
      onWillPop: () async {
        return true;
      }
    );
  }

其中引用了我的 Widget 正文:

  Widget body(BuildContext ctx) {
    return Container(
      padding: EdgeInsets.all(10.0),
      child: Column(
        mainAxisAlignment: MainAxisAlignment.start,
        children: <Widget>[
          Flexible(
            child: Container(
              padding: EdgeInsets.all(5),
              child: EditableText(
              controller: titleController,
              focusNode: titleFocus,
              cursorColor: Colors.blue,
              backgroundCursorColor: Colors.blue,
              style: TextStyle(
                color: Colors.white,
                fontSize: 22,
                fontWeight: FontWeight.bold,
                )
              )
            ),
          ),
          Divider(),
          Flexible(
            child: Container(
              padding: EdgeInsets.all(5),
              child: EditableText(
                controller: contentController,
                maxLines: 600,
                focusNode: contentFocus,
                cursorColor: Colors.blue,
                backgroundCursorColor: Colors.red,
                style: TextStyle(
                  color: Colors.white,
                  fontSize: 20
                )
              )
            )
          ),
        ],
      )
    );
  }

使用这种布局,我将如何将文本放在最底部?我在想一个底部导航栏,但如果我只是想在底部放一些文本,我认为这不是正确的用法。

标签: flutterdart

解决方案


您可以在 Expanded 中使用 Align 小部件

Expanded(
        child: Align(
          alignment: Alignment.bottomCenter,
          child: Text('Something'),
        ),
      )

推荐阅读