【发布时间】:2022-12-12 08:59:57
【问题描述】:
var a = {
'field1' : 'one'
'field2' : 'two'
}
然后我想添加地图 b。
所以我试过了
a['b'] = {
'nestedKey':{
'field1' : 'one'
}
};
但它发生错误。我如何实现这一目标?
[ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: type '_InternalLinkedHashMap<String, dynamic>' is not a subtype of type 'String?' of 'value'
eamirho3ein 的回答有效,但这仍然无效 我添加更多这不起作用
Navigator.of(context).pushAndRemoveUntil(
MaterialPageRoute(
builder: (context) => ScreenB(
args: {
'oldfield': 'old'
},
)),
(Route<dynamic> route) => false);
import 'package:flutter/material.dart';
class ScreenB extends StatelessWidget {
final args;
const ScreenB({Key? key, required this.args}) : super(key: key);
@override
Widget build(BuildContext context) {
args['newfield'] ={
'nested':{
'field1' : 'one'
}
};
print($args);
return Container();
}
}
【问题讨论】:
-
你会包括你的结果和错误信息吗?
-
@eamirho3ein 我补充道