小编nei*_*aro的帖子

Flutter:使用隔离运行函数时,在二进制信使初始化之前无法使用此 MethodChannel

我正在尝试在 Flutter 应用程序中使用隔离和 Bloc 作为状态管理解决方案。现在,我在运行wallet_list.dart.

// wallet_list.dart
final FlutterSecureStorage _storage = const FlutterSecureStorage();

FutureOr<List<alan.Wallet>> getWalletList(int value) async {
  Map<String, String> allValues = await _storage.readAll();
  final List<alan.Wallet> _walletList = [];

  allValues.forEach((key, value) {
    if (key.startsWith(WalletOverviewHomeScreen.walletKey)) {
      final arrMnemonic = value.split(' ');
      final _wallet = alan.Wallet.derive(arrMnemonic, certikNetworkInfo);
      // debugPrint('Adding wallet: $_wallet');
      _walletList.add(_wallet);
    }
  });
Run Code Online (Sandbox Code Playgroud)

以下函数用于 cubit 类中的方法之一WalletInitializationCubit

// inside WalletInitializationCubit
Future<void> getWalletListAndDefaultWallet() async {
    try {
      debugPrint('WalletListInitialization');
      emit(WalletInitializationLoading());
      final List<alan.Wallet> walletList = await compute(
        getWalletList,
        1
      );

      // …
Run Code Online (Sandbox Code Playgroud)

concurrency dart dart-isolates flutter bloc

5
推荐指数
1
解决办法
5897
查看次数

标签 统计

bloc ×1

concurrency ×1

dart ×1

dart-isolates ×1

flutter ×1