flutter_secure_device_id 0.3.0 copy "flutter_secure_device_id: ^0.3.0" to clipboard
flutter_secure_device_id: ^0.3.0 copied to clipboard

discontinuedreplaced by: persistent_device_id
PlatformAndroidiOS

A Flutter plugin for hardware-backed device identifier (Android Keystore & iOS Secure Enclave)

example/lib/main.dart

import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_secure_device_id/flutter_secure_device_id.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 _deviceId = 'Unknown';

  @override
  void initState() {
    super.initState();
    _fetchId();
  }

  Future<void> _fetchId() async {
    try {
      final id = await FlutterSecureDeviceId.getDeviceId();
      if (!mounted) return;
      setState(() {
        _deviceId = id;
      });
    } on PlatformException catch (e) {
      if (!mounted) return;
      setState(() {
        _deviceId = 'Error: ${e.message}';
      });
    } catch (e) {
      if (!mounted) return;
      setState(() {
        _deviceId = 'Error: $e';
      });
    }
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(title: const Text('Secure Device ID Example')),
        body: Center(
          child: Padding(
            padding: const EdgeInsets.all(16.0),
            child: Column(
              mainAxisAlignment: MainAxisAlignment.center,
              children: [
                const Text(
                  'Device ID:',
                  style: TextStyle(fontSize: 18, fontWeight: FontWeight.bold),
                ),
                const SizedBox(height: 16),
                SelectableText(
                  _deviceId,
                  style: const TextStyle(fontSize: 14, fontFamily: 'monospace'),
                  textAlign: TextAlign.center,
                ),
                const SizedBox(height: 32),
                ElevatedButton(
                  onPressed: _fetchId,
                  child: const Text('Refresh'),
                ),
              ],
            ),
          ),
        ),
      ),
    );
  }
}
1
likes
160
points
17
downloads

Publisher

unverified uploader

Weekly Downloads

A Flutter plugin for hardware-backed device identifier (Android Keystore & iOS Secure Enclave)

Homepage
Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (license)

Dependencies

flutter, plugin_platform_interface

More

Packages that depend on flutter_secure_device_id

Packages that implement flutter_secure_device_id