ios_utsname_ext 1.0.0

  • Readme
  • Changelog
  • Example
  • Installing
  • new79

ios_utsname_ext #

pub package build Buy Me A Coffee

Extension method for translation ios utsname to full product name (e.g. iPhone 6 Plus for 'iPhone7,1').

Why this extension package? #

When using the device_info package you get the following (extract from the readme file):

import 'package:device_info/device_info.dart';

DeviceInfoPlugin deviceInfo = DeviceInfoPlugin();
AndroidDeviceInfo androidInfo = await deviceInfo.androidInfo;
print('Running on ${androidInfo.model}');  // e.g. "Moto G (4)"

IosDeviceInfo iosInfo = await deviceInfo.iosInfo;
print('Running on ${iosInfo.utsname.machine}');  // e.g. "iPhone7,1"

As you can see, for Android you get a rather good product name. But for iOS... you get iPhone7,1'. This extension package gives you the real product name by adding.iOSProductName`:

import 'package:ios_utsname_ext/extension.dart';

...

print('Running on ${iosInfo.utsname.machine.iOSProductName}');  // will give you `iPhone 6 Plus`

Source of product models #

The list is maintained at https://github.com/fieldnotescommunities/ios-device-identifiers. The repo provides an updated .json file.

Based upon that .json file the code for this extension package is generated. When the repo is updated this package will be updated.

API Documentation #

API documentation can be found here

[1.0.0] #

  • Initial version.

example/lib/main.dart

import 'dart:io';

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

import 'package:ios_utsname_ext/extension.dart';

void main() async {
  WidgetsFlutterBinding.ensureInitialized();

  var machineId = '';
  var productName = '';
  final deviceInfoPlugin = DeviceInfoPlugin();
  if (Platform.isIOS) {
    var deviceData = await deviceInfoPlugin.iosInfo;
    machineId = deviceData.utsname.machine;
    productName = machineId.iOSProductName;
  }

  runApp(SampleApp(machineId, productName));
}

class SampleApp extends StatelessWidget {
  final String machineId;
  final String productName;

  SampleApp(this.machineId, this.productName);
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'iOS UtsName Demo',
      theme: ThemeData(
        primarySwatch: Colors.blue,
        visualDensity: VisualDensity.adaptivePlatformDensity,
      ),
      home: Scaffold(
        appBar: AppBar(
          title: Text('iOS UtsName Demo'),
        ),
        body: Center(
          child: Column(
            mainAxisAlignment: MainAxisAlignment.center,
            children: <Widget>[
              Text(
                'machineId $machineId = $productName',
              ),
            ],
          ),
        ),
      ),
    );
  }
}

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  ios_utsname_ext: ^1.0.0

2. Install it

You can install packages from the command line:

with Flutter:


$ flutter pub get

Alternatively, your editor might support flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:ios_utsname_ext/extension.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
58
Health:
Code health derived from static analysis. [more]
99
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
100
Overall:
Weighted score of the above. [more]
79
Learn more about scoring.

We analyzed this package on Jul 10, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.8.4
  • pana: 0.13.14
  • Flutter: 1.17.5

Analysis suggestions

Package not compatible with SDK dart

Because:

  • ios_utsname_ext that is a package requiring null.

Health issues and suggestions

Document public APIs. (-1 points)

3 out of 3 API elements have no dartdoc comment.Providing good documentation for libraries, classes, functions, and other API elements improves code readability and helps developers find and use your API.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.7.0 <3.0.0
flutter 0.0.0
Transitive dependencies
collection 1.14.12 1.14.13
meta 1.1.8 1.2.2
sky_engine 0.0.99
typed_data 1.1.6 1.2.0
vector_math 2.0.8 2.1.0-nullsafety
Dev dependencies
flutter_test
pedantic ^1.8.0