-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Description
Platform
ios
Plugin
device_info_plus
Version
11.4.0 through 12.3.0 (latest)
Flutter SDK
3.38.5
Steps to reproduce
Description:
After upgrading from device_info_plus: 11.3.3 to any version >= 11.4.0, calling deviceInfo.iosInfo crashes on iOS Simulator with:
type 'Null' is not a subtype of type 'int'
Root cause:
The physicalRamSize property was introduced in version 11.4.0 (changelog: "Introduced RAM information feature"). On iOS Simulator, this property returns null from the platform channel, but the Dart class expects a non-nullable int, causing deserialization to fail.
Steps to reproduce:
- Create a new Flutter project
- Add device_info_plus: ^12.3.0 to pubspec.yaml
- Run on iOS Simulator
- Call:
final deviceInfo = DeviceInfoPlugin();
final iosInfo = await deviceInfo.iosInfo; // CRASHES HERE
print(iosInfo.isPhysicalDevice);
Expected behavior:
iosInfo should be returned successfully, with physicalRamSize either being nullable (int?) or defaulting to 0 on simulator.
Actual behavior:
Crash during deserialization before any property can be accessed.
Workaround:
Pin to version 11.3.3:
device_info_plus: 11.3.3
Suggested fix:
Make physicalRamSize nullable (int?) or handle null from platform channel with a default value (0) for iOS Simulator.
Code Sample
Logs
n/aFlutter Doctor
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 3.38.5, on macOS 15.7.2 24G325 darwin-x64, locale en-CA)
[✓] Android toolchain - develop for Android devices (Android SDK version 36.1.0)
[✓] Xcode - develop for iOS and macOS (Xcode 16.4)
[✓] Chrome - develop for the web
[✓] Connected device (4 available)
[✓] Network resources
• No issues found!Checklist before submitting a bug
- I searched issues in this repository and couldn't find such bug/problem
- I Google'd a solution and I couldn't find it
- I searched on StackOverflow for a solution and I couldn't find it
- I read the README.md file of the plugin
- I'm using the latest version of the plugin
- All dependencies are up to date with
flutter pub upgrade - I did a
flutter clean - I tried running the example project