flutter_udid 2.1.0 flutter_udid: ^2.1.0 copied to clipboard
Plugin to retrieve a persistent UDID across reinstalls on iOS and Android
import 'package:flutter/material.dart';
import 'dart:async';
import 'package:flutter/services.dart';
import 'package:flutter_udid/flutter_udid.dart';
void main() => runApp(const MyApp());
class MyApp extends StatefulWidget {
const MyApp({super.key});
@override
State<MyApp> createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> {
String _udid = 'Unknown';
@override
void initState() {
super.initState();
initPlatformState();
}
Future<void> initPlatformState() async {
String udid;
try {
udid = await FlutterUdid.udid;
} on PlatformException {
udid = 'Failed to get UDID.';
}
if (!mounted) return;
setState(() {
_udid = udid;
});
}
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(
title: const Text('Plugin example app'),
),
body: Center(
child: Text('Running on: $_udid\n'),
),
),
);
}
}