草庐IT

flutter - Dialog 中内容的对齐方式?

coder 2023-07-22 原文

此处出现包含一些框的对话框。 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)),
            )
          ]),
        ],
      )),
);

当前:

预期:

也帮我解决分隔线问题,当我这样做时,它不像图片那样粗体。

最佳答案

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 - Dialog 中内容的对齐方式?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56815588/

有关flutter - Dialog 中内容的对齐方式?的更多相关文章

  1. ruby - 如何以所有可能的方式将字符串拆分为长度最多为 3 的连续子字符串? - 2

    我试图获取一个长度在1到10之间的字符串,并输出将字符串分解为大小为1、2或3的连续子字符串的所有可能方式。例如:输入:123456将整数分割成单个字符,然后继续查找组合。该代码将返回以下所有数组。[1,2,3,4,5,6][12,3,4,5,6][1,23,4,5,6][1,2,34,5,6][1,2,3,45,6][1,2,3,4,56][12,34,5,6][12,3,45,6][12,3,4,56][1,23,45,6][1,2,34,56][1,23,4,56][12,34,56][123,4,5,6][1,234,5,6][1,2,345,6][1,2,3,456][123

  2. ruby - 解析 RDFa、微数据等的最佳方式是什么,使用统一的模式/词汇(例如 schema.org)存储和显示信息 - 2

    我主要使用Ruby来执行此操作,但到目前为止我的攻击计划如下:使用gemsrdf、rdf-rdfa和rdf-microdata或mida来解析给定任何URI的数据。我认为最好映射到像schema.org这样的统一模式,例如使用这个yaml文件,它试图描述数据词汇表和opengraph到schema.org之间的转换:#SchemaXtoschema.orgconversion#data-vocabularyDV:name:namestreet-address:streetAddressregion:addressRegionlocality:addressLocalityphoto:i

  3. ruby - 将数组的内容转换为 int - 2

    我需要读入一个包含数字列表的文件。此代码读取文件并将其放入二维数组中。现在我需要获取数组中所有数字的平均值,但我需要将数组的内容更改为int。有什么想法可以将to_i方法放在哪里吗?ClassTerraindefinitializefile_name@input=IO.readlines(file_name)#readinfile@size=@input[0].to_i@land=[@size]x=1whilex 最佳答案 只需将数组映射为整数:@land边注如果你想得到一条线的平均值,你可以这样做:values=@input[x]

  4. ruby-on-rails - 如何在我的 Rails 应用程序 View 中打印 ruby​​ 变量的内容? - 2

    我是一个Rails初学者,但我想从我的RailsView(html.haml文件)中查看Ruby变量的内容。我试图在ruby​​中打印出变量(认为它会在终端中出现),但没有得到任何结果。有什么建议吗?我知道Rails调试器,但更喜欢使用inspect来打印我的变量。 最佳答案 您可以在View中使用puts方法将信息输出到服务器控制台。您应该能够在View中的任何位置使用Haml执行以下操作:-puts@my_variable.inspect 关于ruby-on-rails-如何在我的R

  5. ruby-on-rails - 正确的 Rails 2.1 做事方式 - 2

    question的一些答案关于redirect_to让我想到了其他一些问题。基本上,我正在使用Rails2.1编写博客应用程序。我一直在尝试自己完成大部分工作(因为我对Rails有所了解),但在需要时会引用Internet上的教程和引用资料。我设法让一个简单的博客正常运行,然后我尝试添加评论。靠我自己,我设法让它进入了可以从script/console添加评论的阶段,但我无法让表单正常工作。我遵循的其中一个教程建议在帖子Controller中创建一个“评论”操作,以添加评论。我的问题是:这是“标准”方式吗?我的另一个问题的答案之一似乎暗示应该有一个CommentsController参

  6. ruby - 查找字符串中的内容类型(数字、日期、时间、字符串等) - 2

    我正在尝试解析一个CSV文件并使用SQL命令自动为其创建一个表。CSV中的第一行给出了列标题。但我需要推断每个列的类型。Ruby中是否有任何函数可以找到每个字段中内容的类型。例如,CSV行:"12012","Test","1233.22","12:21:22","10/10/2009"应该产生像这样的类型['integer','string','float','time','date']谢谢! 最佳答案 require'time'defto_something(str)if(num=Integer(str)rescueFloat(s

  7. 【鸿蒙应用开发系列】- 获取系统设备信息以及版本API兼容调用方式 - 2

    在应用开发中,有时候我们需要获取系统的设备信息,用于数据上报和行为分析。那在鸿蒙系统中,我们应该怎么去获取设备的系统信息呢,比如说获取手机的系统版本号、手机的制造商、手机型号等数据。1、获取方式这里分为两种情况,一种是设备信息的获取,一种是系统信息的获取。1.1、获取设备信息获取设备信息,鸿蒙的SDK包为我们提供了DeviceInfo类,通过该类的一些静态方法,可以获取设备信息,DeviceInfo类的包路径为:ohos.system.DeviceInfo.具体的方法如下:ModifierandTypeMethodDescriptionstatic StringgetAbiList​()Obt

  8. ruby - 如何使用 Selenium Webdriver 根据 div 的内容执行操作? - 2

    我有一个使用SeleniumWebdriver和Nokogiri的Ruby应用程序。我想选择一个类,然后对于那个类对应的每个div,我想根据div的内容执行一个Action。例如,我正在解析以下页面:https://www.google.com/webhp?sourceid=chrome-instant&ion=1&espv=2&ie=UTF-8#q=puppies这是一个搜索结果页面,我正在寻找描述中包含“Adoption”一词的第一个结果。因此机器人应该寻找带有className:"result"的div,对于每个检查它的.descriptiondiv是否包含单词“adoption

  9. ruby - 鸭子输入字符串、符号和数组的优雅方式? - 2

    这是针对我无法破坏的现有公共(public)API,但我确实希望对其进行扩展。目前,该方法采用字符串或符号或任何其他在作为第一个参数传递给send时有意义的内容我想添加发送字符串、符号等列表的功能。我可以只使用is_a吗?数组,但还有其他发送列表的方法,这不是很像ruby​​。我将调用列表中的map,所以第一个倾向是使用respond_to?:map。但是字符串也会响应:map,所以这行不通。 最佳答案 如何将它们全部视为数组?String的行为与仅包含String的Array相同:deffoo(obj,arg)[*arg].eac

  10. ruby - 如何以编程方式删除实例上的 "singleton information"以使其编码(marshal)? - 2

    我创建了一个由于“在运行时执行的单例元类定义”而无法编码的对象(这段代码的描述是否正确?)。这是通过以下代码执行的:#defineclassXthatmyusesingletonclassmetaprogrammingfeatures#throughcallofmethod:break_marshalling!classXdefbreak_marshalling!meta_class=class我该怎么做才能使对象编码正确?是否可以从对象instance_of_x的classX中“移除”单例组件?我真的需要一个建议,因为我们的一些对象需要通过Marshal.dump序列化机制进行缓存。

随机推荐