老师您好,6-9的登录DEMO在安卓模拟器中运行正常,但是在Chrome浏览器中运行时,页面加载后会报出以下异常,而且似乎无法从HiCache中取值(返回null),请问web应用使用本地存储需要额外操作,还是暂时不能使用HiCache操作本地存储?
以下是main方法
class MyApp extends StatelessWidget {
const MyApp({super.key});
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Login Demo',
theme: ThemeData(
useMaterial3: true,
primarySwatch: Colors.blue,
),
home: FutureBuilder<dynamic>(
future: HiCache.preInit(),
builder: (context, AsyncSnapshot<dynamic> snapshot) {
if (snapshot.connectionState == ConnectionState.done) {
//获取登录的token
if (LoginDao.getFromSp() == null) {
return const LoginPage();
} else {
return const HomePage();
}
} else {
return const Scaffold(
body: Center(
child: CircularProgressIndicator(),
),
);
}
}));
}
}
这个是异常抛出的地方:
以下是控制台输出:
Waiting for connection from debug service on Chrome...
This app is linked to the debug service: ws://127.0.0.1:55202/6JB9tWtoPmQ=/ws
Debug service listening on ws://127.0.0.1:55202/6JB9tWtoPmQ=/ws
Debug service listening on ws://127.0.0.1:55202/6JB9tWtoPmQ=/ws
Error
dart-sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/errors.dart 297:3 throw_
packages/shared_preferences_platform_interface/shared_preferences_platform_interface.dart 100:5 getAllWithParameters
packages/shared_preferences_web/shared_preferences_web.dart 54:12 getAll
dart-sdk/lib/_internal/js_dev_runtime/patch/async_patch.dart 84:54 runBody
dart-sdk/lib/_internal/js_dev_runtime/patch/async_patch.dart 127:5 _async
packages/shared_preferences_web/shared_preferences_web.dart 53:37 getAll
packages/shared_preferences/shared_preferences.dart 255:38 _getSharedPreferencesMap
dart-sdk/lib/_internal/js_dev_runtime/patch/async_patch.dart 84:54 runBody
dart-sdk/lib/_internal/js_dev_runtime/patch/async_patch.dart 127:5 _async
packages/shared_preferences/shared_preferences.dart 229:62 _getSharedPreferencesMap
packages/shared_preferences/shared_preferences.dart 78:19 getInstance
dart-sdk/lib/_internal/js_dev_runtime/patch/async_patch.dart 84:54 runBody
dart-sdk/lib/_internal/js_dev_runtime/patch/async_patch.dart 127:5 _async
packages/shared_preferences/shared_preferences.dart 71:47 getInstance
packages/flutter_hi_cache/flutter_hi_cache.dart 30:39 init
dart-sdk/lib/_internal/js_dev_runtime/patch/async_patch.dart 84:54 runBody
dart-sdk/lib/_internal/js_dev_runtime/patch/async_patch.dart 127:5 _async
packages/flutter_hi_cache/flutter_hi_cache.dart 29:12 init
packages/flutter_hi_cache/flutter_hi_cache.dart 8:5 __
packages/flutter_hi_cache/flutter_hi_cache.dart 25:27 getInstance
packages/my_flutter_test/third/dao/login_dao.dart 44:34 getFromSp
packages/my_flutter_test/third/main.dart 29:42 <fn>
packages/flutter/src/widgets/async.dart 609:48 build
packages/flutter/src/widgets/framework.dart 5592:27 build
packages/flutter/src/widgets/framework.dart 5480:15 performRebuild
packages/flutter/src/widgets/framework.dart 5643:11 performRebuild
packages/flutter/src/widgets/framework.dart 5196:7 rebuild
packages/flutter/src/widgets/framework.dart 2904:18 buildScope
packages/flutter/src/widgets/binding.dart 989:9 drawFrame
packages/flutter/src/rendering/binding.dart 448:5 [_handlePersistentFrameCallback]
packages/flutter/src/scheduler/binding.dart 1386:7 [_invokeFrameCallback]
packages/flutter/src/scheduler/binding.dart 1311:9 handleDrawFrame
packages/flutter/src/scheduler/binding.dart 1034:7 <fn>
dart-sdk/lib/_internal/js_dev_runtime/private/isolate_helper.dart 48:11 internalCallback