How to make an image provider from an Icon in flutter for FadeInImage widget?

前端 未结 2 585
长情又很酷
长情又很酷 2020-12-16 12:58

I want to use FadeInImage with an icon as a placeholder.

FadeInImage has few constructors.

In a default constructor it takes

2条回答
  •  孤城傲影
    2020-12-16 13:15

    Icons are really just text from a font, so its tricky to make that into an image. The trick in the cookbook should work. Use a Stack with the Icon behind and a transparent placeholder.

        body: Stack(
          children: [
            Center(child: Icon(Icons.something)),
            Center(
              child: FadeInImage.memoryNetwork(
                placeholder: kTransparentImage,
                image:
                    'https://github.com/flutter/website/blob/master/_includes/code/layout/lakes/images/lake.jpg?raw=true',
              ),
            ),
          ],
        ),
    

提交回复
热议问题