Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PageViewParallaxItemListenerPage 中Image.network 设置其他的fit,视差效果会失效 #119

Closed
OICQ469 opened this issue Mar 6, 2025 · 1 comment
Assignees

Comments

@OICQ469
Copy link

OICQ469 commented Mar 6, 2025

Version

1.25.0

Platforms

iOS

Device Model

15pm

flutter info

Image.network 设置其他的fit,视差效果会失效

How to reproduce?

Image.network 设置其他的fit,视差效果会失效

Logs

Image.network 设置其他的fit,视差效果会失效

Example code (optional)

Widget _buildPageItemBgPicView(int index) {
    return ValueListenableBuilder(
      valueListenable: picAlignmentX,
      builder: (BuildContext context, double alignmentX, Widget? child) {
        return Image.network(
          widget.imgUrl,
          //fit: BoxFit.cover,
          alignment: Alignment(111, 0),
        );
      },
    );
  }

Contact

No response

@LinXunFeng
Copy link
Member

LinXunFeng commented Mar 7, 2025

这不是这个库的问题,alignment 是否生效与 fit 有关,你不设置 fit,它会根据其它参数给出一个默认值,这里相当于 .contain,会对图片进行缩放直到完全展示,而示例中的图片宽度比高度大,所以在这种情况下,你设置 alignment.x 是无效的,只能调整 alignment.y,否则这将与 fit 相违背。

Image Image

如果你就是想不设置 fit 还有视差效果,那可以改用 Transform

return Transform.translate(
  offset: Offset(alignmentX * 100, 0),
  child: Image.network(
    widget.imgUrl,
  ),
);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants