【问题标题】:Flutter: How to make the below image widget functional in StackFlutter:如何使以下图像小部件在 Stack 中起作用
【发布时间】:2020-10-26 15:48:46
【问题描述】:

我尝试实现该功能:捏放大/缩小另一个叠加图像下的图像。

我的方法是使用photo_view 使主照片可缩放,并通过“堆栈”将叠加图像放在主照片的顶部。

import 'package:photo_view/photo_view.dart';

class Body extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Container(
      child: Stack(
        children: <Widget>[
          Container(
            child: PhotoView(
              initialScale: PhotoViewComputedScale.covered,
              imageProvider: AssetImage("assets/mainphoto.jpg"),
              ),
            ),
          ),
          Container(
            child: Center(
              child: AssetImage("assets/overlay.png”),
            ),
          ),
        ],
      ),
    );
  }
}

以上代码的结果

但是叠加图像完全禁用了主照片,我无法通过捏合来放大/缩小主照片。

我认为是因为 Stack,我用 Google 搜索了它,但仍然没有任何合适的解决方案。

如果有任何建议,我非常感谢。

【问题讨论】:

    标签: flutter dart zooming overlay photoviewer


    【解决方案1】:

    使用 IgnorePointer 小部件

    IgnorePointer(
      child: Container(
        child: Center(
          child: Image.asset(
            "assets/overlay.png",
          ),
        ),
      ),
    )
    

    【讨论】:

      猜你喜欢
      • 2020-10-10
      • 1970-01-01
      • 2018-10-30
      • 2020-09-09
      • 2020-09-29
      • 2019-11-21
      • 2020-10-10
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多