Enhancement: Add null-safety variable
Added null-safety to prevent the packages from throwing errors log if there is not enough sufficient data from the QR code. Issue: QR code (UrlBookmark Type) is required to return url. This issue occured due to the QR code returns empty title Solution: Add nullable String if the QR code returns empty title. Also, added nullable variable to other variables.
Showing
1 changed file
with
45 additions
and
41 deletions
| @@ -25,7 +25,7 @@ class Barcode { | @@ -25,7 +25,7 @@ class Barcode { | ||
| 25 | /// It's only available when the barcode is encoded in the UTF-8 format, and for non-UTF8 ones use [rawBytes] instead. | 25 | /// It's only available when the barcode is encoded in the UTF-8 format, and for non-UTF8 ones use [rawBytes] instead. |
| 26 | /// | 26 | /// |
| 27 | /// Returns null if the raw value can not be determined. | 27 | /// Returns null if the raw value can not be determined. |
| 28 | - final String rawValue; | 28 | + final String? rawValue; |
| 29 | 29 | ||
| 30 | /// Returns format type of the barcode value. | 30 | /// Returns format type of the barcode value. |
| 31 | /// | 31 | /// |
| @@ -165,22 +165,22 @@ class ContactInfo { | @@ -165,22 +165,22 @@ class ContactInfo { | ||
| 165 | /// Gets contact person's organization. | 165 | /// Gets contact person's organization. |
| 166 | /// | 166 | /// |
| 167 | /// Returns null if not available. | 167 | /// Returns null if not available. |
| 168 | - final String organization; | 168 | + final String? organization; |
| 169 | 169 | ||
| 170 | /// Gets contact person's phones. | 170 | /// Gets contact person's phones. |
| 171 | /// | 171 | /// |
| 172 | /// Returns an empty list if nothing found. | 172 | /// Returns an empty list if nothing found. |
| 173 | - final List<Phone> phones; | 173 | + final List<Phone>? phones; |
| 174 | 174 | ||
| 175 | /// Gets contact person's title. | 175 | /// Gets contact person's title. |
| 176 | /// | 176 | /// |
| 177 | /// Returns null if not available. | 177 | /// Returns null if not available. |
| 178 | - final String title; | 178 | + final String? title; |
| 179 | 179 | ||
| 180 | /// Gets contact person's urls. | 180 | /// Gets contact person's urls. |
| 181 | /// | 181 | /// |
| 182 | /// Returns an empty list if nothing found. | 182 | /// Returns an empty list if nothing found. |
| 183 | - final List<String> urls; | 183 | + final List<String>? urls; |
| 184 | 184 | ||
| 185 | /// Create a [ContactInfo] from native data. | 185 | /// Create a [ContactInfo] from native data. |
| 186 | ContactInfo.fromNative(Map<dynamic, dynamic> data) | 186 | ContactInfo.fromNative(Map<dynamic, dynamic> data) |
| @@ -202,7 +202,9 @@ class Address { | @@ -202,7 +202,9 @@ class Address { | ||
| 202 | final List<String> addressLines; | 202 | final List<String> addressLines; |
| 203 | 203 | ||
| 204 | /// Gets type of the address. | 204 | /// Gets type of the address. |
| 205 | - final AddressType type; | 205 | + /// |
| 206 | + /// Returns null if not available. | ||
| 207 | + final AddressType? type; | ||
| 206 | 208 | ||
| 207 | /// Create a [Address] from native data. | 209 | /// Create a [Address] from native data. |
| 208 | Address.fromNative(Map<dynamic, dynamic> data) | 210 | Address.fromNative(Map<dynamic, dynamic> data) |
| @@ -215,37 +217,37 @@ class PersonName { | @@ -215,37 +217,37 @@ class PersonName { | ||
| 215 | /// Gets first name. | 217 | /// Gets first name. |
| 216 | /// | 218 | /// |
| 217 | /// Returns null if not available. | 219 | /// Returns null if not available. |
| 218 | - final String first; | 220 | + final String? first; |
| 219 | 221 | ||
| 220 | /// Gets middle name. | 222 | /// Gets middle name. |
| 221 | /// | 223 | /// |
| 222 | /// Returns null if not available. | 224 | /// Returns null if not available. |
| 223 | - final String middle; | 225 | + final String? middle; |
| 224 | 226 | ||
| 225 | /// Gets last name. | 227 | /// Gets last name. |
| 226 | /// | 228 | /// |
| 227 | /// Returns null if not available. | 229 | /// Returns null if not available. |
| 228 | - final String last; | 230 | + final String? last; |
| 229 | 231 | ||
| 230 | /// Gets prefix of the name. | 232 | /// Gets prefix of the name. |
| 231 | /// | 233 | /// |
| 232 | /// Returns null if not available. | 234 | /// Returns null if not available. |
| 233 | - final String prefix; | 235 | + final String? prefix; |
| 234 | 236 | ||
| 235 | /// Gets suffix of the person's name. | 237 | /// Gets suffix of the person's name. |
| 236 | /// | 238 | /// |
| 237 | /// Returns null if not available. | 239 | /// Returns null if not available. |
| 238 | - final String suffix; | 240 | + final String? suffix; |
| 239 | 241 | ||
| 240 | /// Gets the properly formatted name. | 242 | /// Gets the properly formatted name. |
| 241 | /// | 243 | /// |
| 242 | /// Returns null if not available. | 244 | /// Returns null if not available. |
| 243 | - final String formattedName; | 245 | + final String? formattedName; |
| 244 | 246 | ||
| 245 | /// Designates a text string to be set as the kana name in the phonebook. Used for Japanese contacts. | 247 | /// Designates a text string to be set as the kana name in the phonebook. Used for Japanese contacts. |
| 246 | /// | 248 | /// |
| 247 | /// Returns null if not available. | 249 | /// Returns null if not available. |
| 248 | - final String pronunciation; | 250 | + final String? pronunciation; |
| 249 | 251 | ||
| 250 | /// Create a [PersonName] from native data. | 252 | /// Create a [PersonName] from native data. |
| 251 | PersonName.fromNative(Map<dynamic, dynamic> data) | 253 | PersonName.fromNative(Map<dynamic, dynamic> data) |
| @@ -263,74 +265,74 @@ class DriverLicense { | @@ -263,74 +265,74 @@ class DriverLicense { | ||
| 263 | /// Gets city of holder's address. | 265 | /// Gets city of holder's address. |
| 264 | /// | 266 | /// |
| 265 | /// Returns null if not available. | 267 | /// Returns null if not available. |
| 266 | - final String addressCity; | 268 | + final String? addressCity; |
| 267 | 269 | ||
| 268 | /// Gets state of holder's address. | 270 | /// Gets state of holder's address. |
| 269 | /// | 271 | /// |
| 270 | /// Returns null if not available. | 272 | /// Returns null if not available. |
| 271 | - final String addressState; | 273 | + final String? addressState; |
| 272 | 274 | ||
| 273 | /// Gets holder's street address. | 275 | /// Gets holder's street address. |
| 274 | /// | 276 | /// |
| 275 | /// Returns null if not available. | 277 | /// Returns null if not available. |
| 276 | - final String addressStreet; | 278 | + final String? addressStreet; |
| 277 | 279 | ||
| 278 | /// Gets postal code of holder's address. | 280 | /// Gets postal code of holder's address. |
| 279 | /// | 281 | /// |
| 280 | /// Returns null if not available. | 282 | /// Returns null if not available. |
| 281 | - final String addressZip; | 283 | + final String? addressZip; |
| 282 | 284 | ||
| 283 | /// Gets birth date of the holder. | 285 | /// Gets birth date of the holder. |
| 284 | /// | 286 | /// |
| 285 | /// Returns null if not available. | 287 | /// Returns null if not available. |
| 286 | - final String birthDate; | 288 | + final String? birthDate; |
| 287 | 289 | ||
| 288 | /// Gets "DL" for driver licenses, "ID" for ID cards. | 290 | /// Gets "DL" for driver licenses, "ID" for ID cards. |
| 289 | /// | 291 | /// |
| 290 | /// Returns null if not available. | 292 | /// Returns null if not available. |
| 291 | - final String documentType; | 293 | + final String? documentType; |
| 292 | 294 | ||
| 293 | /// Gets expiry date of the license. | 295 | /// Gets expiry date of the license. |
| 294 | /// | 296 | /// |
| 295 | /// Returns null if not available. | 297 | /// Returns null if not available. |
| 296 | - final String expiryDate; | 298 | + final String? expiryDate; |
| 297 | 299 | ||
| 298 | /// Gets holder's first name. | 300 | /// Gets holder's first name. |
| 299 | /// | 301 | /// |
| 300 | /// Returns null if not available. | 302 | /// Returns null if not available. |
| 301 | - final String firstName; | 303 | + final String? firstName; |
| 302 | 304 | ||
| 303 | /// Gets holder's gender. 1 - male, 2 - female. | 305 | /// Gets holder's gender. 1 - male, 2 - female. |
| 304 | /// | 306 | /// |
| 305 | /// Returns null if not available. | 307 | /// Returns null if not available. |
| 306 | - final String gender; | 308 | + final String? gender; |
| 307 | 309 | ||
| 308 | /// Gets issue date of the license. | 310 | /// Gets issue date of the license. |
| 309 | /// | 311 | /// |
| 310 | /// The date format depends on the issuing country. MMDDYYYY for the US, YYYYMMDD for Canada. | 312 | /// The date format depends on the issuing country. MMDDYYYY for the US, YYYYMMDD for Canada. |
| 311 | /// | 313 | /// |
| 312 | /// Returns null if not available. | 314 | /// Returns null if not available. |
| 313 | - final String issueDate; | 315 | + final String? issueDate; |
| 314 | 316 | ||
| 315 | /// Gets the three-letter country code in which DL/ID was issued. | 317 | /// Gets the three-letter country code in which DL/ID was issued. |
| 316 | /// | 318 | /// |
| 317 | /// Returns null if not available. | 319 | /// Returns null if not available. |
| 318 | - final String issuingCountry; | 320 | + final String? issuingCountry; |
| 319 | 321 | ||
| 320 | /// Gets holder's last name. | 322 | /// Gets holder's last name. |
| 321 | /// | 323 | /// |
| 322 | /// Returns null if not available. | 324 | /// Returns null if not available. |
| 323 | - final String lastName; | 325 | + final String? lastName; |
| 324 | 326 | ||
| 325 | /// Gets driver license ID number. | 327 | /// Gets driver license ID number. |
| 326 | /// | 328 | /// |
| 327 | /// Returns null if not available. | 329 | /// Returns null if not available. |
| 328 | - final String licenseNumber; | 330 | + final String? licenseNumber; |
| 329 | 331 | ||
| 330 | /// Gets holder's middle name. | 332 | /// Gets holder's middle name. |
| 331 | /// | 333 | /// |
| 332 | /// Returns null if not available. | 334 | /// Returns null if not available. |
| 333 | - final String middleName; | 335 | + final String? middleName; |
| 334 | 336 | ||
| 335 | /// Create a [DriverLicense] from native data. | 337 | /// Create a [DriverLicense] from native data. |
| 336 | DriverLicense.fromNative(Map<dynamic, dynamic> data) | 338 | DriverLicense.fromNative(Map<dynamic, dynamic> data) |
| @@ -355,22 +357,23 @@ class Email { | @@ -355,22 +357,23 @@ class Email { | ||
| 355 | /// Gets email's address. | 357 | /// Gets email's address. |
| 356 | /// | 358 | /// |
| 357 | /// Returns null if not available. | 359 | /// Returns null if not available. |
| 358 | - final String address; | 360 | + final String? address; |
| 359 | 361 | ||
| 360 | /// Gets email's body. | 362 | /// Gets email's body. |
| 361 | /// | 363 | /// |
| 362 | /// Returns null if not available. | 364 | /// Returns null if not available. |
| 363 | - final String body; | 365 | + final String? body; |
| 364 | 366 | ||
| 365 | /// Gets email's subject. | 367 | /// Gets email's subject. |
| 366 | /// | 368 | /// |
| 367 | /// Returns null if not available. | 369 | /// Returns null if not available. |
| 368 | - final String subject; | 370 | + final String? subject; |
| 369 | 371 | ||
| 370 | /// Gets type of the email. | 372 | /// Gets type of the email. |
| 371 | /// | 373 | /// |
| 372 | /// See also [EmailType]. | 374 | /// See also [EmailType]. |
| 373 | - final EmailType type; | 375 | + /// Returns null if not available. |
| 376 | + final EmailType? type; | ||
| 374 | 377 | ||
| 375 | /// Create a [Email] from native data. | 378 | /// Create a [Email] from native data. |
| 376 | Email.fromNative(Map<dynamic, dynamic> data) | 379 | Email.fromNative(Map<dynamic, dynamic> data) |
| @@ -383,10 +386,10 @@ class Email { | @@ -383,10 +386,10 @@ class Email { | ||
| 383 | /// GPS coordinates from a 'GEO:' or similar QRCode type. | 386 | /// GPS coordinates from a 'GEO:' or similar QRCode type. |
| 384 | class GeoPoint { | 387 | class GeoPoint { |
| 385 | /// Gets the latitude. | 388 | /// Gets the latitude. |
| 386 | - final double latitude; | 389 | + final double? latitude; |
| 387 | 390 | ||
| 388 | /// Gets the longitude. | 391 | /// Gets the longitude. |
| 389 | - final double longitude; | 392 | + final double? longitude; |
| 390 | 393 | ||
| 391 | /// Create a [GeoPoint] from native data. | 394 | /// Create a [GeoPoint] from native data. |
| 392 | GeoPoint.fromNative(Map<dynamic, dynamic> data) | 395 | GeoPoint.fromNative(Map<dynamic, dynamic> data) |
| @@ -399,12 +402,13 @@ class Phone { | @@ -399,12 +402,13 @@ class Phone { | ||
| 399 | /// Gets phone number. | 402 | /// Gets phone number. |
| 400 | /// | 403 | /// |
| 401 | /// Returns null if not available. | 404 | /// Returns null if not available. |
| 402 | - final String number; | 405 | + final String? number; |
| 403 | 406 | ||
| 404 | /// Gets type of the phone number. | 407 | /// Gets type of the phone number. |
| 405 | /// | 408 | /// |
| 406 | /// See also [PhoneType]. | 409 | /// See also [PhoneType]. |
| 407 | - final PhoneType type; | 410 | + /// Returns null if not available. |
| 411 | + final PhoneType? type; | ||
| 408 | 412 | ||
| 409 | /// Create a [Phone] from native data. | 413 | /// Create a [Phone] from native data. |
| 410 | Phone.fromNative(Map<dynamic, dynamic> data) | 414 | Phone.fromNative(Map<dynamic, dynamic> data) |
| @@ -417,12 +421,12 @@ class SMS { | @@ -417,12 +421,12 @@ class SMS { | ||
| 417 | /// Gets the message content of the sms. | 421 | /// Gets the message content of the sms. |
| 418 | /// | 422 | /// |
| 419 | /// Returns null if not available. | 423 | /// Returns null if not available. |
| 420 | - final String message; | 424 | + final String? message; |
| 421 | 425 | ||
| 422 | /// Gets the phone number of the sms. | 426 | /// Gets the phone number of the sms. |
| 423 | /// | 427 | /// |
| 424 | /// Returns null if not available. | 428 | /// Returns null if not available. |
| 425 | - final String phoneNumber; | 429 | + final String? phoneNumber; |
| 426 | 430 | ||
| 427 | /// Create a [SMS] from native data. | 431 | /// Create a [SMS] from native data. |
| 428 | SMS.fromNative(Map<dynamic, dynamic> data) | 432 | SMS.fromNative(Map<dynamic, dynamic> data) |
| @@ -435,12 +439,12 @@ class UrlBookmark { | @@ -435,12 +439,12 @@ class UrlBookmark { | ||
| 435 | /// Gets the title of the bookmark. | 439 | /// Gets the title of the bookmark. |
| 436 | /// | 440 | /// |
| 437 | /// Returns null if not available. | 441 | /// Returns null if not available. |
| 438 | - final String title; | 442 | + final String? title; |
| 439 | 443 | ||
| 440 | /// Gets the url of the bookmark. | 444 | /// Gets the url of the bookmark. |
| 441 | /// | 445 | /// |
| 442 | /// Returns null if not available. | 446 | /// Returns null if not available. |
| 443 | - final String url; | 447 | + final String? url; |
| 444 | 448 | ||
| 445 | /// Create a [UrlBookmark] from native data. | 449 | /// Create a [UrlBookmark] from native data. |
| 446 | UrlBookmark.fromNative(Map<dynamic, dynamic> data) | 450 | UrlBookmark.fromNative(Map<dynamic, dynamic> data) |
| @@ -458,12 +462,12 @@ class WiFi { | @@ -458,12 +462,12 @@ class WiFi { | ||
| 458 | /// Gets the ssid of the WIFI. | 462 | /// Gets the ssid of the WIFI. |
| 459 | /// | 463 | /// |
| 460 | /// Returns null if not available. | 464 | /// Returns null if not available. |
| 461 | - final String ssid; | 465 | + final String? ssid; |
| 462 | 466 | ||
| 463 | /// Gets the password of the WIFI. | 467 | /// Gets the password of the WIFI. |
| 464 | /// | 468 | /// |
| 465 | /// Returns null if not available. | 469 | /// Returns null if not available. |
| 466 | - final String password; | 470 | + final String? password; |
| 467 | 471 | ||
| 468 | /// Create a [WiFi] from native data. | 472 | /// Create a [WiFi] from native data. |
| 469 | WiFi.fromNative(Map<dynamic, dynamic> data) | 473 | WiFi.fromNative(Map<dynamic, dynamic> data) |
-
Please register or login to post a comment