iso_languages 1.1.1
iso_languages: ^1.1.1 copied to clipboard
A Flutter package to work with ISO 639-1 language codes, providing language names, native names, and utility functions.
iso_languages #
iso_languages is a Flutter package for working with ISO 639-1 language codes, built on the npm package iso-639-1, providing both English and native names for languages through an intuitive API.
Features #
- Retrieve the English name of a language using its ISO 639-1 code.
- Retrieve the native name of a language.
- Supports over 180 ISO 639-1 language codes.
- Lightweight, easy to use, and developer-friendly.
- Built on the widely-used iso-639-1 package from npm for accurate language data.
Installation #
Add the following to your pubspec.yaml
file:
dependencies:
iso_languages: ^1.1.1
Usage #
Import the Package #
import 'package:iso_languages/iso_languages.dart';
Example: Get Language Names #
void main() {
// Get the English name of the language
String englishName = isoLanguage(shortName: 'en');
print('English Name: $englishName'); // Output: English
// Get the native name of the language
String nativeName = isoLanguage(shortName: 'ab', isNativeName: true);
print('Native Name: $nativeName'); // Output: аҧсуа бызшәа
// Get the Full name of the language
String name = isoLanguage(shortName: 'bn');
print('Full Name: $name'); // Output: Bangla
// Get the native name of the language
String nativeName = isoLanguage(shortName: 'bn', isNativeName: true);
print('Native Name: $nativeName'); // Output: বাংলা
// Handle unknown codes gracefully
String unknown = isoLanguage(shortName: 'unknown');
print('Unknown Code: $unknown'); // Output: (Empty String)
}
Usage in a Flutter Text Widget: #
Text(
isoLanguage(shortName: 'en'),
style: TextStyle(
fontSize: 16,
),
);