GitHub 저장소betterxio/string_contains

문자열 포함

이 패키지는 링크화 및 정리용 가벼운 위젯 [Linkify, Clean]과 부적절한 단어/URL/링크/이메일/전화번호/#해시태그/@멘션 등을 포함하는 문자열을 위한 확장 기능을 제공합니다.

문자열 포함 프로젝트 이미지
스타
9
포크
0
최근 푸시(UTC)
2024. 2. 6.
프로젝트 상태
활성

원본 README

아래는 영문 원문 스냅샷입니다. 최신 내용은 GitHub에서 확인하세요.

string_contains

pub package Score Platform GitHub issues GitHub license

Package provides light widgets[for Linkify, Clean] and string scanner extensions on a string to check it contains bad words/urls/links/emails/phone numbers/#hashtags/@mentions etc.

Installing

1. Depend on it

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

dependencies:
  string_contains: ^2.4.0
2. Install it

You can install packages from the command line:

with pub:

$ dart pub add string_contains

with Flutter:

$ flutter pub add string_contains
3. Import it

Now in your Flutter code, you can use:

import 'package:string_contains/string_contains.dart';

Getting Started

Import the library.

import 'package:string_contains/string_contains.dart';

You can use the extension methods on String and Nullable String.

final String? nullableString = "International phone number +91-9000000001. others 123-456-7890 and (123)-456-7890.";
print(nullableString.containsPhoneNumber()); // returns true
print(nullableString.getPhoneNumbers()); // returns ['+91-9000000001', '123-456-7890', '(123)-456-7890']

Example

import 'package:string_contains/string_contains.dart';
 'I am CEO, Bitch'.containsBadWords(); // returns true

 'I am CEO, Bitch'.cleanBadWords() // returns 'I am CEO, B***t'.

 'I am CEO, Bitch'.cleanBadWords(keepFirstLastLetters: false) // returns 'I am CEO, *****'.

 'I am CEO, Bitch'.cleanBadWords(obscuringCharacter: '@') // returns 'I am CEO, B@@@h'.

 'I am CEO, Bitch'.getBadWords() // returns ['Bitch']

 'Please visit our website : https://betterx.io/'.containsUrl() // returns true

 'Please visit our website : https://betterx.io/'.getUrls() // returns ['https://betterx.io/']

 "BetterX.io : Let's build something Better, User-centered & beautiful together\n for more info contact us at : info@betterx.io".containsEmail() // returns true

 "BetterX.io : Let's build something Better, User-centered & beautiful together\n for more info contact us at : info@betterx.io".getEmails() // returns ['betterx.io']

 "BetterX.io : Let's build something Better, User-centered & beautiful together\n for more info contact us at : info@betterx.io".hideEmails() // returns "BetterX.io : Let's build something Better, User-centered & beautiful together\n for more info contact us at : in**@betterx.io

"hi there, i love flutter.".containsWords(["hi", "there","flutter" ]) // returns true
"i love Flutter.".containsWords(["hi", "there","flutter"], caseSensitive: true) // returns false
"hi there, i love flutter.".cleanWords(["hi", "there","flutter" ]) // returns "**, t***e, i love F*****r."
"i love Flutter.".cleanWords(["hi", "there","flutter"], caseSensitive: true) // returns "i love Flutter."
"i love Flutter.".cleanWords(["hi", "there","flutter"], obscuringCharacter: '#') // returns "i love F#####r."
"i love Flutter.".cleanWords(["hi", "there","flutter"], keepFirstLastLetters: false) // returns "i love *******."

StringContainsWidget highlights the url, email, phone number, hashtag, mention and highLightWords. it provides onTap callback for each element of type StringContainsElementType. StringContainsWidget is a widget that displays a string that contains a certain StringContainsElementTypes.

  StringContainsWidget(
                source:
                    '''I am CEO, Bitch Please visit our website : https://betterx.io/. Please visit our website : https://betterx.io/ and you can search for any thing on google : google.com, I love Dart : https://dart.dev/, you can practice on : https://dartpad.dev/. Flutter uses Dart, you can create your own app with Flutter : https://flutter.dev/, this is a good example of Flutter : https://flutter.dev/docs/get-started/. BetterX.io : Let's build something Better, User-centered & beautiful together for more info contact us at : info@betterx.io. My Personal Email : ravikumar2710999@gmail.com. A fake email : gedoye9446@roxoas.com. My Phone Number : +91-9000000001. I love Dart and Flutter I love #dart and #flutter. @flutter is #awesome''',
                onTap: (url) {
                  print('element is a ${url.value} and type of ${url.type}');
                  if (url.type == StringContainsElementType.words) {
                    ScaffoldMessenger.of(context).showSnackBar(
                      SnackBar(
                        content: Text(
                          '${url.value} is awesome!!',
                        ),
                        duration: const Duration(seconds: 2),
                        dismissDirection: DismissDirection.horizontal,
                      ),
                    );
                  }
                },
                highLightWords: const [
                  'Flutter',
                  'Dart',
                ],
                highlightWordsStyle: const TextStyle(
                  color: Colors.red,
                ),
                types: const [
                  StringContainsElementType.email,
                  StringContainsElementType.url,
                  StringContainsElementType.phoneNumber,
                  StringContainsElementType.hashtag,
                  StringContainsElementType.mention,
                  StringContainsElementType.words,
                ],
),

CleanWidget it used to clean up bad-words/hide emails/hide phoneNumbers/partially or fully hide extra words from the source string. return a clean Text widget.

CleanWidget(
            source:
                      '''I am CEO, Bitch Please visit our website : https://betterx.io/. Please visit our website : https://betterx.io/ and you can search for any thing on google : google.com, I love Dart : https://dart.dev/, you can practice on : https://dartpad.dev/. Flutter uses Dart, you can create your own app with Flutter : https://flutter.dev/, this is a good example of Flutter : https://flutter.dev/docs/get-started/. BetterX.io : Let's build something Better, User-centered & beautiful together for more info contact us at : info@betterx.io. My Personal Email : ravikumar2710999@gmail.com. A fake email : gedoye9446@roxoas.com. My Phone Number : +91-9000000001 I love Dart and Flutter I love #dart and #flutter. @flutter is #awesome''',
                  style: Theme.of(context).textTheme.headline6?.copyWith(
                        color: Theme.of(context).primaryColorDark,
                ),
),

Maintainers

Ravi Kovind

Disclaimer

This library is not a replacement for human review of potentially offensive content. The purpose of this library is to help surface potentially offensive content to human reviewers. It is not a perfect solution for identifying potentially offensive content.

Issues and feedback

Open to suggestions and contributions. Please file issues to send feedback or report a bug. Thank you!

BetterX.io GitHub avatar
GitHub 작성자

BetterX.io ↗

Let's build Something Better, user-centered & Beautiful together.

언어DartC++CMakeHTMLCSwiftKotlinObjective-C

분류

이 저장소가 배포한 패키지

사용 중인 의존성

의존성 목록 3 개

  • flutter{"sdk":"flutter"}
  • flutter_test개발 의존성{"sdk":"flutter"}
  • flutter_lints개발 의존성^3.0.0

프로젝트에 맞는 저장소를 선택하려면?

사용 목적에 따라 검색하고 개발 활동을 비교한 뒤 원본 저장소에서 요구 사항을 확인하세요.

  1. 이름, 작성자 또는 설명으로 검색하고 기술 주제로 범위를 좁힙니다.
  2. 스타, 포크, 최근 푸시를 함께 비교하세요. 스타는 관심의 지표이며 품질을 보장하지 않습니다.
  3. 사용하기 전에 GitHub에서 README, 라이선스, Issues를 확인하세요.

출처 및 관리

“A repository is the most basic element of GitHub.”

GitHub Docs — About repositories ↗