【发布时间】:2019-08-10 02:43:55
【问题描述】:
我正在使用颤振的“image_picker”插件来拍照并在我的应用程序上显示。我的问题是我需要展示不止一张图片。因此,如果您拍摄第二张照片,它应该显示在前一张的旁边。
到目前为止,我已经尝试将我拍摄的图像保存到一个列表中,这样我就可以通过构建器中的“_imageList[index]”来显示它们
List<File> _imageList = [];
void _getImage(File _image) {
setState(() {
_imageList.add(_image);
});
}
@override
Widget build(BuildContext context) {
return new Scaffold(
backgroundColor: Theme.of(context).primaryColor,
body: ListView(
padding: EdgeInsets.only(top: 70.0),
children: [Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Container(
width: MediaQuery.of(context).size.width * 0.7,
child: TextField(
textAlign: TextAlign.center,
style: TextStyle(
color: Colors.white
),
decoration: InputDecoration(
hintText: "Ingrese título opcional",
hintStyle: TextStyle(color: Colors.red[200]),
enabledBorder: UnderlineInputBorder(
borderSide: BorderSide(color: Theme.of(context).accentColor)
),
focusedBorder: UnderlineInputBorder(
borderSide: BorderSide(color: Theme.of(context).accentColor)
),
)
),
)
],
),
Container(
padding: EdgeInsets.all(20.0),
child: ListView.builder(
itemCount: _imageList.length,
itemBuilder: (context, index) {
return Image.file(_imageList[index]);
},
),
),
],)]
,),
bottomNavigationBar: BottomAppBar(
child: Row(
mainAxisSize: MainAxisSize.max,
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: <Widget>[
IconButton(
icon: Icon(Icons.camera_alt),
color: Theme.of(context).primaryColor,
onPressed: () async {
File _image = await ImagePicker.pickImage(source: ImageSource.gallery);
_getImage(_image);
},
),
IconButton(
icon: Icon(Icons.videocam),
color: Theme.of(context).primaryColor,
onPressed: () {
},
),
IconButton(
icon: Icon(Icons.mic),
color: Theme.of(context).primaryColor,
onPressed: () {
},
),
IconButton(
icon: Icon(Icons.create),
color: Theme.of(context).primaryColor,
onPressed: () {
},
),
],
),
),
);
}
}
请帮忙,我真的不知道还能做什么
它没有显示错误,它让我拍照,但它们不显示
【问题讨论】: