通过文件选择器Flutter显示文件名
我需要在按钮下显示添加的文件名。 我正在使用 file_picker 添加图像。添加图像后,我需要删除或替换图像。 之后,我需要将该图像发送到电子邮件。 我正在使用 EmailJS 提交表单。
Padding(
padding: EdgeInsets.fromLTRB(20, 10, 20, 10),
child: RaisedButton(
elevation: 0,
onPressed: () async{
final result = await FilePicker.platform.pickFiles();
if(result == null) return;
final file = result.files.first;
//openFile(file);
},
color: Colors.white,
shape: RoundedRectangleBorder(
side: BorderSide(
color: Colors.green,
width: 1),
borderRadius: BorderRadius.all(Radius.circular(0),
),
),
child: Padding(
padding: EdgeInsets.fromLTRB(10, 10, 10, 10),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
Text(
'Qatar ID',
style: TextStyle(
fontSize: 20,
fontWeight: FontWeight.normal,
color: Colors.green,
),
),
Icon(
Icons.upload_sharp,
color: Colors.green,
)
],
),
),
),
),
I need to display the added filename under the button.
I'm using file_picker to add the image. after adding the image I need to remove or replace the image.
after that, I need to send that image to email.
I'm using EmailJS to submit a form.
Padding(
padding: EdgeInsets.fromLTRB(20, 10, 20, 10),
child: RaisedButton(
elevation: 0,
onPressed: () async{
final result = await FilePicker.platform.pickFiles();
if(result == null) return;
final file = result.files.first;
//openFile(file);
},
color: Colors.white,
shape: RoundedRectangleBorder(
side: BorderSide(
color: Colors.green,
width: 1),
borderRadius: BorderRadius.all(Radius.circular(0),
),
),
child: Padding(
padding: EdgeInsets.fromLTRB(10, 10, 10, 10),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
Text(
'Qatar ID',
style: TextStyle(
fontSize: 20,
fontWeight: FontWeight.normal,
color: Colors.green,
),
),
Icon(
Icons.upload_sharp,
color: Colors.green,
)
],
),
),
),
),
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
请参考下面的代码:
Please refer to the below code: