jonataslaw / getx

Open screens/snackbars/dialogs/bottomSheets without context, manage states and inject dependencies easily with Get.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[Document] Can write a document to explaining each rendering function?

xieyezi opened this issue · comments

Is your feature request related to a problem? Please describe.

We all know that getx have many render function in views, there are:

  • Obx(()=>())
Obx (() => Text (controller.name));
  • GetBuilder<Controller>
GetBuilder<CountController>(
  init: controller,
  initState: (_) {},
  builder: (controller) {
    return Text('value -> ${controller.count}');
  },
),
  • GetX<Controller>
GetX<Controller>(
  builder: (controller) {
    print("count 1 rebuild");
    return Text('${controller.count1.value}');
  },
),
  • ValueBuilder<bool>
ValueBuilder<bool>(
  initialValue: false,
  builder: (value, updateFn) => Switch(
    value: value,
    onChanged: updateFn, 
  ),
  onUpdate: (value) => print("Value updated: $value"),
  onDispose: () => print("Widget unmounted"),
),
  • ObxValue
ObxValue((data) => Switch(
        value: data.value,
        onChanged: data,
    ),
    false.obs,
),
  • GetView<AwesomeController>
 class AwesomeView extends GetView<AwesomeController> {
   @override
   Widget build(BuildContext context) {
     return Container(
       padding: EdgeInsets.all(20),
       child: Text( controller.title )
     );
   }
 }

Describe the solution you'd like

In fact, I really read the documentation carefully, but I really don’t understand these methods, how to use them, and where to use them. And the difference between them.

So can getx provide one document to explain these render function how to use, and where to use?

Thanks!

This StackOverflow comment has some explanation about these https://stackoverflow.com/a/65415848/340290