首页 > 解决方案 > 如何在颤振的步骤方法中上传图像

问题描述

     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。我已尝试启动上述步骤。显示错误

在初始化器中只能访问静态成员

标签: flutterflutter-image

解决方案


如果您创建了一个函数,则 chooseImage 和 startUpload 不是函数

void chooseImage() {
 // add image picking code here
}

那么你需要改变

onPressed: chooseImage,

onPressed: chooseImage(),

如果你没有做这些功能,你也可以做

onPressed: () {
// add image picking code here
}

推荐阅读