mirror of
https://github.com/cake-tech/cake_wallet.git
synced 2025-06-28 20:39:51 +00:00
fix: Flutter error when running tests with Flutter drive
This commit is contained in:
parent
5060cbe55e
commit
85f8ebbfef
2 changed files with 27 additions and 1 deletions
|
@ -23,6 +23,7 @@ import 'package:cake_wallet/routes.dart';
|
|||
import 'package:cake_wallet/src/screens/root/root.dart';
|
||||
import 'package:cake_wallet/store/app_store.dart';
|
||||
import 'package:cake_wallet/store/authentication_store.dart';
|
||||
import 'package:cake_wallet/test_asset_bundles.dart';
|
||||
import 'package:cake_wallet/themes/theme_base.dart';
|
||||
import 'package:cake_wallet/utils/device_info.dart';
|
||||
import 'package:cake_wallet/utils/exception_handler.dart';
|
||||
|
@ -80,8 +81,18 @@ Future<void> runAppWithZone({Key? topLevelKey}) async {
|
|||
ledgerFile.writeAsStringSync("$content\n${event.message}");
|
||||
});
|
||||
}
|
||||
// Basically when we're running a test
|
||||
if (topLevelKey != null) {
|
||||
runApp(
|
||||
DefaultAssetBundle(
|
||||
bundle: TestAssetBundle(),
|
||||
child: App(key: topLevelKey),
|
||||
),
|
||||
);
|
||||
} else {
|
||||
runApp(App(key: topLevelKey));
|
||||
}
|
||||
|
||||
runApp(App(key: topLevelKey));
|
||||
isAppRunning = true;
|
||||
}, (error, stackTrace) async {
|
||||
if (!isAppRunning) {
|
||||
|
|
15
lib/test_asset_bundles.dart
Normal file
15
lib/test_asset_bundles.dart
Normal file
|
@ -0,0 +1,15 @@
|
|||
import 'dart:convert';
|
||||
|
||||
import 'package:flutter/services.dart';
|
||||
|
||||
class TestAssetBundle extends CachingAssetBundle {
|
||||
@override
|
||||
Future<String> loadString(String key, {bool cache = true}) async {
|
||||
final ByteData data = await load(key);
|
||||
|
||||
return utf8.decode(data.buffer.asUint8List());
|
||||
}
|
||||
|
||||
@override
|
||||
Future<ByteData> load(String key) async => rootBundle.load(key);
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue