=2.7.0 (-6ren">
gpt4 book ai didi

flutter - Firestore错误 'controller != null':不正确

转载 作者:行者123 更新时间:2023-12-03 03:13:56 25 4
gpt4 key购买 nike

每当我尝试查询时,都会收到此错误。而且此错误似乎是随机出现的,并非总是如此。
pubspec.yaml

version: 1.0.0+1

environment:
sdk: ">=2.7.0 <3.0.0"

dependencies:
flutter:
sdk: flutter
flutter_bloc: ^6.0.2
bloc: ^6.0.2
cloud_firestore: ^0.14.0+2
path_provider: ^1.6.14
cupertino_icons: ^0.1.3

dev_dependencies:
flutter_test:
sdk: flutter
flutter 医生v
[√] Flutter (Channel stable, 1.20.2, on Microsoft Windows [Version 10.0.19041.572], locale en-IN)
• Flutter version 1.20.2 at C:\src\flutter
• Framework revision bbfbf1770c (2 months ago), 2020-08-13 08:33:09 -0700
• Engine revision 9d5b21729f
• Dart version 2.9.1
[√] Android toolchain - develop for Android devices (Android SDK version 29.0.3)
• Android SDK at C:\Users\users\AppData\Local\Android\sdk
• Platform android-29, build-tools 29.0.3
• Java binary at: C:\Program Files\Android\Android Studio\jre\bin\java
• Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b01)
• All Android licenses accepted.

E/flutter (13433): [ERROR:flutter/lib/ui/ui_dart_state.cc(166)] Unhandled Exception: 'package:cloud_firestore_platform_interface/src/method_channel/method_channel_firestore.dart': Failed assertion: line 159 pos 12: 'controller != null': is not true.
E/flutter (13433): #0 _AssertionError._doThrowNew (dart:core-patch/errors_patch.dart:46:39)
E/flutter (13433): #1 _AssertionError._throwNew (dart:core-patch/errors_patch.dart:36:5)
E/flutter (13433): #2 MethodChannelFirebaseFirestore._handleError (package:cloud_firestore_platform_interface/src/method_channel/method_channel_firestore.dart:159:12)
E/flutter (13433): #3 MethodChannelFirebaseFirestore._handleQuerySnapshotError (package:cloud_firestore_platform_interface/src/method_channel/method_channel_firestore.dart:84:5)
E/flutter (13433): #4 MethodChannelFirebaseFirestore._handleQuerySnapshotEvent (package:cloud_firestore_platform_interface/src/method_channel/method_channel_firestore.dart:74:7)
E/flutter (13433): #5 new MethodChannelFirebaseFirestore.<anonymous closure> (package:cloud_firestore_platform_interface/src/method_channel/method_channel_firestore.dart:32:18)
E/flutter (13433): #6 MethodChannel._handleAsMethodCall (package:flutter/src/services/platform_channel.dart:432:55)
E/flutter (13433): #7 MethodChannel.setMethodCallHandler.<anonymous closure> (package:flutter/src/services/platform_channel.dart:385:33)
E/flutter (13433): #8 _DefaultBinaryMessenger.handlePlatformMessage (package:flutter/src/services/binding.dart:267:33)
E/flutter (13433): #9 _invoke3.<anonymous closure> (dart:ui/hooks.dart:282:15)
E/flutter (13433): #10 _rootRun (dart:async/zone.dart:1190:13)
E/flutter (13433): #11 _CustomZone.run (dart:async/zone.dart:1093:19)
E/flutter (13433): #12 _CustomZone.runGuarded (dart:async/zone.dart:997:7)
E/flutter (13433): #13 _invoke3 (dart:ui/hooks.dart:281:10)
E/flutter (13433): #14 _dispatchPlatformMessage (dart:ui/hooks.dart:156:5)
E/flutter (13433):
我的查询:
Stream<List<PostItem>> searchPosts({String searchTerm, String organisation}) {
print('function called');
if (organisation == null) {
print('running searches');
return _postsCollection
.where('description', isGreaterThanOrEqualTo: searchTerm)
.where('description', isLessThanOrEqualTo: '$searchTerm\uf8ff')
.snapshots()
.map(_getPostItem);
} else {
print('getting organisation posts');
return _postsCollection
.where('organisation', isEqualTo: organisation)
.snapshots()
.map(_getPostItem);
}
}
在这里,我尝试根据其中一个过滤帖子。 _getPostItem只是修改原始流。
任何帮助表示赞赏。谢谢。

最佳答案

升级Cloud Firestore套件

cloud_firestore: ^0.14.0+2
cloud_firestore: ^0.14.0+3
作为可接受的答案,升级软件包可以解决此问题。在 Github上,已经存在使用相同方法克服的相同问题。

关于flutter - Firestore错误 'controller != null':不正确,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64517313/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com