Binding without using "Get.to()" for GetX in Flutter

Viewed 385

I want to bind a controller to view 1 but I don't want to go to that view 1 via using Get.to(Page());.
Instead I want to use view 1 directly inside view 2 by creating an object.

Simplified code (BTW I'm using Veiw1Controller variables inside View1 itself)

class Veiw2 extends GetView<Veiw2Controller>{
     return View1();
}

When I'm doing the above code, it throws an error saying

"View1Controller" not found. You need to call "Get.put(View1Controller())" or "Get.lazyPut(()=>View1Controller())"

I did call Get.put(...) in the binding but I think since we are not calling Get.to()therefore GetX does not realize when we are using that view and it does not bind the dependencies
Here is what I've done

class View1 extends Bindings {
  @override
  void dependencies() {
    Get.put<View1Controller>(
      View1Controller(),
    );
  }
}

What is the best way to do that?

0 Answers
Related