【问题标题】:How to create a color bar with rows of text in flutter如何在颤动中创建带有文本行的颜色条
【发布时间】:2021-03-22 23:30:20
【问题描述】:

我如何使用颤振在屏幕截图中创建条形显示。下面[在此处输入图片说明][1]

[1]:https://i.stack.imgur.com/dXKsm.png`enter 此处代码`

Row(
                  children: [
                    Expanded(
                          child: SizedBox(
                          child: Text("CONTACT US",
                          style: TextStyle(color: Colors.white),
                          ),
                      ),
                    ),
                    Expanded(
                        child: Padding(
                          padding: const EdgeInsets.only(left: 30.0),
                          child: SizedBox(
                          child: Text("SOCIAL MEDIA", style: TextStyle(color: Colors.white),),
                      ),
                        )
                    ),
                    Expanded(
                        child: Padding(
                          padding: const EdgeInsets.only(left: 30.0),
                          child: SizedBox(
                          child: Text("NEWSLETTER", style: TextStyle(color: Colors.white),),
                      ),
                        )
                    ),
                  ],
                ),

【问题讨论】:

  • 你需要创建一个包含 3 个子元素的 Row,这 3 个子元素将是一个 Column,并且该列的子元素是你的元素。然后您可以将所有内容包装到一个容器中并提供首选背景。
  • Emanuel 开发者,你有例子吗?给我示例布局。

标签: flutter dart


【解决方案1】:

您可以尝试类似的东西并根据您的目的和颜色进行调整:

class Sample extends StatefulWidget {
  @override
  _SampleState createState() => _SampleState();
}

class _SampleState extends State<Sample> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      backgroundColor: Colors.white,
      appBar: AppBar(
        title: Text('sample'),
      ),
      body: Container(
        height: 200,
        width: 2000,
        color: Color(0xff808080),
        child: Row(
          mainAxisAlignment: MainAxisAlignment.spaceAround,
          children: [
            Column(
              mainAxisAlignment: MainAxisAlignment.center,
              children: [
                Text('Contact Us'),
                Row(children: [
                  Icon(Icons.phone),
                  Text('phone')]),
                Row(children: [
                  Icon(Icons.mail),
                  Text('info@test.it')]),
                Row(children: [
                  Icon(Icons.map_outlined),
                  Text('unavailable')]),
              ],
            ),
            Column(
              mainAxisAlignment: MainAxisAlignment.center,
              children: [
                Text('Contact Us'),
                Icon(Icons.wrap_text_rounded),
                Icon(Icons.point_of_sale),
              ],
            ),
            Column(
              mainAxisAlignment: MainAxisAlignment.center,
              children: [
                Text('Newsletter'),
                Text('Susbcribe'),
              ],
            ),
          ],
        ),
      )
    );
  }
}

【讨论】:

  • 伊曼纽尔开发者。是的,这行得通。只是好奇你知道如何让它可折叠用于手机吗?
  • 同理只需要调整Container(高宽)
  • 不!我不认为你明白。我正在编写一个网站。我想知道你是否知道如何让它对手机有响应。这样第二列在第一列下塌陷,第三列在第二列下塌陷。
  • 是的,你可以用 WRAP 而不是 ROW 来包装它们,你也可以将它们用作宽度:MediaQuery.of(context).size.width
  • 很抱歉,您提到的内容令人困惑。你能给我一个直观的例子吗?将其发送至 camaronbrowne@gmail.com。您是说删除所有内部行小部件并用 Wrap 替换它们?
猜你喜欢
  • 2014-03-21
  • 2019-09-08
  • 2020-08-19
  • 2021-01-25
  • 2021-12-14
  • 1970-01-01
  • 2023-03-29
  • 1970-01-01
  • 2020-11-18
相关资源
最近更新 更多