简体   繁体   English

如何从其他小部件访问 flutter package 中变量的值?

[英]How access to value of a variable in flutter package from other widget?

I wrote a package for Flutter and added it to the main.dart and it works well but How can I access the value of one of the variables in the package? I wrote a package for Flutter and added it to the main.dart and it works well but How can I access the value of one of the variables in the package? or how return a variables from it?或者如何从中返回变量? For example, in the slider widget, we have access to the value of the slider with on change.例如,在slider小部件中,我们可以通过 on change 访问 slider 的值。

You want to learn how to manage state in flutter.您想了解如何管理 flutter 中的 state。

There are couple of good state management tools:有几个很好的 state 管理工具:

provider seems to be the easiest one. provider似乎是最简单的一个。

Here is a nice tutorial on provider:这是关于提供者的一个很好的教程:

https://blog.codemagic.io/flutter-tutorial-app-arhitecture-beginners/ https://blog.codemagic.io/flutter-tutorial-app-arhitecture-beginners/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Flutter - 如何在其他小部件中访问 TextEditingController? - Flutter - How to access TextEditingController in other widget? 如何在初始化程序颤振中访问来自小部件的传递值 - how to access passed value from widget in initializer flutter 如何在 flutter 中从一个 class 访问变量到另一个 - How to access the variable from one class to other in flutter Flutter:如何从其他小部件调用 openDrawer - Flutter: How to call openDrawer from other widget Flutter/Dart FutureBuilder - 如何将快照数据存储在变量中并将值传递给其他小部件? - Flutter/Dart FutureBuilder - How to store a snapshot.data in a variable and pass the value to other widget? 如何从函数访问变量并在我的小部件中使用它 - Flutter 存储变量 - How do I access variable from a function and use it in my widget - Flutter storage variable Flutter - 如何从其他小部件访问 DropDown 中当前选定的项目? - Flutter - How can I access current selected item in DropDown from other widget? Flutter 访问另一个小部件中的小部件变量 - Flutter access Widget variable in another widget 如何从 Flutter 中的另一个小部件访问有状态小部件动画控制器? - How to access Stateful widget animation controller from another widget in Flutter? 如何从 flutter 中的不同屏幕访问变量值? - how to access variable value , from a different screen in flutter?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM