Search packages, repositories and app categories

Package detailsv2.0.3

lpinyin

Chinese character conversion pinyin library.Accurate and complete Chinese character dictionary.Fast conversion.

AndroidiOSWebmacOSWindowsLinux
30-day downloads
88.1K
Likes
139
Pub points
160

Install package

flutter pub add lpinyin

Package Overview

Package selection guidance compiled from public package information, community data, and project usage.

lpinyin is a high-performance Flutter/Dart package for converting Chinese characters to pinyin with accurate and comprehensive dictionary support. It enables fast, reliable phonetic transcription of Chinese text, making it ideal for applications requiring proper pronunciation guidance, search functionality, or language learning tools. The library is optimized for multiple platforms including Android, iOS, Web, macOS, Windows, and Linux, ensuring consistent behavior across environments. Its robust character coverage and efficient algorithms make it suitable for both simple and complex input scenarios.

Use cases

  • Chinese language learning apps
  • Search and sorting by pinyin
  • Text-to-speech integration
  • Input method assistance
  • Dictionary and lookup tools

Key features

  • Accurate pinyin conversion
  • Complete Chinese character dictionary
  • Cross-platform support
  • Fast performance
  • Supports tone marks
  • Easy integration via pub

Suitable for

  • Developers building Chinese language apps
  • Educational software for Mandarin learners
  • Applications needing phonetic indexing
  • Tools requiring Chinese text processing

Considerations

  • May require additional handling for rare or variant characters
  • Tone mark rendering depends on font support
  • Large dictionary size may impact initial app bundle size

Original README

Original README snapshot from the linked source repository. Visit the repository for the latest content.

lpinyin (Flutter汉字转拼音)

lpinyin是一个汉字转拼音的Dart Package. 主要参考Java开源类库jpinyin.
①准确、完善的字库
②拼音转换速度快
③支持多种拼音输出格式:带音标、不带音标、数字表示音标以及拼音首字母输出格式
④支持常见多音字的识别,其中包括词组、成语、地名等
⑤简繁体中文转换
⑥支持添加用户自定义字典

Pub

dependencies:
  lpinyin: ^2.0.2  #latest version

Example


// Import package
import 'package:lpinyin/lpinyin.dart';

String text = "天府广场";

//字符串拼音首字符
PinyinHelper.getShortPinyin(str); // tfgc

//字符串首字拼音
PinyinHelper.getFirstWordPinyin(str); // tian

//无法转换拼音会 throw PinyinException
PinyinHelper.getPinyin(text);
PinyinHelper.getPinyin(text, separator: " ", format: PinyinFormat.WITHOUT_TONE);//tian fu guang chang

//无法转换拼音 默认用' '替代
PinyinHelper.getPinyinE(text);
PinyinHelper.getPinyinE(text, separator: " ", defPinyin: '#', format: PinyinFormat.WITHOUT_TONE);//tian fu guang chang

//添加用户自定义字典
List<String> dict1 = ['耀=yào','老=lǎo'];
PinyinHelper.addPinyinDict(dict1);//拼音字典
List<String> dict2 = ['奇偶=jī,ǒu','成都=chéng,dū'];
PinyinHelper.addMultiPinyinDict(dict2);//多音字词组字典
List<String> dict3 = ['倆=俩','們=们'];
ChineseHelper.addChineseDict(dict3);//繁体字字典

Screenshots

Changelog

Please see the Changelog page to know what's recently changed.

App

Moss
A GitHub client app developed with Flutter, which supports Android iOS Web.
Web :Flutter Web.

Categories

Source repository

Projects using this package

Rankings