我有一个通用的功能:
ValueType get<ValueType>(String keyToRead) {
try {
return _dataClient.get(keyToRead) as ValueType;
} on SocketException catch (error) {...我这样叫它:
@override
Map<String, dynamic> getUserRegistration() {
return dataClient.get<Map<String, dynamic>>(UserRegistrationFieldKeys.self);
}但是,由于我从_dataClient的_dataClient框变成了蜂巢框,所以我得到了以下错误:
The following ProviderException was thrown building LoggedOutPageView(dirty, dependencies: [UncontrolledProviderScope], state: _ConsumerState#6c90b):
An exception was thrown while building AutoDisposeProvider<RegisterViewModel>#00006().
Thrown exception:
type '_InternalLinkedHashMap<dynamic, dynamic>' is not a subtype of type 'Map<String, dynamic>' in type cast
Stack trace:
#0 LocalDataClient.get
package:vepo/…/data_clients/local_data_client.dart:51
#1 UserRegistrationLocalDataSource.getUserRegistration
package:vepo/…/user_registration/user_registration_local_data_source.dart:22
#2 UserRegistrationRepository.getUserRegistration
package:vepo/…/user-registration/user_registration_repository.dart:31由于加密,Hive必须将数据存储为不同的格式,但我如何解释这一点并消除此错误呢?
发布于 2020-12-25 05:21:13
试着使用
Map<String, dynamic>.from(dataClient.get(UserRegistrationFieldKeys.self))`;如果使用此方法,也可以删除泛型函数。
https://stackoverflow.com/questions/65444862
复制相似问题