info_pl 0.0.2 copy "info_pl: ^0.0.2" to clipboard
info_pl: ^0.0.2 copied to clipboard

Flutter project that retrieves a device's information.

info_pl #

melos

A Flutter plugin that gets an android device's information.

Platform Support #

Android

Usage #

To use this plugin, add info_pl as a dependency in your pubspec.yaml file.

Example #

Import package:info_pl/info_pl.dart and to get platform-specific device information initialize InfoPl.

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

import 'package:info_pl/info_pl.dart';

static final InfoPl _infoPl = InfoPl();

void main() => runApp(
      const MaterialApp(
        home: Material(
          child: Center(
            child: ElevatedButton(
              onPressed: _getDeviceInfo,
              child: Text('Get Device Info'),
            ),
          ),
        ),
      ),
    );

Future<void> _getDeviceInfo() async {
  if (!await _infoPl.init()) {
    throw Exception('Could not to get device info');
  }
}

Info Text Generator Example #

This plugin offers a data method that provides platform-specific device information in a generic manner. Data obtained through this method can be visualized in an organized and readable manner.

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

import 'package:info_pl/info_pl.dart';

static final InfoPl _infoPl = InfoPl();
DeviceInfo? _deviceInfo;
String? _deviceInfoText;

void main() {
  _getDeviceInfo();
  runApp(
    const MaterialApp(
      home: Material(
        child: SingleChildScrollView(
          child: Text(
            _deviceInfoText ?? 'Loading...',
          ),
        ),
      ),
    ),
  );
}

Future<void> _getDeviceInfo() async {
  String? deviceInfoText;
  
  try {
    _deviceInfo = await _infoPl.init();
    deviceInfoText = _deviceInfo.toString();
  } on PlatformException {
    deviceInfoText = 'Failed to get device info.';
  }

  setState(() {
    _deviceInfoText = deviceInfoText!;
  });
}



Screenshots of the info text generator used

Individual Access to Data via DeviceInfo Example #

Furthermore, individual access to the data obtained through this method is also possible via the DeviceInfo class.

import 'package:info_pl/info_pl.dart';

static final InfoPl _infoPl = InfoPl();
DeviceInfo? _deviceInfo;

Future<void> _getDeviceInfo() async {
  String? deviceBrandAndModel;
  
  try {
    _deviceInfo = await _infoPl.init();
    deviceBrandAndModel = '${_deviceInfo!.brand} ${_deviceInfo!.model}';
  } on PlatformException {
    deviceBrandAndModel = 'Failed to get device info.';
  }
}

Generated UUID Example #

A distinctive UUID created with ID, android_ID and board data is provided. This created UUID is accessed from the DeviceInfo class, like other data obtained.

import 'package:info_pl/info_pl.dart';

static final InfoPl _infoPl = InfoPl();
DeviceInfo? _deviceInfo = await _infoPl.init();
String? uuId = _deviceInfo!.uuId;

See the example app for more complex examples.

2
likes
100
pub points
0%
popularity

Publisher

unverified uploader

Flutter project that retrieves a device's information.

Repository (GitHub)
View/report issues

Documentation

API reference

License

unknown (LICENSE)

Dependencies

flutter, flutter_web_plugins, logging, plugin_platform_interface

More

Packages that depend on info_pl