flutter sharedmem_gpumem_alloc:

2020-12-25  本文已影响0人  悟饭哪

使用cached_network_image加载网络图片时,遇到sharedmem_gpumem_alloc: mmap failed errno 12 Out of memory,然后app会闪退。
解决办法,设置缓存图片的宽高,如下:

CachedNetworkImage(
                  imageUrl: imageURL,
                  placeholder: (context, url) => CircularProgressIndicator(
                    valueColor: AlwaysStoppedAnimation<Color>(widget.navColor),
                    strokeWidth: 1,
                  ),
                  errorWidget: (context, url, error) => Icon(Icons.error),
                  memCacheWidth: 180,
                  memCacheHeight: 180,
                  width: 180,
                  height: 180,
                  fit: BoxFit.cover,
                ),

Have fun.

上一篇 下一篇

猜你喜欢

热点阅读