Ardeshir ojan
Ardeshir ojan

Reputation: 2419

Flutter get.create implementation

I have a situation that only is fixed by get.create in getx package I have the following code

class ShoppingBinding implements Bindings {
 @override
 void dependencies() {

  Get.create<ShoppingController>(() => ShoppingController()); 
   } 
}

but I don't know how to call this thanks in advance

Upvotes: 0

Views: 1160

Answers (1)

Mori
Mori

Reputation: 171

you should create routing in GetMaterialApp :

  getPages: AppPages.pages,
  initialRoute: AppPages.INITIAL_ROUTE,

and in AppPages class :

GetPage(
    name: AppRoutes.ShoppingRouteName,
    page: () => ShoppingWidget(),
    binding: ShoppingBinding()),

Finally :

Get.toNamed(AppRoutes.ShoppingRouteName),

and in shopWidget :

class ShoppingWidget extends GetView<ShoppingController> {

Upvotes: 1

Related Questions