![](/img/trans.png)
[英]How to pass image picker file from one page to another in flutter dart?
[英]Flutter: how to pass values from one file to another without Navigator?
我目前遇到了一些麻煩。 我想將一個字符串變量(列表字符串的索引)從一個 dart 文件傳遞到另一個文件,但我知道的唯一方法是使用 Navigator。 還有其他不需要手機換屏的方法嗎?
You can do it like this
{
//Model class that required some files to print out the full name
class Model {
String name;
String fName;
Model({required this.fName, required this.name});
void caller(){
print('Your name is: $name $fName');
}
}
//This is data provider class to the Model class
class Test {
var model = Model(fName: 'Flutter',name: 'Developer');
}
// This is the main function to Invoke the Test class
void main() {
var tester =Test();
tester.model.caller();
}
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.