본문 바로가기

Flutter

자꾸 까먹는 플러터 패턴/부모클래스

바인딩  : Bindings

 ex) class InitBinding extends Bindings {}

 

컨트롤러 : GetxService or GetxController 을 사용하고 static 사용

 ex)

 앱컨트롤러

   class AppController extends GetxService {

      static AppController get to => Get.find();

   }

기타 컨트롤러

  class HomeController extends GetxController {

  static HomeController get to => Get.find();

 

레포지토리 : GetConnect 을 사용하고 static 사용

  ex)

  class ApiRepo extends GetConnect {

    static ApiRepo get to => Get.find();

   @override

   void onInit(){

   httpClient.baseurl = "https://aaa.com";

   super.onInit();

   }

  }

 

app.dart GetView<AppController>

ex) 

  class App extends GetView<AppController> { }