Skip to content
This repository was archived by the owner on Feb 22, 2023. It is now read-only.

Commit 3dfbb26

Browse files
author
Chris Yang
committed
review
1 parent 663e074 commit 3dfbb26

File tree

4 files changed

+83
-84
lines changed

4 files changed

+83
-84
lines changed

packages/device_info/device_info/example/lib/main.dart

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -59,13 +59,13 @@ class _MyAppState extends State<MyApp> {
5959

6060
Map<String, dynamic> _readAndroidBuildData(AndroidDeviceInfo build) {
6161
return <String, dynamic>{
62-
'version.securityPatch': build.version?.securityPatch,
63-
'version.sdkInt': build.version?.sdkInt,
64-
'version.release': build.version?.release,
65-
'version.previewSdkInt': build.version?.previewSdkInt,
66-
'version.incremental': build.version?.incremental,
67-
'version.codename': build.version?.codename,
68-
'version.baseOS': build.version?.baseOS,
62+
'version.securityPatch': build.version.securityPatch,
63+
'version.sdkInt': build.version.sdkInt,
64+
'version.release': build.version.release,
65+
'version.previewSdkInt': build.version.previewSdkInt,
66+
'version.incremental': build.version.incremental,
67+
'version.codename': build.version.codename,
68+
'version.baseOS': build.version.baseOS,
6969
'board': build.board,
7070
'bootloader': build.bootloader,
7171
'brand': build.brand,
@@ -98,11 +98,11 @@ class _MyAppState extends State<MyApp> {
9898
'localizedModel': data.localizedModel,
9999
'identifierForVendor': data.identifierForVendor,
100100
'isPhysicalDevice': data.isPhysicalDevice,
101-
'utsname.sysname:': data.utsname?.sysname,
102-
'utsname.nodename:': data.utsname?.nodename,
103-
'utsname.release:': data.utsname?.release,
104-
'utsname.version:': data.utsname?.version,
105-
'utsname.machine:': data.utsname?.machine,
101+
'utsname.sysname:': data.utsname.sysname,
102+
'utsname.nodename:': data.utsname.nodename,
103+
'utsname.release:': data.utsname.release,
104+
'utsname.version:': data.utsname.version,
105+
'utsname.machine:': data.utsname.machine,
106106
};
107107
}
108108

packages/device_info/device_info/example/pubspec.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,3 @@ flutter:
1919

2020
environment:
2121
sdk: '>=2.10.0-56.0.dev <3.0.0'
22-

packages/device_info/device_info_platform_interface/lib/model/android_device_info.dart

Lines changed: 47 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -35,43 +35,43 @@ class AndroidDeviceInfo {
3535
systemFeatures = List<String>.unmodifiable(systemFeatures);
3636

3737
/// Android operating system version values derived from `android.os.Build.VERSION`.
38-
final AndroidBuildVersion? version;
38+
final AndroidBuildVersion version;
3939

4040
/// The name of the underlying board, like "goldfish".
41-
final String? board;
41+
final String board;
4242

4343
/// The system bootloader version number.
44-
final String? bootloader;
44+
final String bootloader;
4545

4646
/// The consumer-visible brand with which the product/hardware will be associated, if any.
47-
final String? brand;
47+
final String brand;
4848

4949
/// The name of the industrial design.
50-
final String? device;
50+
final String device;
5151

5252
/// A build ID string meant for displaying to the user.
53-
final String? display;
53+
final String display;
5454

5555
/// A string that uniquely identifies this build.
56-
final String? fingerprint;
56+
final String fingerprint;
5757

5858
/// The name of the hardware (from the kernel command line or /proc).
59-
final String? hardware;
59+
final String hardware;
6060

6161
/// Hostname.
62-
final String? host;
62+
final String host;
6363

6464
/// Either a changelist number, or a label like "M4-rc20".
65-
final String? id;
65+
final String id;
6666

6767
/// The manufacturer of the product/hardware.
68-
final String? manufacturer;
68+
final String manufacturer;
6969

7070
/// The end-user-visible name for the end product.
71-
final String? model;
71+
final String model;
7272

7373
/// The name of the overall product.
74-
final String? product;
74+
final String product;
7575

7676
/// An ordered list of 32 bit ABIs supported by this device.
7777
final List<String> supported32BitAbis;
@@ -83,16 +83,16 @@ class AndroidDeviceInfo {
8383
final List<String> supportedAbis;
8484

8585
/// Comma-separated tags describing the build, like "unsigned,debug".
86-
final String? tags;
86+
final String tags;
8787

8888
/// The type of build, like "user" or "eng".
89-
final String? type;
89+
final String type;
9090

9191
/// `false` if the application is running in an emulator, `true` otherwise.
92-
final bool? isPhysicalDevice;
92+
final bool isPhysicalDevice;
9393

9494
/// The Android hardware device ID that is unique between the device + user and app signing.
95-
final String? androidId;
95+
final String androidId;
9696

9797
/// Describes what features are available on the current device.
9898
///
@@ -115,25 +115,25 @@ class AndroidDeviceInfo {
115115
return AndroidDeviceInfo(
116116
version: AndroidBuildVersion._fromMap(
117117
map['version']?.cast<String, dynamic>() ?? {}),
118-
board: map['board'],
119-
bootloader: map['bootloader'],
120-
brand: map['brand'],
121-
device: map['device'],
122-
display: map['display'],
123-
fingerprint: map['fingerprint'],
124-
hardware: map['hardware'],
125-
host: map['host'],
126-
id: map['id'],
127-
manufacturer: map['manufacturer'],
128-
model: map['model'],
129-
product: map['product'],
118+
board: map['board'] ?? '',
119+
bootloader: map['bootloader'] ?? '',
120+
brand: map['brand'] ?? '',
121+
device: map['device'] ?? '',
122+
display: map['display'] ?? '',
123+
fingerprint: map['fingerprint'] ?? '',
124+
hardware: map['hardware'] ?? '',
125+
host: map['host'] ?? '',
126+
id: map['id'] ?? '',
127+
manufacturer: map['manufacturer'] ?? '',
128+
model: map['model'] ?? '',
129+
product: map['product'] ?? '',
130130
supported32BitAbis: _fromList(map['supported32BitAbis'] ?? []),
131131
supported64BitAbis: _fromList(map['supported64BitAbis'] ?? []),
132132
supportedAbis: _fromList(map['supportedAbis'] ?? []),
133-
tags: map['tags'],
134-
type: map['type'],
135-
isPhysicalDevice: map['isPhysicalDevice'],
136-
androidId: map['androidId'],
133+
tags: map['tags'] ?? '',
134+
type: map['type'] ?? '',
135+
isPhysicalDevice: map['isPhysicalDevice'] ?? '',
136+
androidId: map['androidId'] ?? '',
137137
systemFeatures: _fromList(map['systemFeatures'] ?? []),
138138
);
139139
}
@@ -161,38 +161,38 @@ class AndroidBuildVersion {
161161
});
162162

163163
/// The base OS build the product is based on.
164-
final String? baseOS;
164+
final String baseOS;
165165

166166
/// The current development codename, or the string "REL" if this is a release build.
167-
final String? codename;
167+
final String codename;
168168

169169
/// The internal value used by the underlying source control to represent this build.
170-
final String? incremental;
170+
final String incremental;
171171

172172
/// The developer preview revision of a prerelease SDK.
173-
final int? previewSdkInt;
173+
final int previewSdkInt;
174174

175175
/// The user-visible version string.
176-
final String? release;
176+
final String release;
177177

178178
/// The user-visible SDK version of the framework.
179179
///
180180
/// Possible values are defined in: https://developer.android.com/reference/android/os/Build.VERSION_CODES.html
181-
final int? sdkInt;
181+
final int sdkInt;
182182

183183
/// The user-visible security patch level.
184-
final String? securityPatch;
184+
final String securityPatch;
185185

186186
/// Deserializes from the map message received from [_kChannel].
187187
static AndroidBuildVersion _fromMap(Map<String, dynamic> map) {
188188
return AndroidBuildVersion._(
189-
baseOS: map['baseOS'],
190-
codename: map['codename'],
191-
incremental: map['incremental'],
192-
previewSdkInt: map['previewSdkInt'],
193-
release: map['release'],
194-
sdkInt: map['sdkInt'],
195-
securityPatch: map['securityPatch'],
189+
baseOS: map['baseOS'] ?? '',
190+
codename: map['codename'] ?? '',
191+
incremental: map['incremental'] ?? '',
192+
previewSdkInt: map['previewSdkInt'] ?? '',
193+
release: map['release'] ?? '',
194+
sdkInt: map['sdkInt'] ?? '',
195+
securityPatch: map['securityPatch'] ?? '',
196196
);
197197
}
198198
}

packages/device_info/device_info_platform_interface/lib/model/ios_device_info.dart

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -19,38 +19,38 @@ class IosDeviceInfo {
1919
});
2020

2121
/// Device name.
22-
final String? name;
22+
final String name;
2323

2424
/// The name of the current operating system.
25-
final String? systemName;
25+
final String systemName;
2626

2727
/// The current operating system version.
28-
final String? systemVersion;
28+
final String systemVersion;
2929

3030
/// Device model.
31-
final String? model;
31+
final String model;
3232

3333
/// Localized name of the device model.
34-
final String? localizedModel;
34+
final String localizedModel;
3535

3636
/// Unique UUID value identifying the current device.
37-
final String? identifierForVendor;
37+
final String identifierForVendor;
3838

3939
/// `false` if the application is running in a simulator, `true` otherwise.
40-
final bool? isPhysicalDevice;
40+
final bool isPhysicalDevice;
4141

4242
/// Operating system information derived from `sys/utsname.h`.
43-
final IosUtsname? utsname;
43+
final IosUtsname utsname;
4444

4545
/// Deserializes from the map message received from [_kChannel].
4646
static IosDeviceInfo fromMap(Map<String, dynamic> map) {
4747
return IosDeviceInfo(
48-
name: map['name'],
49-
systemName: map['systemName'],
50-
systemVersion: map['systemVersion'],
51-
model: map['model'],
52-
localizedModel: map['localizedModel'],
53-
identifierForVendor: map['identifierForVendor'],
48+
name: map['name'] ?? '',
49+
systemName: map['systemName'] ?? '',
50+
systemVersion: map['systemVersion'] ?? '',
51+
model: map['model'] ?? '',
52+
localizedModel: map['localizedModel'] ?? '',
53+
identifierForVendor: map['identifierForVendor'] ?? '',
5454
isPhysicalDevice: map['isPhysicalDevice'] == 'true',
5555
utsname:
5656
IosUtsname._fromMap(map['utsname']?.cast<String, dynamic>() ?? {}),
@@ -70,28 +70,28 @@ class IosUtsname {
7070
});
7171

7272
/// Operating system name.
73-
final String? sysname;
73+
final String sysname;
7474

7575
/// Network node name.
76-
final String? nodename;
76+
final String nodename;
7777

7878
/// Release level.
79-
final String? release;
79+
final String release;
8080

8181
/// Version level.
82-
final String? version;
82+
final String version;
8383

8484
/// Hardware type (e.g. 'iPhone7,1' for iPhone 6 Plus).
85-
final String? machine;
85+
final String machine;
8686

8787
/// Deserializes from the map message received from [_kChannel].
8888
static IosUtsname _fromMap(Map<String, dynamic> map) {
8989
return IosUtsname._(
90-
sysname: map['sysname'],
91-
nodename: map['nodename'],
92-
release: map['release'],
93-
version: map['version'],
94-
machine: map['machine'],
90+
sysname: map['sysname'] ?? '',
91+
nodename: map['nodename'] ?? '',
92+
release: map['release'] ?? '',
93+
version: map['version'] ?? '',
94+
machine: map['machine'] ?? '',
9595
);
9696
}
9797
}

0 commit comments

Comments
 (0)