0
Follow
0
View

How to call a function from another page in flutter?

guwanglai 注册会员
2023-01-25 17:53

If you want to use some parent's function in child widget then it is easy - just pass the reference to the function you want through the constructor.

If you want to use some child's function in parent widget then the situation is a little bit different - you have to pass a GlobalKey to identify the state of child widget when creating an instance of this widget. You can refer to this https://stacksecrets.com/flutter/how-to-call-method-of-a-child-widget-from-parent-in-flutter.

If you want to use a function from a widget that is not either a child or parent widget, then you might think of using some state managment solution (such as Provider or GetX or Bloc) to provide it to all the widget that needs some information from it.

About the Author

Question Info

Publish Time
2023-01-25 17:53
Update Time
2023-01-25 17:53

Related Question

Firestore订阅主题结构,如何绕过1MB限制?

运行dotnet隔离的AzureFunction不起作用

Windows桌面应用程序仍然支持vsto吗

React查询devtools在React -typescript应用中没有

vsto加载项显示不出来

SaxonC 11.1 transform_to_file不产生输出文件

如何在命令行上从JSON编码到二进制Protobuf ?

qcustomplot坐标轴问题

电脑报错This application failed to start because no Ot platform plugincould be initialized.

如何在springboot中使用MongoRepository查找Mongo集合的特定字段的平均值?