Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: toMap is recommended in the documentation, but deprecated without an apparent replacement #1291

Closed
7 tasks done
BernieSumption opened this issue Oct 25, 2022 · 2 comments · Fixed by #1292
Closed
7 tasks done
Assignees
Labels
bug Something isn't working device_info_plus documentation Improvements or additions to documentation

Comments

@BernieSumption
Copy link

BernieSumption commented Oct 25, 2022

Platform

iOS 16

Plugin

device_info_plus

Version

7.0.1

Flutter SDK

3.3.4

Steps to reproduce

The documentation recommends that in order to get all available device information in a platform-agnostic way, the toMap() method should be used. This been deprecated with no apparent replacement.

I'm not sure if this is a bug report that the recommended method has been deprecated, or a feature request that a non-deprecated method be provided!

In any case, in the mean time I have downgraded to 6.0.0 so that I can use the toMap method without warnings.

Code Sample

final deviceInfoPlugin = DeviceInfoPlugin();
final deviceInfo = await deviceInfoPlugin.deviceInfo;
final allInfo = deviceInfo.toMap();

Logs

n/a - compile time error

Flutter Doctor

[✓] Flutter (Channel stable, 3.3.4, on macOS 12.5.1 21G83 darwin-arm, locale
    en-GB)
[✓] Android toolchain - develop for Android devices (Android SDK version 33.0.0)
[✓] Xcode - develop for iOS and macOS (Xcode 14.0.1)
[✓] Android Studio (version 2021.2)
[✓] VS Code (version 1.72.2)
[✓] Connected device (2 available)
[✓] HTTP Host Availability

• No issues found!

Checklist before submitting a bug

  • 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
@BernieSumption BernieSumption added bug Something isn't working triage labels Oct 25, 2022
@miquelbeltran
Copy link
Member

Should be removed from the documentation, then.

The problem with toMap is that it is not a JSON compatible object as it contains non-serializable data, being misleading to users, and that's why it is currently being deprecated.

The alternative is to read each value individually and build your own data class.

The device_info_plus package needs a deep refactor, so we cannot promise if the toMap is going to stay in the future, and we don't know yet what to do to replace it, that's why it is marked as deprecated and use at your own risk.

@miquelbeltran
Copy link
Member

FYI @BernieSumption the toMap() method is replaced by the data member of the BaseDeviceInfo class

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working device_info_plus documentation Improvements or additions to documentation
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants