我用来Freezed在我的 flutter 项目上生成数据类。
我所做的一切与包自述文件中提到的完全一样:
import 'package:freezed_annotation/freezed_annotation.dart';
part 'access_token.freezed.dart';
@freezed
class AccessToken with _$AccessToken {
@JsonSerializable()
const factory AccessToken(
@JsonKey(name: 'access_token') String accessToken,
@JsonKey(name: 'refresh_token') String refreshToken,
) = _AccessToken;
factory AccessToken.fromJson(Map<String, Object?> json) =>
_$AccessTokenFromJson(json);
}
Run Code Online (Sandbox Code Playgroud)
构建成功完成。
当我运行该应用程序时,我得到:
lib/services/models/access_token.freezed.dart:118:7:错误:找不到方法:'_$$_AccessTokenFromJson'。_$$ AccessTokenFromJson(json); ^^^^^^^^^^^^^^^^^^^^^^^^ lib/services/models/access_token.freezed.dart:157:12:错误:方法“ $$ AccessTokenToJson”不是“ t 为类“ $_AccessToken”定义。
- “_$ AccessToken”来自“package:tenant_app/services/models/access_token.dart”(“lib/services/models/access_token.dart”)。尝试将名称更正为现有方法的名称,或定义名为“ $$_AccessTokenToJson”的方法。返回 _$$_AccessTokenToJson(
为什么Freezed没有正确生成该函数?我缺少什么?
我想创建一个 Flutter 应用程序,它将根据用户设备本地化支持不同的语言。
我想通过 Firebase 远程配置存储所有翻译文本。这样,远程更改将适用于所有用户,而无需更新应用程序。
现在,我的应用程序可以根据官方文档进行本地化。但这样所有文本都是硬编码的,因此用户必须更新应用程序才能获得新的文本更改。
我读过一篇关于创建自定义的文章LocalizationsDelegate,也许这样我就可以从 Firebase 和运行时加载所有文本。
我还阅读了有关easy_localization包的信息,但不幸的是,它似乎仅支持开箱即用的硬编码文本。
在 Firebase 配置中实现动态本地化的最佳方法是什么?
我希望有一个例子
firebase flutter firebase-remote-config google-cloud-firestore flutter-localizations
我正在使用改造包来在我的应用程序中生成 HTTP 请求。我想将多个文件上传到我们的服务器。文件数量未知(列表是动态的)。
我找到了一种解决方案,描述了如何使用改造上传一个文件:
@POST('/store')
@MultiPart()
Future<dynamic> store({
@Part() required String title,
@Part() File? attach,
});
Run Code Online (Sandbox Code Playgroud)
我正在寻找上传文件列表List<File>。
我该如何实现这一目标?
我正在尝试检查我的documentSnapshot.
我的代码:
document.data.containsKey('field_name')
Run Code Online (Sandbox Code Playgroud)
但我得到:
错误:未为类型“Function”定义方法“containsKey”。
有什么建议么?
我用来CustomPainter创建一个三角形。我想创建一个带边框的三角形。
我的 PaintTriangle 课程:
class PaintTriangle extends CustomPainter {
final Color backgroundColor;
PaintTriangle({
required this.backgroundColor,
});
@override
void paint(Canvas canvas, Size size) {
final y = size.height;
final x = size.width;
final paint = Paint()..color = backgroundColor;
final path = Path()
..moveTo(0, y)
..lineTo((x / 2), (y / y))
..lineTo(x, y);
canvas.drawPath(path, paint);
}
@override
bool shouldRepaint(CustomPainter oldDelegate) => true;
}
Run Code Online (Sandbox Code Playgroud) 真的很奇怪。添加超过 3BottomNavigationBarItem秒会将默认图标和背景颜色更改BottomNavigationBar为透明。
这是为什么?
PS,只要有 2 或 3 个项目,一切就可以正常工作。
class BottomNavigationTabs extends StatelessWidget {
const BottomNavigationTabs({Key? key, required this.child}) : super(key: key);
final Widget child;
@override
Widget build(BuildContext context) {
return Scaffold(
body: child,
bottomNavigationBar: BottomNavigationBar(
items: const [
BottomNavigationBarItem(icon: Icon(Icons.home), label: 'Home'),
BottomNavigationBarItem(icon: Icon(Icons.add), label: 'Create'),
BottomNavigationBarItem(
icon: Icon(Icons.favorite), label: 'Favorite'),
// BottomNavigationBarItem(icon: Icon(Icons.person), label: 'Profile'), // <-- uncomment transparent the whole bottomNavigationBar
],
),
);
}
}
Run Code Online (Sandbox Code Playgroud) 我正在使用url_launcher (6.1.5),我想在默认浏览器而不是应用程序内的 webView 中打开网址。
最新版本似乎不支持它,因为launch函数已被弃用,并且launchUrl不支持该forceWebView=false标志。
如何使用默认浏览器运行我的网址url_launcher?
当我跑步时,flutter doctor -v一切似乎都很好。但是当我使用 android studio 运行我的应用程序时,出现以下错误:
任务“:app:dexBuilderDebug”执行失败。地图中缺少 /home/daniel/AndroidStudioProjects/app_frontend/build/app/intermediates/transforms/FirebasePerformancePlugin/debug/142.jar 键。
在 kotlin.collections.MapsKt__MapWithDefaultKt.getOrImplicitDefaultNullable(MapWithDefault.kt:24)
在 kotlin.collections.MapsKt__MapsKt.getValue(Maps.kt:341)
我找不到任何相关信息FirebasePerformancePlugin key is missing error,甚至不知道如何开始调查该错误。
希望得到帮助,谢谢
当我运行时,flutter build ios我遇到上述错误:
产生错误。/Users/user926689/Library/Developer/Xcode/DerivedData/Runner-emyehpjhqbfhbsc xayqxsyftfyix/Build/Intermediates.noindex/Runner.build/Release-iphoneos/Runn er.build/DerivedSources/Runner_vers.c:5:72:错误:预期标识符 const double RunnerVersionNumber属性((used)) = (double)29 .;
flutter doctor就很好了。上次我为 ios 构建应用程序没有遇到任何问题。
什么是RunnerVersionNumber?有谁知道如何解决这个问题?
我想重置我的应用在 Google Play 上的评分和评论。
我怎么做?
有可能吗?
我无法找到有关该主题的太多信息。
flutter ×9
firebase ×3
android ×1
freezed ×1
google-play ×1
retrofit ×1
url-launcher ×1
xcode ×1