enter image description hereI try to solve the problem although the user is in offline situation, to show local image ,but I get this error.how to solve it please help me .My url is not worng but get error .

  FadeInImage(
                      height: 250,
                      width: 300,
                      // here `bytes` is a Uint8List containing the bytes for the in-memory image
                      placeholder: AssetImage('images/profile.jpg'),
                      image: NetworkImage(user?.photoUrl ?? ''),
                    ),

推荐答案

...用户处于脱机状态,以显示本 map 像,但我收到此错误

placeholder属性用于当图像为loading时,因此在图像完全加载后,您仍然会在脱机模式下收到错误,因为它仍然try 加载在offline模式下不起作用的NetworkImage.

要解决这个问题,您可以使用Image.network,它有一个errorBuilder-如果找不到网络映像,就会被调用,然后,您应该加载一个Asset映像.

FadeInImage(
              height: 250,
              width: 300,
              placeholder: NetworkImage('https://picsum.photos/200/300.jpg'),
              image: Image.network(
                'https://fastly.picsum.photos/id/493/200/300.jpg?hmac=grrcfhF-iSyQuaMEkd8b4OH6Gn2W3xm7dUL4-955Vxw',
                errorBuilder: (BuildContext context, Object exception,
                    StackTrace? stackTrace) {
                  return Image.asset('/path/to/image.png');
                },
              ).image)

See also

Flutter相关问答推荐

Flutter bloc -如何使用BlocBuilder?

将目标平台设置为Flutter 构建

从超级应用程序启动时,Flutter 小应用程序中未加载资源

Flutter 翼future 建造者不断开火和重建.它在每次重建时都会生成一个新的随机数--我如何防止这种情况?

如何在抖动中将PNG图像转换为WebP

轻松本地化包翻译在底部导航栏项目标签Flutter 翼dart 中不起作用

flutter Listview构建器溢出

在 flutter 的列中使用 Expanded 时出现渲染 Flex 错误

如何修改来自合并 list 的 Android list 权限?

Riverpod中stateNotiferProvider和notifierProvider的区别

使用 Play Integrity API 时,Firebase 电话身份验证问题缺少客户端标识符错误

如何更改中心的圆形进度指示器

Show Snackbar above to showModalBottomSheet Flutter

Riverpod 在使用冻结副本更新状态时触发重建,即使没有任何更改

如何在 Flutter 中使用简写 IF 禁用单选按钮?

如何在 flutter 中过滤 DateTime(intl)?

Flutter 中的无效日期格式 2022 年 11 月 14 日

我几乎每次都将 Stateless Widget 与 BLoC 一起使用.我错了吗?

Flutter如何从左到右连续 Select 多个列表项而不跳过任何

参数类型Future>不能分配给参数类型Future>?