getId method

  1. @override
Future<String> getId({
  1. AndroidIdSource androidSource = AndroidIdSource.androidId,
  2. String? initialValue,
})
override

Returns the stable identifier of this device.

Implementation

@override
Future<String> getId({
  AndroidIdSource androidSource = AndroidIdSource.androidId,
  String? initialValue,
}) async {
  final id = await methodChannel.invokeMethod<String>(_getIdMethod, {
    _androidSourceArgument: androidSource.name,
    _initialValueArgument: initialValue,
  });
  if (id == null || id.isEmpty) {
    throw PlatformException(
      code: _unavailableErrorCode,
      message: 'The platform returned an empty device identifier.',
    );
  }
  return id;
}