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

feat(device_info_plus): LinuxDeviceInfo toString method #2652

Conversation

defuncart
Copy link
Contributor

Description

Adds toString for LinuxDeviceInfo. This is useful when debugging apps on Linux distros.

Related Issues

N/A

Checklist

  • I read the Contributor Guide and followed the process outlined there for submitting PRs.
  • I titled the PR using Conventional Commits.
  • I did not modify the CHANGELOG.md nor the plugin version in pubspec.yaml files.
  • All existing and new tests are passing.
  • The analyzer (flutter analyze) does not report any problems on my PR.

Breaking Change

Does your PR require plugin users to manually update their apps to accommodate your change?

  • Yes, this is a breaking change (please indicate that with a ! in the title as explained in Conventional Commits).
  • No, this is not a breaking change.

@defuncart defuncart changed the title chore(device_info_plus) LinuxDeviceInfo toString chore: device_info_plus LinuxDeviceInfo toString Mar 2, 2024
Copy link
Member

@miquelbeltran miquelbeltran left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the contribution, and including a test as well!

I'd prefer if the long string could be split into several lines or a multiline string, as it will be easier to extend and review changes in the future.

Can you take a look at the Flutter analyze issues as well?

@miquelbeltran miquelbeltran changed the title chore: device_info_plus LinuxDeviceInfo toString feat(device_info_plus): LinuxDeviceInfo toString method Mar 2, 2024
@defuncart
Copy link
Contributor Author

I'd prefer if the long string could be split into several lines or a multiline string, as it will be easier to extend and review changes in the future.

The method was generated by dart-data-class-generator and uses a standard format. How would you like it to be multi-line? Code of the form

    return '''LinuxDeviceInfo(
name: $name,
version: $version,
id: $id, 
idLike: $idLike, 
versionCodename: $versionCodename, 
versionId: $versionId, 
prettyName: $prettyName, 
buildId: $buildId, 
variant: $variant, 
variantId: $variantId, 
machineId: $machineId
)''';

would return a multi-line string, not a single line as expected in toString. To improve extensibility, StringBuffer could be considered, or alternatively data could be used as follows

String toString() => 'LinuxDeviceInfo(${data.toString().replaceAll('}', '').replaceAll('{', '')})';

Can you take a look at the Flutter analyze issues as well?

Done.

@defuncart defuncart force-pushed the chore/device-info-plus-linux-device-info-toString branch from 09b2896 to d7520d0 Compare March 2, 2024 12:04
@defuncart defuncart requested a review from miquelbeltran March 2, 2024 12:04
@miquelbeltran
Copy link
Member

That's right, I was thinking on a different approach, but since we already do similar toString methods in other parts of the projects, I guess that would be fine as well:

@defuncart
Copy link
Contributor Author

@miquelbeltran Seems the pipeline needs to be re-run, android integration test is failing & I cannot manually re-run. Probably a flaky issue as PR does not touch any android code.

@miquelbeltran
Copy link
Member

That's fine, no worries, the android_integration_test (22) is indeed flaky

@miquelbeltran miquelbeltran merged commit f2fbcdb into fluttercommunity:main Mar 3, 2024
18 of 19 checks passed
@defuncart defuncart deleted the chore/device-info-plus-linux-device-info-toString branch March 3, 2024 17:39
suquant pushed a commit to suquant/plus_plugins that referenced this pull request Mar 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants