【问题标题】:insert 2 images together将 2 个图像一起插入
【发布时间】:2022-09-23 19:48:33
【问题描述】:

我正在尝试从 figma ui 设计中进行此设计,并且需要将 2 张图片相互制作,但是当我这样做时,它们之间有一个空间,还有右侧图片中的阴影部分我该如何制作

但它不起作用所以它是这个形状的

import \'package:flutter/material.dart\';

class HomeScreen extends StatelessWidget {
  const HomeScreen({super.key});

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: Stack(
        children: [
          Row(
            children: [
              Expanded(
                child: Container(
                  width: 235,
                  height: 235,
                  decoration: const BoxDecoration(
                    image: DecorationImage(
                      image: AssetImage(
                        \'assets/images/back1.png\',
                      ),
                      fit: BoxFit.cover,
                    ),
                  ),
                ),
              ),
              Expanded(
                child: Container(
                  width: 279,
                  height: 279,
                  decoration: const BoxDecoration(
                    image: DecorationImage(
                      image: AssetImage(
                        \'assets/images/back1.png\',
                      ),
                      fit: BoxFit.cover,
                    ),
                  ),
                ),
              ),
            ],
          ),
        ],
      ),
    );
  }
}

那么要添加什么小部件或东西来使 2 pic 混合

标签: flutter dart


【解决方案1】:

使用 StackPositioned ,试试这个:

Stack(
                children: [
                  Positioned(
                    top: 0,
                    right: 0,
                    child: Image.asset(
                      'assets/images/back1.png',
                      fit: BoxFit.cover,
                      width: 235,
                      height: 235,
                    ),
                  ),
                  Positioned(
                    top: 0,
                    left: 0,
                    child: Image.asset(
                      'assets/images/back1.png',
                      fit: BoxFit.cover,
                      width: 279,
                      height: 279,
                    ),
                  ),
                  
                ],
              ),

【讨论】:

    猜你喜欢
    • 2012-06-15
    • 1970-01-01
    • 2014-03-21
    • 1970-01-01
    • 1970-01-01
    • 2021-08-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多