我有一个数组
// this does fetch the url of images stored in firebase fire store List imgList = [];
我有一个滑块,可以从数据库中显示我的图像,我也可以让用户添加更多图像和删除图像。所以我的问题是,有没有办法把这两者结合起来?来自firestore和一个数组中的设备的图像的url,例如imgList
。
这是我的旋转木马
final List<Widget> imageSliders = imgList .map((item) => Container( child: Container( margin: EdgeInsets.all(5.0), child: ClipRRect( borderRadius: BorderRadius.all(Radius.circular(5.0)), child: Stack( children: <Widget>[ Image.network(item, fit: BoxFit.cover, width: 1000.0), Positioned( bottom: 0.0, left: 0.0, right: 0.0, child: Container( decoration: BoxDecoration( gradient: LinearGradient( colors: [ Color.fromARGB(200, 0, 0, 0), Color.fromARGB(0, 0, 0, 0) ], begin: Alignment.bottomCenter, end: Alignment.topCenter, ), ), padding: EdgeInsets.symmetric( vertical: 10.0, horizontal: 20.0), child: Text( 'No. ${imgList.indexOf(item)} image', style: TextStyle( color: Colors.white, fontSize: 20.0, fontWeight: FontWeight.bold, ), ), ), ), ], )), ), )) .toList();
这是我的多选择器图像代码,我将新选择的图像直接附加到我检索firestore url照片的数组中。
Future selectMultipleImages() async { try { final List<XFile> selectedImages = await imagePicker.pickMultiImage(); if (selectedImages.isNotEmpty) { for (var element in selectedImages) { // this is where I add my newly selected multiple images fireStoreMultipleImage!.add(File(element.path)); } } setState(() {}); } on PlatformException catch (error) { print("error message of selectMultipleImages function: ${error.message}"); } }