[CP-beta]Configure FfiNative resolver on dart:io (#177308)

This pull request is created by [automatic cherry pick workflow](https://github.com/flutter/flutter/blob/main/docs/releases/Flutter-Cherrypick-Process.md#automatically-creates-a-cherry-pick-request)
Please fill in the form below, and a flutter domain expert will evaluate this cherry pick request.

### Issue Link:

None

### Changelog Description:

Calling `FileSystemEntity.watch(...)` will throw on Mac OS and Windows.

### Impact Description:

Calling `FileSystemEntity.watch(...)` will throw on Mac OS and Windows, instead of correctly watching the path.

### Workaround:

No user level work-around. `dart:io` is broken.

### Risk:

What is the risk level of this cherry-pick?

### Test Coverage:

Are you confident that your fix is well-tested by automated tests?

It's tested by tests in Dart SDK

### Validation Steps:

Run a Mac OS or Windows app with the following `main`. It should do nothing - rather than throw an exception.

```dart
import 'dart:async';
import 'dart:io';

void main() async {
  final sub = Directory.systemTemp.watch(recursive: true).listen((_) {});
  await Future.delayed(Duration(seconds: 1));
  sub.cancel();
}
```
This commit is contained in:
flutteractionsbot 2025-10-27 15:53:59 -07:00 committed by GitHub
parent 069ba6054d
commit 082bd44a7c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -17,10 +17,13 @@ namespace flutter {
void DartIO::InitForIsolate(bool may_insecurely_connect_to_all_domains,
const std::string& domain_network_policy) {
// TODO(https://dartbug.com/61694): move this code into dart_io_api.h
Dart_Handle io_lib = Dart_LookupLibrary(ToDart("dart:io"));
Dart_Handle result = Dart_SetNativeResolver(io_lib, dart::bin::LookupIONative,
dart::bin::LookupIONativeSymbol);
FML_CHECK(!CheckAndHandleError(result));
result = Dart_SetFfiNativeResolver(io_lib, dart::bin::LookupIOFfiNative);
FML_CHECK(!CheckAndHandleError(result));
Dart_Handle ui_lib = Dart_LookupLibrary(ToDart("dart:ui"));
Dart_Handle dart_validate_args[1];