| // Copyright 2017 The Chromium Authors. All rights reserved. |
| // Use of this source code is governed by a BSD-style license that can be |
| // found in the LICENSE file. |
| |
| import 'dart:async'; |
| import 'package:device_info_platform_interface/device_info_platform_interface.dart'; |
| |
| export 'package:device_info_platform_interface/device_info_platform_interface.dart' |
| show AndroidBuildVersion, AndroidDeviceInfo, IosDeviceInfo, IosUtsname; |
| |
| /// Provides device and operating system information. |
| class DeviceInfoPlugin { |
| /// No work is done when instantiating the plugin. It's safe to call this |
| /// repeatedly or in performance-sensitive blocks. |
| DeviceInfoPlugin(); |
| |
| /// This information does not change from call to call. Cache it. |
| AndroidDeviceInfo _cachedAndroidDeviceInfo; |
| |
| /// Information derived from `android.os.Build`. |
| /// |
| /// See: https://developer.android.com/reference/android/os/Build.html |
| Future<AndroidDeviceInfo> get androidInfo async => |
| _cachedAndroidDeviceInfo ??= |
| await DeviceInfoPlatform.instance.androidInfo(); |
| |
| /// This information does not change from call to call. Cache it. |
| IosDeviceInfo _cachedIosDeviceInfo; |
| |
| /// Information derived from `UIDevice`. |
| /// |
| /// See: https://developer.apple.com/documentation/uikit/uidevice |
| Future<IosDeviceInfo> get iosInfo async => |
| _cachedIosDeviceInfo ??= await DeviceInfoPlatform.instance.iosInfo(); |
| } |