toMap method

Map<String, Object> toMap()

Converts the NaturalLanguage object to a JSON map.

The returned map contains the following keys:

  • "name": A string that represents the name of the language.
  • "code": A string that represents the ISO 639-1 code of the language.
  • "codeShort": A string that represents the short code of the language.
  • "namesNative": A string that represents the native names of the language.
  • "family": A string that represents the name of the language family.
  • "isRightToLeft": A boolean that indicates whether the language is written from right to left.
  • "scripts": A string that represents the scripts of the language.

Example usage:

import 'package:sealed_languages/sealed_languages.dart';

void main() {
  final jsonMap = const LangEng().toMap();
  assert(jsonMap.isNotEmpty);
}

Implementation

Map<String, Object> toMap() => {
  "bibliographicCode": ?bibliographicCode,
  "code": code,
  "codeShort": codeShort,
  "family": family.name,
  "isRightToLeft": isRightToLeft,
  "name": name,
  "namesNative": namesNative,
  "scripts": scripts.toIsoList(),
};