How to save JSON array into SharedPreferences?
I've tried some code like this below, but i got some error :
[ERROR:flutter/lib/ui/ui_dart_state.cc(148)] Unhandled Exception: type 'Text' is not a subtype of type 'String'
for (var x = 0; x < dynamicwidget.length - 1; x++) {
_listOrder={
"id_product": dataJSON[x]["product_id"],
"order_count": dynamicwidget[x].controller.text,
};
}
String json = jsonEncode(_listOrder);
SharedPreferences prefs = await SharedPreferences.getInstance();
prefs.setString(categoryname, json);