During a widget test, I want to write to the dev environment file system, instead of writing to the device’s file system. (So, using dart.io instead of path_provider.)
For reason’s I don’t understand, the writeAsString function hangs. E.g., here’s a minimal example where execution hangs on the writeAsString
call and never reaches the debugPrint
line. The TestFile.txt
is created within the local test directory, but it is empty.
import 'dart:io';
import 'package:flutter/widgets.dart';
import 'package:flutter_test/flutter_test.dart';
void main() {
testWidgets('Try writing to dev system within test', (WidgetTester tester) async {
await tester.pumpWidget(const SizedBox.shrink());
await tester.pumpAndSettle();
final file = File('TestFile.txt');
await file.writeAsString('Some Text');
debugPrint('Test completed');
});
}