fetch static method

Future<DeviceInformation> fetch({
  1. String? deviceId,
  2. String? osName,
  3. String? osVersion,
  4. num? osVersionCode,
  5. String? softwareName,
  6. String? softwareVersion,
  7. String? applicationId,
  8. String? applicationType,
  9. String? applicationName,
  10. String? applicationVersion,
  11. String? applicationBuildCode,
  12. DeviceInformationDecorators? decorators,
})

Get basic client information

Optional parameters can overwrite the information if provided.

decorators is a set of decorators to decorate the information.(optional)

Implementation

static Future<DeviceInformation> fetch({
  String? deviceId,
  String? osName,
  String? osVersion,
  num? osVersionCode,
  String? softwareName,
  String? softwareVersion,
  String? applicationId,
  String? applicationType,
  String? applicationName,
  String? applicationVersion,
  String? applicationBuildCode,
  DeviceInformationDecorators? decorators,
}) async {
  DeviceInformation information;

  if (_isMockMode == true) {
    if (kDebugMode) {
      print('DeviceInformation Warning ! You\'re in test mode.');
    }
    information = _mockData;
  } else {
    var map = await _channel.invokeMethod('getInformation');
    information = map != null
        ? DeviceInformation._fromMap(Map<String, dynamic>.from(map))
        : DeviceInformation();
  }

  if (deviceId?.isNotEmpty ?? false) {
    information.deviceId = deviceId!;
  }
  if (osName?.isNotEmpty ?? false) {
    information.osName = osName!;
  }
  if (osVersion?.isNotEmpty ?? false) {
    information.osVersion = osVersion!;
  }
  if (osVersionCode != null) {
    information.osVersionCode = osVersionCode;
  }
  if (softwareName?.isNotEmpty ?? false) {
    information.softwareName = softwareName!;
  }
  if (softwareVersion?.isNotEmpty ?? false) {
    information.softwareVersion = softwareVersion!;
  }
  if (applicationId?.isNotEmpty ?? false) {
    information.applicationId = applicationId!;
  }
  if (applicationType?.isNotEmpty ?? false) {
    information.applicationType = applicationType!;
  }
  if (applicationName?.isNotEmpty ?? false) {
    information.applicationName = applicationName!;
  }
  if (applicationVersion?.isNotEmpty ?? false) {
    information.applicationVersion = applicationVersion!;
  }
  if (applicationBuildCode?.isNotEmpty ?? false) {
    information.applicationBuildCode = applicationBuildCode!;
  }

  return decorators != null
      ? _clientInfoDecorationHandler(information, decorators)
      : information;
}