【问题标题】:I want a row inside a container which has a boxdecoration too我想在一个也有 boxdecoration 的容器内有一排
【发布时间】:2019-11-09 09:25:16
【问题描述】:

我正在尝试构建一个屏幕,我想要一个容器内的行小部件,其中容器具有 boxDecoration 属性。如何做到这一点?

我试图把容器放在一个大小合适的盒子里,它有一个 boxDecoration 属性。现在,我想要一个行小部件,以便我可以将图像和一些文本放在一起。但我不知道这样做。

这是我的代码:

大小框( 宽度:420.0, 高度:110.0,

                child :
                Container( //here i want a row widget so that i can put one image and some text 

                  padding: EdgeInsets.only(bottom:10,top:30,left:20),
                  decoration: BoxDecoration(
                      border: Border.all(color: Color(0xffD4D4D4),width: 2.0)
                  ),
                  child : Text("External LTE 4G universal modem antennas (2 or 4) (SMA) finger tighten only",textAlign: TextAlign.justify,style: TextStyle(fontSize: 15,fontWeight: FontWeight.normal),
                  )
              ),
            ),

【问题讨论】:

    标签: flutter-layout


    【解决方案1】:

    你的意思是你想要一个图像和一些文本并排?

    试试这个。

    Container(
                padding: EdgeInsets.only(bottom:10,top:30,left:20),
                decoration: BoxDecoration(
                    border: Border.all(color: Color(0xffD4D4D4),width: 2.0)
                ),
                child: Row(
                  children: <Widget>[
                    Image.asset(), // <-- add the image path here, also don't forget to add the image to pubspec.yaml
                    Expanded(child: Text("External LTE 4G universal modem antennas (2 or 4) (SMA) finger tighten only",textAlign: TextAlign.justify,style: TextStyle(fontSize: 15,fontWeight: FontWeight.normal),))
                  ],
                )
            ),
    

    【讨论】:

    • 谢谢它的工作,但如果文本很长,则会出现文本溢出并且开箱即用。我现在该怎么办?
    • 您可以用展开的小部件包围文本小部件。检查更新的答案。
    • 是的,扩展后的东西稍微有点作用,但盒子末尾的文字不可见(就像我只能看到句子中最后一个字母的一半)。
    • 你是什么意思它对我很有效??尝试将此添加到 Container padding `padding: E​​dgeInsets.only(bottom:10,top:30,left:20, right: 20.0),`
    猜你喜欢
    • 1970-01-01
    • 2017-12-23
    • 2019-07-27
    • 1970-01-01
    • 2023-03-27
    • 2021-08-18
    • 2020-09-30
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多