Sqlite 颤振:如何在showDialog中同步数据?(与sqflite一起) void MakeMomeMarker(列表备忘录列表、构建上下文){ if(memoList.length!=null | | 0
这是我的密码。我想通过Sqlite 颤振:如何在showDialog中同步数据?(与sqflite一起) void MakeMomeMarker(列表备忘录列表、构建上下文){ if(memoList.length!=null | | 0,sqlite,flutter,Sqlite,Flutter,这是我的密码。我想通过showDialog把我的一些笔记放进去。所以我写了一些东西,并成功地在Sqlflite中插入了一个注释。我还成功地使用builderSetState在不离开showDialog的情况下显示了注释,但当我离开并返回到showDialog时,它又回到了过去。如何解决这个问题?当我将便笺直接插入到备忘录[“备忘录”]时,会出现一个错误,显示为只读。请发布一个最小的可复制代码,我们不知道您的备忘录是什么 void makeMemoMarker(List<Map<Str
showDialog
把我的一些笔记放进去。所以我写了一些东西,并成功地在Sqlflite
中插入了一个注释。我还成功地使用builderSetState
在不离开showDialog
的情况下显示了注释,但当我离开并返回到showDialog
时,它又回到了过去。如何解决这个问题?当我将便笺直接插入到备忘录[“备忘录”]
时,会出现一个错误,显示为只读。请发布一个最小的可复制代码,我们不知道您的备忘录是什么
void makeMemoMarker(List<Map<String, dynamic>> memoList, BuildContext context){
if (memoList.length != null || 0 < memoList.length) {
for(final memo in memoList){
memoMarkerList.add(Marker(
markerId: MarkerId(memo["id"]),
position: LatLng(memo["latitude"], memo["longitude"]),
onTap: (){
memodialog(context, memo);
}
));
}
}
}
Future memodialog(BuildContext context, Map<String, dynamic> memo) async {
bool editState = false;
String note = memo["memo"];
TextEditingController textEditingController = TextEditingController();
await showDialog(
context: context,
child: StatefulBuilder(
builder: (context, builderSetState){
return SimpleDialog(
children: [
editState ? Padding(
padding: const EdgeInsets.only(left: 8, right: 8),
child: Container(
child: TextFormField(
controller: textEditingController,
),
),
) : SimpleDialogOption(
child: Container(
child: Center(child: Text(note))
),
),
SimpleDialogOption(
child: editState ?
Center(child: Text("Save", style: TextStyle(fontWeight: FontWeight.bold, color: Colors.blueAccent))) :
Center(child: Text("Edit", style: TextStyle(fontWeight: FontWeight.bold, color: Colors.blueAccent))),
onPressed: ()async{
if(editState == false){
builderSetState(() {
editState = true;
});
}
else{
dbHelper.updatememo(Provider.of<UserModelState>(context, listen: false).userModel.userkey, memo["id"], textEditingController.text);
builderSetState((){
note = textEditingController.text;
editState = false;
});
}
},
),
],
);
}
)
);
}