【问题标题】:How to increase the height of Network Image in Flutter?Flutter中如何增加Network Image的高度?
【发布时间】:2022-01-12 20:51:19
【问题描述】:

我怎样才能改变我的网络图像的高度,它是固定的,不会改变,

This is the output

这是代码。

Container(
      padding: const EdgeInsets.all(10),
      child: SingleChildScrollView(
        child: Column(
          children: [
            TextField(
              decoration: const InputDecoration(
                border: OutlineInputBorder(),
                labelText: 'Movie Title',
              ),
              controller: controller,
            ),
            const SizedBox(
              height: 20,
            ),
            Card(
              child: ListTile(
                leading: Image.network(
                  "https://m.media-amazon.com/images/M/MV5BMTExZmVjY2ItYTAzYi00MDdlLWFlOWItNTJhMDRjMzQ5ZGY0XkEyXkFqcGdeQXVyODIyOTEyMzY@._V1_SX300.jpg",
                  fit: BoxFit.cover,
                  width: 100,
                  height: 150,
                ),
              ),
            ),
          ],
        ),
      ),
    ),

提前致谢!

【问题讨论】:

    标签: flutter layout flutter-layout


    【解决方案1】:

    如果您进入 ListTile,您将看到前导的高度和宽度常量数字已给出。所以你不能改变前导的高度和宽度。您可以使用 SizedBox 或 Container 代替 ListTile

    【讨论】:

      【解决方案2】:

      试试下面的代码希望它对你有帮助。使用Container 而不是ListTile

      请参考 Container Here

        Column(
          children: [
            const TextField(
              decoration: InputDecoration(
                border: OutlineInputBorder(),
                labelText: 'Movie Title',
              ),
            ),
            const SizedBox(
              height: 20,
            ),
            Card(
              child: Row(
                crossAxisAlignment: CrossAxisAlignment.start,
                children: [
                  Container(
                    child: Image.network(
                      "https://m.media-amazon.com/images/M/MV5BMTExZmVjY2ItYTAzYi00MDdlLWFlOWItNTJhMDRjMzQ5ZGY0XkEyXkFqcGdeQXVyODIyOTEyMzY@._V1_SX300.jpg",
                      fit: BoxFit.cover,
                      width: 100,
                      height: 150,
                    ),
                  ),
                  SizedBox(
                    width: 20,
                  ),
                  Expanded(
                    child: Column(
                      crossAxisAlignment: CrossAxisAlignment.start,
                      children: [
                        Text('Your Other Widgets if you want'),
                        SizedBox(height: 20),
                        Text('Your Other Widgets if you want'),
                      ],
                    ),
                  ),
                ],
              ),
            ),
          ],
        ),
      

      您的结果屏幕->

      【讨论】:

        猜你喜欢
        • 2018-11-04
        • 1970-01-01
        • 2023-03-10
        • 2019-03-05
        • 2012-10-13
        • 2015-10-27
        • 2018-12-08
        • 2012-01-23
        • 2019-10-24
        相关资源
        最近更新 更多