You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm trying to access the root folder name which is '/storage/emulated/0' but the foldername field in json array for is null and the following error was thrown:
════════ Exception caught by widgets library ═══════════════════════════════════════════════════════
The following assertion was thrown building Builder(dirty): A non-null String must be provided to a Text widget.
'package:flutter/src/widgets/text.dart':
Failed assertion: line 360 pos 10: 'data != null'
The relevant error-causing widget was:
Builder file:///C:/Users/Aatif/AndroidStudioProjects/gallery_app/lib/main.dart:59:32
When the exception was thrown, this was the stack: #2 new Text (package:flutter/src/widgets/text.dart:360:10) #3 _HomeState.build.. (package:gallery_app/main.dart:66:36) #4 Builder.build (package:flutter/src/widgets/basic.dart:7166:48) #5 StatelessElement.build (package:flutter/src/widgets/framework.dart:4631:28) #6 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4557:15)
...
I've filtered the list of images which are in root folder and added folderName
_imagesPath = await StoragePath.imagesPath;
//images list with files and folder name
var imagesList = jsonDecode(_imagesPath) as List;
//root folderName handling********************
Map<String,dynamic> rootObject = {'files':[],'folderName':'0'};
for(Map<String,dynamic> a in imagesList){
if (a['folderName']==null){
a['folderName'] = '0';
rootObject['files']=rootObject['files']+a['files'];
}
}
imagesList.removeWhere((element) => element['folderName']=='0');
imagesList.insert(0,rootObject);
//***********************
I'm trying to access the root folder name which is '/storage/emulated/0' but the foldername field in json array for is null and the following error was thrown:
════════ Exception caught by widgets library ═══════════════════════════════════════════════════════
The following assertion was thrown building Builder(dirty):
A non-null String must be provided to a Text widget.
'package:flutter/src/widgets/text.dart':
Failed assertion: line 360 pos 10: 'data != null'
The relevant error-causing widget was:
Builder file:///C:/Users/Aatif/AndroidStudioProjects/gallery_app/lib/main.dart:59:32
When the exception was thrown, this was the stack:
#2 new Text (package:flutter/src/widgets/text.dart:360:10)
#3 _HomeState.build.. (package:gallery_app/main.dart:66:36)
#4 Builder.build (package:flutter/src/widgets/basic.dart:7166:48)
#5 StatelessElement.build (package:flutter/src/widgets/framework.dart:4631:28)
#6 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4557:15)
...
JSON array:
**_{files: [/storage/emulated/0/IMG_20160709_181323981.jpg]}, {files: [/storage/emulated/0/IMG_20160709_174128028.jpg]}_**, {files: [/storage/emulated/0/timetable/IMG-20200107-WA0002.jpg], folderName: timetable}, {files: [/storage/emulated/0/Fake Tweets/Image-6156.jpg, /storage/emulated/0/Fake Tweets/Image-3012.jpg, /storage/emulated/0/Fake Tweets/IMG_20180703_141329.jpg], folderName: Fake Tweets},
as you can see there's no folderName field.
The text was updated successfully, but these errors were encountered: