I have a flutter app, and in one screen, I'm getting content from storage and firestore. With this code I'm able to see a list of links from firestore
myScreen.dart
//I have another method similar to this to show the content inside folders (read below)
loadBasicStructure(submenu ,callback, context){
return FutureBuilder(
future: ctrl.loadMain(submenu),
builder: (ctx, snapshot) {
if (snapshot.connectionState == ConnectionState.waiting) {
return Center(child: CircularProgressIndicator());
} else if (snapshot.error != null) {
print(snapshot.error);
return Center(child: Text('Error'));
} else {
return ListView.separated(
separatorBuilder: (context, index) {
return Divider();
},
itemCount: snapshot.data.length,
itemBuilder: (ctx, i) {
ItemLab item = snapshot.data[i];
print(item);
return ListTile(
leading: setIconLab(item),
title: Text(setText(item)),
trailing: Icon(Icons.chevron_right),
onTap: () async {
//mycode
}
},
);
},
);
}
},
);
}
controller.dart
Future<List<ItemLab>> loadLab(String submenu) async {
var snapshot = await _storage.ref().child(submenu);
var ret = await snapshot.listAll();
List<ItemLab> content = [];
ret.prefixes.forEach((element) {
content add(
Item(
type: 'FOLDER',
elemento: element,
),
);
});
ret.items.forEach((element) {
print(element);
conteudo.add(
ItemLab(
type: 'FILE',
element: element,
),
);
});
try{
await databaseReference
.collection("${submenu}_url")
.get()
.then((snapshot) {
snapshot.docs.forEach((f) async => {
f.data().isNotEmpty ?
content.add(
Item(
type: 'VIDEO',
element: null,
video: f.data(),
),
)
:
null
});
});
await databaseReference
.collection("${submenu}_url")
.doc("Folder")
.collection("RESET")
.get()
.then((snap){
snap.docs.isNotEmpty ? conteudo.add(
Item(
type: FOLDER',
folderVideo: "RESET"
),
) : null;
});
}catch(e){
print(e);
}
return Future.value(content);
}
How this code works:
I have a screen with a list of submenus EX ("submenu1, submenu2"). Inside it I check in storage if in that folder ("submenu1") it has some files and if yes I show in a list, if has not I check if there are folders inside this one ("submenu1 > RESET"). If it exists I show the folder.
I do this exact check too in firestore (because there I store some links from youtube). In this case the error is throwing because I have another screen with only items from firestore (and with the same structure) and it works normally, but in the submenu "photos" when I click in the folder "RESET" the app crashes and show this error:
2021-02-01 09:28:22.129581-0300 Runner[391:22847] An error occurred while parsing query arguments, this is most likely an error with this SDK. (
0 CoreFoundation 0x0000000189afb9ec F3021642-E3C0-33F8-9911-DD303A6056D0 + 1157612
1 libobjc.A.dylib 0x000000019de81b54 objc_exception_throw + 56
2 Runner 0x00000001023cddf0 _ZN8firebase9firestore4util16ObjcThrowHandlerENS1_13ExceptionTypeEPKcS4_iRKNSt3__112basic_stringIcNS5_11char_traitsIcEENS5_9allocatorIcEEEE + 304
3 Runner 0x00000001023cd90c _ZN8firebase9firestore4util5ThrowENS1_13ExceptionTypeEPKcS4_iRKNSt3__112basic_stringIcNS5_11char_traitsIcEENS5_9allocatorIcEEEE + 20
4 Runner 0x00000001023dfcf8 _ZN8firebase9firestore4util20ThrowInvalidArgumentIJNSt3__112basic_stringIcNS3_11char_traitsIcEENS3_9allocatorIcEEEEmEEEvPKcDpRKT_ + 48
5 Runner 0x00000001023b8238 _ZN8firebase9firestore3api19CollectionReferenceC2ENS0_5model12ResourcePathENSt3__110shared_ptrINS1_9FirestoreEEE + 716
6 Runner 0x00000001023e6684 _ZN8firebase9firestore3api9Firestore13GetCollectionERKNSt3__112basic_stringIcNS3_11char_traitsIcEENS3_9allocatorIcEEEE + 104
7 Runner 0x00000001023fc0a4 -[FIRFirestore collectionWithPath:] + 112
8 Runner 0x00000001025319b4 -[FLTFirebaseFirestoreReader FIRQuery] + 344
9 Runner 0x0000000102531428 -[FLTFirebaseFirestoreReader readValueOfType:] + 1272
10 Flutter 0x0000000103914130 Flutter + 5685552
11 Runner 0x0000000102530fdc -[FLTFirebaseFirestoreReader readValueOfType:] + 172
12 Flutter 0x000000010391564c Flutter + 5690956
13 Flutter 0x00000001039121dc Flutter + 5677532
14 Flutter 0x00000001033d9f9c Flutter + 204700
15 Flutter 0x00000001036b1d88 Flutter + 3186056
16 Flutter 0x00000001033e342c Flutter + 242732
17 Flutter 0x00000001033e53a0 Flutter + 250784
18 CoreFoundation 0x0000000189a7c3e0 F3021642-E3C0-33F8-9911-DD303A6056D0 + 635872
19 CoreFoundation 0x0000000189a7bfe4 F3021642-E3C0-33F8-9911-DD303A6056D0 + 634852
20 CoreFoundation 0x0000000189a7b4c4 F3021642-E3C0-33F8-9911-DD303A6056D0 + 632004
21 CoreFoundation 0x0000000189a75850 F3021642-E3C0-33F8-9911-DD303A6056D0 + 608336
22 CoreFoundation 0x0000000189a74ba0 CFRunLoopRunSpecific + 572
23 GraphicsServices 0x00000001a07dd598 GSEventRunModal + 160
24 UIKitCore 0x000000018c3662f4 CC6E5AC7-8248-35F6-8B42-2E25C93DCF0A + 11723508
25 UIKitCore 0x000000018c36b874 UIApplicationMain + 164
26 Runner 0x000000010239af80 main + 64
27 libdyld.dylib 0x0000000189753568 0B475C78-3C12-3121-B7F8-2B95B83DAF44 + 5480
)
2021-02-01 09:28:22.130980-0300 Runner[391:22847] -[NSNull getDocumentsWithSource:completion:]: unrecognized selector sent to instance 0x1d9269ee0
2021-02-01 09:28:22.132261-0300 Runner[391:22847] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[NSNull getDocumentsWithSource:completion:]: unrecognized selector sent to instance 0x1d9269ee0'
*** First throw call stack:
(0x189afb9d8 0x19de81b54 0x189a0bbbc 0x189afe01c 0x189afff8c 0x102530514 0x10252e9d0 0x103912224 0x1033d9f9c 0x1036b1d88 0x1033e342c 0x1033e53a0 0x189a7c3e0 0x189a7bfe4 0x189a7b4c4 0x189a75850 0x189a74ba0 0x1a07dd598 0x18c3662f4 0x18c36b874 0x10239af80 0x189753568)
libc++abi.dylib: terminating with uncaught exception of type NSException
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[NSNull getDocumentsWithSource:completion:]: unrecognized selector sent to instance 0x1d9269ee0'
terminating with uncaught exception of type NSException
I expect that when I tap in the folder inside submenu, it opens a list of links (like it do in the other submenu that only have storage files
I don't know if i'm being clear, if there are a question, tell me
I had a similar problem, just drop the part you get content from firestore and see if it works... if yes, put it back. For some reason it might work
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments