plus_plugins icon indicating copy to clipboard operation
plus_plugins copied to clipboard

deviceInfoPlugin.androidInfo.version.toString() does not return a useful string

Open ooglek opened this issue 2 months ago • 0 comments

https://github.com/fluttercommunity/plus_plugins/blob/61786a1d680d8c3886b4fceb34d689ec94e10d8a/packages/device_info_plus/device_info_plus/lib/src/model/android_device_info.dart#L346

I'm getting the value of Instance of 'AndroidBuildVersion' when I call deviceInfoPlugin.androidInfo.version.toString()

The documentation seems to imply that I might get something useful out of version.toString()

https://pub.dev/documentation/device_info_plus/latest/device_info_plus/AndroidBuildVersion-class.html

I realize the Object class just inherits the default behavior of toString() and just outputs the standard instance.

I think an override here would be quite useful.

This is what I'll be implementing in my code... it'd be useful for Android IMHO! :-)

@override
String toString() {
  var output = '';
  if (![null, ''].contains(baseOS)) {
    output += baseOS;
  }
  output += release;
  if (![null, ''].contains(securityPatch)) {
	output += ' ' + securityPatch;
  }
  output += ' ($sdkInt, $incremental)';
  return output;
}

ooglek avatar Nov 07 '25 22:11 ooglek