如何在Flutter 中垂直居中?我使用了"新中心"小部件.我使用了小部件"新中心",但它没有垂直居中我的列?任何 idea 都会有帮助....

@override
Widget build(BuildContext context) {
  return Scaffold(
    appBar: AppBar(
      title: Text("Thank you"),
    ),
    body: new Center(
      child: new Column(
        children: <Widget>[
          new Padding(
            padding: new EdgeInsets.all(25.0),
            child: new AnimatedBuilder(
              animation: animationController,
              child: new Container(
                height: 175.0,
                width: 175.0,
                child: new Image.asset('assets/angry_face.png'),
              ),
              builder: (BuildContext context, Widget _widget) {
                return new Transform.rotate(
                  angle: animationController.value * 6.3,
                  child: _widget,
                );
              },
            ),
          ),
          new Text('We are glad we could serve you...', style: new TextStyle(
              fontSize: 16.0,
              fontWeight: FontWeight.w600,
              color: Colors.black87),),
          new Padding(padding: new EdgeInsets.symmetric(vertical: 5.0, horizontal: 0.0)),
          new Text('We appreciate your feedback ! !', style: new TextStyle(
              fontSize: 13.0,
              fontWeight: FontWeight.w200,
              color: Colors.black87),),
        ],
      ),
    ),
  );
}

推荐答案

阿齐兹提出的解决方案是:

Column(
  mainAxisAlignment: MainAxisAlignment.center,
  crossAxisAlignment: CrossAxisAlignment.center,
  children: [
    //your widgets here...
  ],
)

由于填充的原因,它不会位于精确的中心:

padding: EdgeInsets.all(25.0),

要使列正好居中-至少在这种情况下-您需要删除填充.

Flutter相关问答推荐

我遇到了一个问题,从showDialogue()调用Navigator.pop()两次导致屏幕空白

如何在SingleChildScrollView中使用GridView

Flutter:sqflite DB

Flutter—如何在Riverpod中使用全类状态?

如何在默认情况下隐藏appBar并在向下滚动时显示它- Flutter

你能go 掉Flutter 小部件测试中的样板吗?

Flutter Riverpod,将默认的BTC值改写为我的新状态

将记录/元组用作SplayTreeMap中的键

Flutter飞溅屏幕即使在修改后仍显示默认徽标和背景色

从Firestore流式传输单个文档还是整个集合更好?

flatter_localizations错误在Null值上使用了Null判断运算符

如何使 dart 函数变得通用?

Supabase Auth:重定向到 Google.com 而不是我的应用程序

Flutter 火焰相机抖动已弃用

在允许屏幕 Select 和点击的同时保持通用对话框显示

使用Flutter项目设置Firebase遇到困难?这些解决方案或许能帮到你!

在提供程序包更改通知程序中构建倒计时时钟

如何建立最近的文件列表?

如何在 flutter 中创建渐变按钮

我们什么时候在flutter中初始化一个provider?