当我尝试使用 这里有一个网络上的例子 Hive.box('box_name').listenable(),没有键就出现了错误。
════════ Exception caught by widgets library ═══════════════════════════════════
The following NoSuchMethodError was thrown building FutureBuilder<dynamic>(dirty, state: _FutureBuilderState<dynamic>#566bb):
The method 'toSet' was called on null.
Receiver: null
Tried calling: toSet()
The relevant error-causing widget was
FutureBuilder<dynamic>
package:hive_benchmark/sketcpad/sketchpad.dart:109
When the exception was thrown, this was the stack
#0 Object.noSuchMethod (dart:core-patch/object_patch.dart:53:5)
#1 BoxX.listenable
package:hive_flutter/src/box_extensions.dart:11
#2 _DrawingScreenState.build.<anonymous closure>
package:hive_benchmark/sketcpad/sketchpad.dart:120
#3 _FutureBuilderState.build
package:flutter/…/widgets/async.dart:732
#4 StatefulElement.build
package:flutter/…/widgets/framework.dart:4619
...
════════════════════════════════════════════════════════════════════════════════
这个问题已经解决了,因为 hive_flutter: ^0.3.0+2
只是升级依赖性