locale property Null safety

Locale locale

The system-reported default locale of the device.

This establishes the language and formatting conventions that application should, if possible, use to render their user interface.

This is the first locale selected by the user and is the user's primary locale (the locale the device UI is displayed in)

This is equivalent to locales.first, except that it will provide an undefined (using the language tag "und") non-null locale if the locales list has not been set or is empty.

Implementation

Locale get locale => locales.isEmpty ? const Locale.fromSubtags() : locales.first;