简体   繁体   English

如何将值传递给flutter中的函数

[英]How to pass a value to a function in flutter

I created a StatefulWidget and get the index value here:我创建了一个StatefulWidget并在此处获取索引值:

在此处输入图像描述

But the index is not accessible in the function, how can I access the index in the Fetchingredient function.但是函数中无法访问索引,如何访问Fetchingredient函数中的索引。

在此处输入图像描述

Write widget before index.在索引之前写入widget Final code:最终代码:

widget.index

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM