2025-08-05 00:24:57 +08:00
|
|
|
import 'package:flutter/services.dart';
|
|
|
|
|
|
|
|
|
|
class NativeUuidGenerator {
|
|
|
|
|
static const MethodChannel _channel =
|
2025-08-05 08:21:05 +08:00
|
|
|
MethodChannel('com.example/uuid_generator');
|
2025-08-05 00:24:57 +08:00
|
|
|
|
2025-08-05 08:21:05 +08:00
|
|
|
static Future<String> generateStandardUUID() async {
|
|
|
|
|
return await _channel.invokeMethod('generateStandardUUID');
|
2025-08-05 00:24:57 +08:00
|
|
|
}
|
|
|
|
|
|
2025-08-05 08:21:05 +08:00
|
|
|
static Future<String> generateShortUUID({int length = 8}) async {
|
|
|
|
|
return await _channel.invokeMethod('generateShortUUID', {'length': length});
|
2025-08-05 00:24:57 +08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 1. https://mvnrepository.com/artifact/com.fasterxml.uuid/java-uuid-generator/4.0.1
|
|
|
|
|
* 2. add jars to app/libs, modify build.gradle.kts
|
|
|
|
|
* 3. modify app/src/main/kotlin/com/example/include_jar/MainActivity.kt
|
|
|
|
|
* 4. refer in flutter
|
|
|
|
|
*/
|