flutter - 如何在颤振的步骤方法中上传图像
问题描述
List<Step> steps = [
Step(
isActive: false,
state: StepState.editing,
title: const Text('Id Proof'),
content: Column(
children: <Widget>[
OutlineButton(
onPressed: chooseImage,
child: Text('Choose Image'),),
showImage(),
OutlineButton(
onPressed: startUpload,
child:Text(Upload Image),
),
Text(status,textAlign:TextAlign.center,style:TextStyle(color:Colors.green))
],
),
),
];
无法初始化chooseImage、showImage、startUpload。我已尝试启动上述步骤。显示错误
在初始化器中只能访问静态成员
解决方案
如果您创建了一个函数,则 chooseImage 和 startUpload 不是函数
void chooseImage() {
// add image picking code here
}
那么你需要改变
onPressed: chooseImage,
至
onPressed: chooseImage(),
如果你没有做这些功能,你也可以做
onPressed: () {
// add image picking code here
}
推荐阅读
- javascript - Angular-Cli 在应用程序开发期间为实时重新加载设置默认路径
- highcharts - Highchart Scatter plot with 2 series,工具提示刷新命令给出错误
- react-native - 如何在tcomb中输入按钮反应原生
- php - 使用正则表达式计算具有某些内容的 php 脚本
- reactjs - 没有为 antd 菜单选项加载 CSS
- ruby-on-rails - Ruby 将参数传递给构造函数,使其行为类似于动态方法
- reporting-services - 如何设置不同的 SSRS 图表图例文本颜色
- javascript - 使用 FileReader 的 onload 函数的返回值
- sql - 如何在一列下获得一个月中的天数,并在不同列中显示不同的月份
- java - 在 Windows 上运行 JavaFX 应用程序时出错