Home > OS >  send data through arguments with GetX
send data through arguments with GetX

Time:09-17

is it a good practice to send data with arguments in flutter using GetX (or any other way)? i mean is it good for performance and ram capcity ? ... like this example:

Get.toNamed(AppPages.servicesDetails, arguments: [service]);

when (service) contain a data for only one product came from API : like (id, name, info, image ...etc).

and in the servicesDetails page:

 final s = Get.arguments[0];
  @override
  Widget build(BuildContext context) {
    return  Scaffold(
      body:  Center(child: Text(s.name),),

CodePudding user response:

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

CodePudding user response:

You can simply use arguments

Get.toNamed(
      '/my-route',
      arguments: "Hello",
    );

on the second screen, you can do

final title = Get.arguments as String;

  • Related