unique_ids 3.0.0 copy "unique_ids: ^3.0.0" to clipboard
unique_ids: ^3.0.0 copied to clipboard

can create uuid and can get adid/idfa for mobile app(android/ios)

example/lib/main.dart

import 'dart:async';

import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:unique_ids/unique_ids.dart';

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

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

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

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

  Future<void> _init() async {
    String? adId;
    String? uuid;

    try {
      uuid = await UniqueIds.uuid;
    } on PlatformException {
      uuid = 'Failed to create uuid.v1';
    }

    try {
      adId = await UniqueIds.adId;
    } on PlatformException {
      adId = 'Failed to get adId version.';
    }

    if (!mounted) return;

    setState(() {
      _adId = adId ?? "unknown";
      _uuid = uuid ?? "unknown";
    });
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Plugin example app'),
        ),
        body: Center(
            child: Column(
          children: [
            Text('Running on adId: $_adId\n'),
            Text('created uuid: $_uuid'),
          ],
        )),
      ),
    );
  }
}
6
likes
150
pub points
77%
popularity

Publisher

unverified uploader

can create uuid and can get adid/idfa for mobile app(android/ios)

Repository (GitHub)
View/report issues

Documentation

API reference

License

Apache-2.0 (license)

Dependencies

flutter

More

Packages that depend on unique_ids