flutter - flutter 中对话框内的内容对齐?

标签 flutter dart flutter-layout

此处出现包含一些框的对话框。 1.我不知道这些盒子(我不知道它们叫什么)将如何像这样对齐。

如何给对话框赋予标题?

import 'package:flutter/material.dart';

Dialog leadDialog = Dialog(
  child: Container(
      color: Colors.white,
      child: Column(
        mainAxisAlignment: MainAxisAlignment.start,
        children: <Widget>[
          Padding(
            padding: EdgeInsets.all(15.0),
            child: Text(
              'BUY TICKETS',
              style: TextStyle(color: Colors.black, fontSize: 22.0),
            ),
          ),
          Divider(color: Colors.redAccent),
          Row(crossAxisAlignment: CrossAxisAlignment.start, children: <Widget>[
            Padding(
              padding: EdgeInsets.all(15.0),
            ),
            RaisedButton(
              padding: EdgeInsets.symmetric(horizontal: 30.0, vertical: 15.0),
              textColor: Colors.black,
              child: Text(
                '02:00PM',
                style: TextStyle(),
              ),
              shape: RoundedRectangleBorder(
                  borderRadius: BorderRadius.circular(10.0)),
            ),
            RaisedButton(
              padding: EdgeInsets.symmetric(horizontal: 30.0, vertical: 15.0),
              textColor: Colors.black,
              child: Text(
                '10:00PM',
                style: TextStyle(),
              ),
              shape: RoundedRectangleBorder(
                  borderRadius: BorderRadius.circular(10.0)),
            )
          ]),
          Divider(color: Colors.redAccent),
          Row(crossAxisAlignment: CrossAxisAlignment.start, children: <Widget>[
            Padding(
              padding: EdgeInsets.all(15.0),
            ),
            RaisedButton(
              padding: EdgeInsets.symmetric(horizontal: 30.0, vertical: 15.0),
              textColor: Colors.black,
              child: Text(
                '02:00PM',
                style: TextStyle(),
              ),
              shape: RoundedRectangleBorder(
                  borderRadius: BorderRadius.circular(10.0)),
            ),
            RaisedButton(
              color: Colors.grey,
              padding: EdgeInsets.symmetric(horizontal: 30.0, vertical: 15.0),
              textColor: Colors.black,
              child: Text(
                '10:00PM',
                style: TextStyle(),
              ),
              shape: RoundedRectangleBorder(
                  borderRadius: BorderRadius.circular(10.0)),
            )
          ]),
        ],
      )),
);

当前:

enter image description here

预期:

enter image description here

也帮我解决分隔线,当我这样做时,它并不像图像所示那么粗体。

最佳答案

enter image description here

Dialog leadDialog = Dialog(
  elevation: 12,
  shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(40)),
  child: Padding(
    padding: const EdgeInsets.all(12.0),
    child: Column(
      mainAxisAlignment: MainAxisAlignment.start,
      mainAxisSize: MainAxisSize.min,
      children: <Widget>[
        Padding(
          padding: EdgeInsets.all(15.0),
          child: Text(
            'BUY TICKETS',
            style: TextStyle(color: Colors.blue, fontSize: 26.0, fontWeight: FontWeight.bold),
          ),
        ),
        Container(color: Colors.redAccent, height: 2),
        SizedBox(height: 8),
        Text(
          "Select your time zone",
          style: TextStyle(fontWeight: FontWeight.bold),
        ),
        SizedBox(height: 8),
        Row(
          crossAxisAlignment: CrossAxisAlignment.start,
          children: <Widget>[
            RaisedButton(
              padding: EdgeInsets.symmetric(horizontal: 30.0, vertical: 12.0),
              textColor: Colors.black,
              child: Text('02:00PM', style: TextStyle(fontSize: 16)),
              shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(10.0)),
              onPressed: () {},
            ),
            Spacer(),
            RaisedButton(
              padding: EdgeInsets.symmetric(horizontal: 30.0, vertical: 12.0),
              textColor: Colors.white,
              color: Colors.yellow[800],
              child: Text('10:00PM', style: TextStyle(fontSize: 16)),
              shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(10.0)),
              onPressed: () {},
            )
          ],
        ),
        Container(
          color: Colors.redAccent,
          height: 2,
          margin: EdgeInsets.symmetric(vertical: 12),
        ),
        Text(
          "Select your Ticket",
          style: TextStyle(color: Colors.black),
        ),
        Table(
          columnWidths: {
            0: FlexColumnWidth(0.4),
            1: FlexColumnWidth(0.2),
            2: FlexColumnWidth(0.4),
          },
          children: [
            TableRow(
              children: [
                RaisedButton(
                  onPressed: () {},
                  child: Text("#15", style: TextStyle(fontSize: 16)),
                ),
                SizedBox(),
                RaisedButton(
                  onPressed: () {},
                  child: Text("#20", style: TextStyle(fontSize: 16)),
                ),
              ],
            ),
            TableRow(
              children: [
                RaisedButton(
                  onPressed: () {},
                  child: Text("#25", style: TextStyle(fontSize: 16)),
                ),
                SizedBox(),
                RaisedButton(
                  onPressed: () {},
                  child: Text("#50", style: TextStyle(fontSize: 16)),
                ),
              ],
            ),
          ],
        ),
        Container(
          color: Colors.redAccent,
          height: 2,
          margin: EdgeInsets.symmetric(vertical: 12),
        ),
        Row(
          crossAxisAlignment: CrossAxisAlignment.start,
          children: <Widget>[
            RaisedButton(
              padding: EdgeInsets.symmetric(horizontal: 40.0, vertical: 12.0),
              textColor: Colors.white,
              color: Colors.red,
              child: Text('Cancel', style: TextStyle(fontSize: 16)),
              shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(30.0)),
              onPressed: () {},
            ),
            Spacer(),
            RaisedButton(
              padding: EdgeInsets.symmetric(horizontal: 40.0, vertical: 12.0),
              textColor: Colors.white,
              color: Colors.yellow[800],
              child: Text('Confirm', style: TextStyle(fontSize: 16)),
              shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(30.0)),
              onPressed: () {},
            )
          ],
        ),
        SizedBox(height: 8),
        Text(
          "*You can buy max 2 tickets",
          style: TextStyle(color: Colors.grey),
        ),
      ],
    ),
  ),
);

关于flutter - flutter 中对话框内的内容对齐?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56815588/

相关文章:

flutter - 如何在Flutter中进行此UI设计

flutter 桌面 : Disable scrolling when hover a Container

flutter - 如何在 flutter 中单击 float 操作按钮时动态添加卡片小部件?

flutter - 如何在 ListView 中添加滚动指示器

Flutter Gridview 在列中。有什么解决办法..?

flutter - 如有必要,允许行子级扩展,否则占用最小尺寸

Flutter 全屏应用程序。摆脱Android应用程序底部的空白区域

cordova - RikuloGap地理位置

dart - 如何在 Flutter App 中管理选项卡之间的状态

flutter - 如何从名为 Next 的 `bottomNavigationBar` 按钮滑动到下一个选项卡?