59 lines
1.7 KiB
Dart
59 lines
1.7 KiB
Dart
import 'package:flutter/foundation.dart';
|
|
import 'package:flutter/services.dart';
|
|
|
|
/// The plugin class for retrieving the Android ID.
|
|
class AndroidId {
|
|
const AndroidId();
|
|
|
|
/// The method channel used to interact with the native platform.
|
|
static const _methodChannel = MethodChannel('android_id');
|
|
|
|
/// Calls the native method to retrieve the Android ID.
|
|
Future<String?> getId() async {
|
|
final isAndroid =
|
|
!kIsWeb && defaultTargetPlatform == TargetPlatform.android;
|
|
if (!isAndroid) return null;
|
|
|
|
return _methodChannel.invokeMethod<String?>('getId');
|
|
}
|
|
|
|
Future<String?> getImei() async {
|
|
final isAndroid =
|
|
!kIsWeb && defaultTargetPlatform == TargetPlatform.android;
|
|
if (!isAndroid) return null;
|
|
|
|
return _methodChannel.invokeMethod<String?>('getImei');
|
|
}
|
|
|
|
Future<String?> getMaAddress() async {
|
|
final isAndroid =
|
|
!kIsWeb && defaultTargetPlatform == TargetPlatform.android;
|
|
if (!isAndroid) return null;
|
|
|
|
return _methodChannel.invokeMethod<String?>('getMacAddress');
|
|
}
|
|
// Future<String?> getOaid() async {
|
|
// final isAndroid =
|
|
// !kIsWeb && defaultTargetPlatform == TargetPlatform.android;
|
|
// if (!isAndroid) return null;
|
|
//
|
|
// return _methodChannel.invokeMethod<String?>('getOaid');
|
|
// }
|
|
|
|
Future<bool?> isRoot() async {
|
|
final isAndroid =
|
|
!kIsWeb && defaultTargetPlatform == TargetPlatform.android;
|
|
if (!isAndroid) return null;
|
|
|
|
return _methodChannel.invokeMethod<bool?>('checkRoot');
|
|
}
|
|
|
|
Future<bool?> isEmulator() async {
|
|
final isAndroid =
|
|
!kIsWeb && defaultTargetPlatform == TargetPlatform.android;
|
|
if (!isAndroid) return null;
|
|
|
|
return _methodChannel.invokeMethod<bool?>('checkIsEmulator');
|
|
}
|
|
}
|