xdd666t / getx_template

Used to generate the template code of GetX framework | Flutter GetX模板代码生成(一个有用的IDEA插件)
Apache License 2.0
298 stars 67 forks source link

Get.find找不到 #37

Closed tonyzy212 closed 2 years ago

tonyzy212 commented 2 years ago

您好 使用模板新建之后 final logic = Get.find()(); 会提示find过时 切在route路由调用getpage的时候会提示找不到find,求解,用的最新版3.2.6

xdd666t commented 2 years ago

描述详细点吧,你的getx是什么版本?你操作调整路由的可执行的代码

final logic = Get.find()(); 
  final logic = Get.put(SmartDialogLogic());
  final state = Get.find<SmartDialogLogic>().state;
tonyzy212 commented 2 years ago

描述详细点吧,你的getx是什么版本?你操作调整路由的可执行的代码

  • 还有模板并没有这种代码
final logic = Get.find()(); 
  • 生成的是这种的
  final logic = Get.put(SmartDialogLogic());
  final state = Get.find<SmartDialogLogic>().state;

class BestPage extends StatelessWidget { @override Widget build(BuildContext context) { final logic = Get.find(); final state = Get.find().state;

return Container();

} } temple版本是3.2.6,get版本是 get: ^4.6.5 class RouteGet { ///root page static const String tab = "/main/TabPage"; static const String main = "/main/MainPage"; static const String mine = "/mine/MinePage"; static const String trade = "/trade/TradePage"; static const String market = "/market/MarketPage"; static const String best = "/best/BestPage"; static const String zero = "/zero/ZeroPage"; ///pages map static final List getPages = [ GetPage(name: tab, page: () => TabPage()), GetPage(name: main, page: () => MainPage(),binding: MainBinding()), GetPage(name: mine, page: () => MinePage(),binding: MineBinding()), GetPage(name: trade, page: () => TradePage(),binding: TradeBinding()), GetPage(name: market, page: () => MarketPage(),binding: MarketBinding()), GetPage(name: best, page: () => BestPage()), ]; } 我这个自动生成后的view是find不是put 看您的文档是put 想知道是哪里错了 temple版本是3.2.6,get版本是 get: ^4.6.5,新手求教大神

tonyzy212 commented 2 years ago

class BestPage extends StatelessWidget { @override Widget build(BuildContext context) { final logic = Get.find(); final state = Get.find().state;

return Container();

} }我复制粘贴上来的find被改了奇怪 class BestLogic extends GetxController { final BestState state = BestState();

@override void onReady() { // TODO: implement onReady super.onReady(); }

@override void onClose() { // TODO: implement onClose super.onClose(); } }

xdd666t commented 2 years ago

这是我这边的效果

tonyzy212 commented 2 years ago

class BestPage extends StatelessWidget { @OverRide Widget build(BuildContext context) { final logic = Get.find(); final state = Get.find().state;

return Container();

} }我复制粘贴上来的find被改了奇怪 class BestLogic extends GetxController { final BestState state = BestState();

@OverRide void onReady() { // TODO: implement onReady super.onReady(); }

@OverRide void onClose() { // TODO: implement onClose super.onClose(); } }

`class BestPage extends StatelessWidget { @override Widget build(BuildContext context) { final logic = Get.find(); final state = Get.find().state;

return Container();

} }`

tonyzy212 commented 2 years ago

奇怪为啥我生成是find不是put

xdd666t commented 2 years ago

卸载重装,清下缓存重启试试吧

tonyzy212 commented 2 years ago

微信截图_20220920112940

tonyzy212 commented 2 years ago

您看 自动生成后 默认就是find

tonyzy212 commented 2 years ago

卸载重装,清下缓存重启试试吧

好的我试试

xdd666t commented 2 years ago

沃日,你用了binding吧

xdd666t commented 2 years ago

image

xdd666t commented 2 years ago

image

tonyzy212 commented 2 years ago
  • 你这地方没加binding

image

不用binding的话是不是就是put了, 问题是为啥我自动生成是find不是put大神

tonyzy212 commented 2 years ago

还真是 谢谢您 不用binging 就是put了 感谢大神

xdd666t commented 2 years ago

你自己看看你生成代码的弹窗选项

tonyzy212 commented 2 years ago
  • 因为选中的生成代码的 “addBinding” 选项,put就会改成find,binding里面已经lazyput了

你自己看看你生成代码的弹窗选项

受教了 学艺不精 添麻烦了大神