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

Flutter每日一面(面试题五) #5

Open
ahyangnb opened this issue Mar 3, 2020 · 0 comments
Open

Flutter每日一面(面试题五) #5

ahyangnb opened this issue Mar 3, 2020 · 0 comments
Labels
加载 Flutter每日一面试题更新

Comments

@ahyangnb
Copy link
Owner

ahyangnb commented Mar 3, 2020

  • 1.你是如何解决asset数组图片滑动出现白屏问题的?

答案:

在初始化的时候就加载指定asset图片,而不是在需要展示的时候才开始加载。

  @override
  void initState() {
    super.initState();
    WidgetsBinding.instance.addPostFrameCallback((_) async {
     // _imageUrls 就是数组的Asset图片地址
      _imageUrls.forEach((image) {
        precacheImage(AssetImage(image), context);
      });
    });
  }
@ahyangnb ahyangnb added the 加载 Flutter每日一面试题更新 label Mar 3, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
加载 Flutter每日一面试题更新
Projects
None yet
Development

No branches or pull requests

1 participant