unique_identifier 0.4.0 copy "unique_identifier: ^0.4.0" to clipboard
unique_identifier: ^0.4.0 copied to clipboard

A new Flutter plugin for fetching the unique identifier from android and ios.

example/lib/main.dart

import 'package:flutter/material.dart';
import 'dart:async';

import 'package:flutter/services.dart';
import 'package:unique_identifier/unique_identifier.dart';

void main() => runApp(new MyApp());

class MyApp extends StatefulWidget {
  @override
  _MyAppState createState() => new _MyAppState();
}

class _MyAppState extends State<MyApp> {
  String _identifier = 'Unknown';

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

  Future<void> initUniqueIdentifierState() async {
    String identifier;
    try {
      identifier = (await UniqueIdentifier.serial)!;
    } on PlatformException {
      identifier = 'Failed to get Unique Identifier';
    }

    if (!mounted) return;

    setState(() {
      _identifier = identifier;
    });
  }

  @override
  Widget build(BuildContext context) {
    return new MaterialApp(
      home: new Scaffold(
        appBar: new AppBar(
          title: const Text('Plugin example app'),
        ),
        body: new Center(
          child: new Text('Running on device with id: $_identifier\n'),
        ),
      ),
    );
  }
}
55
likes
140
points
18.9k
downloads

Publisher

verified publisheraltercode.xyz

Weekly Downloads

A new Flutter plugin for fetching the unique identifier from android and ios.

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (license)

Dependencies

flutter, plugin_platform_interface

More

Packages that depend on unique_identifier