Flutter 如何向下遍历并显示Firebase存储中每个目录中的所有文件?

Flutter 如何向下遍历并显示Firebase存储中每个目录中的所有文件?,flutter,firebase-storage,Flutter,Firebase Storage,如何为firebase创建类似于UI的文件浏览器?我尝试使用listAll()并在用户单击目录时再次调用listAll(),但它没有刷新视图 我还尝试递归调用当用户单击目录时构建ListView小部件的函数,但是它只显示存储的根级别,当我单击目录时它不会更新视图 我还尝试将引用存储在类对象中并调用setState(),但它也没有更新视图。我做错了什么?感谢您的帮助 Widget showDirectories(firebase_storage.ListResult directories) {

如何为firebase创建类似于UI的文件浏览器?我尝试使用listAll()并在用户单击目录时再次调用listAll(),但它没有刷新视图

我还尝试递归调用当用户单击目录时构建ListView小部件的函数,但是它只显示存储的根级别,当我单击目录时它不会更新视图

我还尝试将引用存储在类对象中并调用setState(),但它也没有更新视图。我做错了什么?感谢您的帮助

Widget showDirectories(firebase_storage.ListResult directories) {
    List<firebase_storage.Reference> directoryList = directories.prefixes;
    List<firebase_storage.Reference> items = directories.items;
    return Column(
      children: <Widget>[
        ListView.builder(
          shrinkWrap: true,
          itemCount: directoryList.length,
          itemBuilder: (BuildContext context, int index) {
            return Card(
              child: ListTile(
                title: Text(directoryList[index].name),
                subtitle: Text(directoryList[index].fullPath),
                onTap: () async {
                  //open the directory and get the list of items in there
                  firebase_storage.ListResult subDirectory =
                      await directoryList[index]
                          .listAll();
                  return showDirectories(subDirectory);
                },
              ),
            );
          },
        ),
小部件显示目录(firebase_storage.ListResult目录){
List directoryList=directories.prefixes;
列表项=目录.items;
返回列(
儿童:[
ListView.builder(
收缩膜:对,
itemCount:directoryList.length,
itemBuilder:(构建上下文,int索引){
回程卡(
孩子:ListTile(
标题:文本(目录列表[index].name),
字幕:文本(目录列表[index].fullPath),
onTap:()异步{
//打开目录并获取其中的项目列表
firebase_storage.ListResult子目录=
等待目录列表[索引]
.listAll();
返回显示目录(子目录);
},
),
);
},
),
============其他版本=========

  Widget showDirectories() {
    List<firebase_storage.Reference> directoryList = head.prefixes;
    List<firebase_storage.Reference> items = head.items;
    return Column(
      children: <Widget>[
        ListView.builder(
          shrinkWrap: true,
          itemCount: directoryList.length,
          itemBuilder: (BuildContext context, int index) {
            return Card(
              child: ListTile(
                title: Text(directoryList[index].name),
                subtitle: Text(directoryList[index].fullPath),
                onTap: () async {
                  //open the directory and get the list of items in there
                  firebase_storage.ListResult subDirectory =
                      await directoryList[index].listAll();
                  setState(() {
                    head = subDirectory;
                  });
                },
              ),
            );
          },
        ),
Widget showDirectories(){
List directoryList=head.prefixes;
列表项目=head.items;
返回列(
儿童:[
ListView.builder(
收缩膜:对,
itemCount:directoryList.length,
itemBuilder:(构建上下文,int索引){
回程卡(
孩子:ListTile(
标题:文本(目录列表[index].name),
字幕:文本(目录列表[index].fullPath),
onTap:()异步{
//打开目录并获取其中的项目列表
firebase_storage.ListResult子目录=
等待目录列表[index].listAll();
设置状态(){
head=子目录;
});
},
),
);
},
),

我遵循了

中的文档,您必须创建单独的屏幕,一个用于所有目录的列表,另一个用于显示其中的数据。屏幕的数量取决于数据的深度。