initPlatformState method

Future<String?> initPlatformState()

Implementation

Future<String?> initPlatformState() async {
  // Platform messages may fail, so we use a try/catch PlatformException.
  try {
    // StringUtils.deviceId = await PlatformDeviceId.getDeviceId;
    final deviceInfoPlugin = DeviceInfoPlugin();
    final deviceInfo = await deviceInfoPlugin.deviceInfo;
    StringUtils.deviceId = deviceInfo.data["id"] ?? "";
  } on PlatformException {
    StringUtils.deviceId = 'Unknown';
  }

  return StringUtils.deviceId;
  // If the widget was removed from the tree while the asynchronous platform
  // message was in flight, we want to discard the reply rather than calling
  // setState to update our non-existent appearance.
}