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

Lookup device marketing names for Android, iOS and browsers with ease. No internet connection or database required.

example/lib/main.dart

import 'dart:async';

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

void main() {
  runApp(const DeviceNamesExample());
}

class DeviceNamesExample extends StatefulWidget {
  const DeviceNamesExample({Key? key}) : super(key: key);

  @override
  State<DeviceNamesExample> createState() => _DeviceNamesExampleState();
}

class _DeviceNamesExampleState extends State<DeviceNamesExample> {
  String singleDeviceName = "Unknown";
  String singleDeviceNameFromModel = "Unknown";
  String deviceNames = "Unknown";
  String deviceNamesFromModel = "Unknown";

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

  Future<void> initPlugin() async {
    const model = "SM-J250F";
    final deviceMarketingNames = DeviceMarketingNames();
    final currentSingleDeviceName = await deviceMarketingNames.getSingleName();
    final currentDeviceNames = await deviceMarketingNames.getNames();
    setState(() {
      singleDeviceName = currentSingleDeviceName;
      deviceNames = currentDeviceNames;
      singleDeviceNameFromModel = deviceMarketingNames.getSingleNameFromModel(
          DeviceType.android, model);
      deviceNamesFromModel =
          deviceMarketingNames.getNamesFromModel(DeviceType.android, model);
    });
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('DeviceNames example app'),
        ),
        body: Padding(
          padding: const EdgeInsets.all(32.0),
          child: Column(
            crossAxisAlignment: CrossAxisAlignment.stretch,
            children: [
              Padding(
                padding: const EdgeInsets.all(8.0),
                child: Text(
                  'First device name:\n$singleDeviceName',
                ),
              ),
              Padding(
                padding: const EdgeInsets.all(8.0),
                child: Text(
                  'All possible device names:\n$deviceNames',
                ),
              ),
              Padding(
                padding: const EdgeInsets.all(8.0),
                child: Text(
                  'First device name for model "SM-J250F":\n$singleDeviceNameFromModel',
                ),
              ),
              Padding(
                padding: const EdgeInsets.all(8.0),
                child: Text(
                  'All possible device names for model "SM-J250F":\n$deviceNamesFromModel',
                ),
              ),
            ],
          ),
        ),
      ),
    );
  }
}
30
likes
160
points
31k
downloads

Publisher

verified publisherboehrsi.de

Weekly Downloads

Lookup device marketing names for Android, iOS and browsers with ease. No internet connection or database required.

Repository (GitHub)
View/report issues
Contributing

Topics

#device #name #utils

Documentation

API reference

License

Apache-2.0 (license)

Dependencies

device_info_plus, flutter, universal_platform

More

Packages that depend on device_marketing_names