unreliable_device_info 1.0.0 copy "unreliable_device_info: ^1.0.0" to clipboard
unreliable_device_info: ^1.0.0 copied to clipboard

For getting device info, including some that isn't exposed in a official/neat/reliable way

example/lib/main.dart

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

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

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

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

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

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

  Future<void> initPlatformState() async {
    String serialNumber;
    String mainMessage;

    serialNumber = await UnreliableDeviceInfo.manufacturerSerialNumber;

    if (!mounted) return;

    if (serialNumber != null) {
      mainMessage = "Serial number is: $serialNumber";
    } else {
      if (await UnreliableDeviceInfo.hasException) {
        final exceptionMessage = await UnreliableDeviceInfo.exceptionMessage;

        mainMessage = "Exception: $exceptionMessage";
      } else {
        mainMessage = "Serial number null, but no exception was caught;"
            "likely a method that works for this device has not been implemented.";
      }
    }

    setState(() {
      _mainMessage = mainMessage;
    });
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('UnreliableDeviceInfoPlugin example app'),
        ),
        body: Center(
          child: Text(_mainMessage),
        ),
      ),
    );
  }
}
0
likes
30
pub points
0%
popularity

Publisher

unverified uploader

For getting device info, including some that isn&#x27;t exposed in a official&#x2F;neat&#x2F;reliable way

Homepage
Repository (GitHub)
View/report issues

License

unknown (LICENSE)

Dependencies

flutter

More

Packages that depend on unreliable_device_info