You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit ea7e031
Browse filesBrowse the repository at this point in the historyBrowse files
[shared_preferences_android] Fix web compilation of apps that import the package (flutter#13380)
Since 2.5.0 (flutter/packages#12329), `package:shared_preferences_android/shared_preferences_android.dart` transitively imports `package:jni`, which needs `dart:ffi`. So any app that imports it fails to compile for web, even if it only uses `SharedPreferencesAsyncAndroidOptions` the way the `shared_preferences` README shows. This currently breaks `shared_preferences/example` in the web unit test shards on every Flutter roll PR:
```
jni-1.1.0/lib/src/jni.dart:5:8: Error: Dart library 'dart:ffi' is not available on this platform.
```
Example CI failures:
- https://ci.chromium.org/b/8667231073363438673
- https://ci.chromium.org/b/8667231073314809361
- https://ci.chromium.org/b/8667308711483341649
This uses the same approach as `path_provider_android`: the library exports a stub of the plugin classes when `dart.library.ffi` isn't available, and the option types move to their own file that doesn't depend on FFI. The package's own tests now import `src/shared_preferences_android_real.dart` directly, since the analyzer resolves the conditional export to the stub.
Test coverage comes from the existing `shared_preferences/example` web tests, which import this library and fail to compile without this change.
Copy file name to clipboardExpand all lines: packages/shared_preferences/shared_preferences_android/example/integration_test/shared_preferences_test.dart
0 commit comments