1

I want to be able to track the number of files in the main directory and if possible the sub directory as well.

enter image description here

The below code builds more than I expect. I had the solution and actually don't know where the 'assestManifest.json' directory is but is kind of works but return is more than what I have in my directory. Printing the last index shows there is more files aside mine.

Please help me!

`

FutureBuilder<String>(
          future:
              DefaultAssetBundle.of(context).loadString('AssetManifest.json'),
          builder: (context, snapshot) {
            if (snapshot.hasData) {
              Map? jsonMap = json.decode(snapshot.data!);
              List? file = jsonMap?.keys.toList();
              print(file?[49]);
              return GridView.builder(
                physics: const NeverScrollableScrollPhysics(),
                padding: const EdgeInsets.symmetric(horizontal: 15),
                gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(
                  crossAxisCount: 5,
                  mainAxisSpacing: 1,
                  mainAxisExtent: 60,
                  crossAxisSpacing: 15,
                ),
                itemCount: file?.length,
                itemBuilder: (context, index) {
                  return Text(
                    '${index + 1}',
                    style: Theme.of(context).textTheme.headline2,
                  );
                },
              );
            }
            return Center(
              child: Text('Loading...'),
            );
          }),
   `
JustCode
  • 463
  • 2
  • 11

0 Answers0