[英]Flutter get image from firebase storage and show it in app for download
我正在尝试从 firebase 存储(firebase firestore 中的 url)获取图像,并像过滤器一样在我的应用程序中显示它。
我的代码(它不起作用):
import 'package:cloud_firestore/cloud_firestore.dart';
import 'package:flutter/material.dart';
import 'package:pap_test/upload/upload_resumos_screen.dart';
class DownloadScreen extends StatefulWidget {
const DownloadScreen({Key? key}) : super(key: key);
static const routeName = '/downlaod-resumos';
@override
State<DownloadScreen> createState() => _DownloadScreenState();
}
class _DownloadScreenState extends State<DownloadScreen> {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('Resumos'),
),
body: StreamBuilder(
stream: FirebaseFirestore.instance.collection('courses').snapshots(),
builder: (context, AsyncSnapshot snapshot) {
return ListView.builder(
itemCount: snapshot.data.documents.length,
itemBuilder: (context, index) {
DocumentSnapshot image = snapshot.data!.documents[index];
return ListTile(
leading: Image.network(
image['disciplina'],
),
title: Text(image['modulo']),
subtitle: Text('11'),
);
},
);
},
),
floatingActionButton: FloatingActionButton(
onPressed: () {
// Add your onPressed code here!
Navigator.of(context).pushNamed(UploadResumoScreen.routeName);
},
backgroundColor: Color.fromARGB(255, 28, 209, 216),
child: const Icon(Icons.add),
),
);
}
}
我为每个图像创建了一个文档,在文档中我保存了 disciplina 和模数(我试图过滤的东西),以及 url 转到存储在存储中的图像。
我想像列表视图一样展示它们
我如何从 firebase 存储和 firebase firestore 中的 url 中获取图像并使用过滤器在我的应用程序中显示?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.