0
点赞
收藏
分享

微信扫一扫

Getx controller初始化携带参数

大雁f 2023-12-28 阅读 46


不难的一个问题,写的时候一时间没反应过来。。。

// 声明controller

SomeController extends GetxController{
	final String id;
	final String? name;
  SomeController({required this.id,this.name});

  static SomeController get to => Get.find();
  
  initConfig(){
  	print(id);
  }
  
  @override
  void onInit() {
    super.onInit();
    initConfig();
  }
}

// 实例化controller
Get.put(SomeController(id: id,name:'johnny'));

搞定~~~~


举报

相关推荐

0 条评论