lpinyin 1.0.6

  • README.md
  • CHANGELOG.md
  • Example
  • Installing
  • Versions
  • 83

lpinyin (汉字转拼音Flutter版)

Pub

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

Android扫码下载APK

Demo截图

image

Add dependency

dependencies:
  lpinyin: x.x.x  #latest version

Example


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

String text = "天府广场";

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

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

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

//无法转换拼音 默认用'#'替代
PinyinHelper.convertToPinyinStringWithoutException(text);
PinyinHelper.convertToPinyinStringWithoutException(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);//繁体字字典

1.0.6

  • TODO: Packages arrangement.

1.0.2

  • TODO: Delete useless files.

1.0.1

  • TODO: Optimize Pinyin conversion speed.

1.0.0

  • TODO: fix "" separator bug.

0.0.2

  • TODO: fix sdk environment.

0.0.1

  • TODO: lPinyin initial release.

example/lib/main.dart

import 'package:lpinyin/lpinyin.dart';

void main() {
  String str = "天府广场";

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

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

  PinyinHelper.convertToPinyinString(str); //tian fu guang chang
  PinyinHelper.convertToPinyinString(str, separator: " ", format: PinyinFormat.WITHOUT_TONE);

  PinyinHelper.convertToPinyinStringWithoutException(str); //tian fu guang chang
  PinyinHelper.convertToPinyinStringWithoutException(str, separator: " ", format: PinyinFormat.WITHOUT_TONE);

  //添加用户自定义字典
  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); //繁体字字典
}

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  lpinyin: ^1.0.6

2. Install it

You can install packages from the command line:

with pub:


$ pub get

with Flutter:


$ flutter packages get

Alternatively, your editor might support pub get or flutter packages get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:lpinyin/lpinyin.dart';
  
Version Uploaded Documentation Archive
1.0.6 Sep 21, 2018 Go to the documentation of lpinyin 1.0.6 Download lpinyin 1.0.6 archive
1.0.2 Sep 19, 2018 Go to the documentation of lpinyin 1.0.2 Download lpinyin 1.0.2 archive
1.0.1 Sep 18, 2018 Go to the documentation of lpinyin 1.0.1 Download lpinyin 1.0.1 archive
1.0.0 Sep 10, 2018 Go to the documentation of lpinyin 1.0.0 Download lpinyin 1.0.0 archive
0.0.2 Aug 14, 2018 Go to the documentation of lpinyin 0.0.2 Download lpinyin 0.0.2 archive
0.0.1 Aug 14, 2018 Go to the documentation of lpinyin 0.0.1 Download lpinyin 0.0.1 archive
Popularity:
Describes how popular the package is relative to other packages. [more]
65
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
100
Overall:
Weighted score of the above. [more]
83
Learn more about scoring.

We analyzed this package on Sep 21, 2018, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.0.0
  • pana: 0.12.3

Platforms

Detected platforms: Flutter, web, other

No platform restriction found in primary library package:lpinyin/lpinyin.dart.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=1.19.0 <3.0.0