我有一个 JsonElement 类型的对象,其中包含 API 返回的数据。我想获取某个属性的值,但问题是 TryGetProperty 区分大小写。有没有办法或解决方法可以在忽略区分大小写的同时按名称获取属性?
谢谢你。
我已经在我的 flutter 项目中安装了 Riverpod,并且正在尝试创建一个扩展 ConsumerWidget 的类,但后者无法被我的 IDE(Android Studio)识别,并且它以红色下划线,尽管一切似乎都是正确的。
这是我的课:
import 'package:flutter/material.dart';
import 'package:testproject/models/message_model.dart';
import 'package:riverpod/riverpod.dart';
class MessageList extends ConsumerWidget {
@override
Widget build(BuildContext context, WidgetRef ref) {
List<Message> messages = ref.watch(todosProvider);
return widget();
}
}
Run Code Online (Sandbox Code Playgroud)
这是我的 pubspec 文件:
name: testproject
description: A new Flutter project.
# The following line prevents the package from being accidentally published to
# pub.dev using `pub publish`. This is preferred for private packages.
publish_to: 'none' # Remove this line if you wish to publish to …Run Code Online (Sandbox Code Playgroud) 我正在为我的 Android 和 ios 应用程序开发上传功能,并且我正在使用 Firebase Storage。我正在上传大小仅超过 100kb 的小图像。在我的 Android 设备上一切正常,但由于某种原因我的 ios 无法按预期工作。这是有问题的代码:
final snapshot = await _firebaseStorage
.ref()
.child("$profilePicsFolder/$fileName")
.putFile(resImg);
final String imgUrl = await snapshot.ref.getDownloadURL();
await auth.updateUserProfilePicture(photoUrl: imgUrl);
Run Code Online (Sandbox Code Playgroud)
这里的问题是 putFile() 在 ios 上需要很长时间,但在 android 上只需要几秒钟。我注意到,即使执行仍在等待 putFile() 函数几分钟,当我直接检查 Firebase 存储时,我注意到文件几乎立即上传。
不确定我在这里做错了什么。