You can also used parameters.
var data = {
"email" : "[email protected]",
"message" : "hi!"
};
Get.toNamed(YourRouteName.name, parameters: data);
Also from getting it from another pages is like this.
print(Get.parameters['email']);
Also on Getx you can pass it like a url link on data as the document written.
https://github.com/jonataslaw/getx/blob/master/documentation/en_US/route_management.md
If you want to pass whole item data,
You can also pass a model from list if have onTap function though you need to decode it again
e.g
MyCardItemFromList(
name: list[index].name,
ontapFunction: () => Get.toNamed(
YourRouuteName.name,
parameters: {
/// Lets assume this is the item selected also it's own item data
"itembyIndex": jsonEncode(list[index]),
}
),
),
from controller
class MyXampleController extends GetxController{
//declare the model
final Rx<Model> model = Model().obs;
@override
void onInit() {
convertToDecode();
super.onInit();
}
convertToDecode(){
final decode = jsonDecode(Get.parameters['itembyIndex'])
final passToModel = Model.fromJson(decode);
model(passToModel);
// or if you are using getBuilder
// try do it like this
// model.value = passToModel;
// update();
// don't forget to call update() since it's needed from getbuilder;
}
}
Now, For calling the data from ui will be like this
final controller = Get.put(MyXampleController());
///// this will be the data we got from the item
controller.model.value.name