test: use isTrue/isFalse matcher
This commit is contained in:
parent
f5b940bc07
commit
79d192a441
21
README.md
21
README.md
|
@ -1,18 +1,23 @@
|
|||
# linkfy_text
|
||||
|
||||
A lightweight flutter package to linkify texts containing urls, emails and hashtags.
|
||||
|
||||
<!-- [](https://pub.dev/packages/linkfy_text) -->
|
||||
]
|
||||
[](https://pub.dev/packages/linkfy_text)
|
||||
|
||||
## Using
|
||||

|
||||
|
||||
## Usage
|
||||
|
||||
```dart
|
||||
// first import the package
|
||||
import 'package:linkfy_text/linkify_text.dart';
|
||||
|
||||
LinkifyText(
|
||||
"This text contains a url: https://flutter.dev",
|
||||
linkStyle: TextStyle(color: Colors.blue, fontSize: 16),
|
||||
onTap: (link) {
|
||||
// onTap is called when a link is pressed
|
||||
print("${link.value}");
|
||||
/// do stuff with `link`
|
||||
},
|
||||
);
|
||||
```
|
||||
|
@ -21,11 +26,13 @@ Be default, The above snippet would linkify all urls in the string, you can choo
|
|||
|
||||
```dart
|
||||
LinkifyText(
|
||||
"This text contains an #hashtag",
|
||||
"This text contains an #hashtag and a url",
|
||||
linkStyle: TextStyle(color: Colors.blue, fontSize: 16),
|
||||
linkTypes: [LinkType.hashtag]
|
||||
linkTypes: [LinkType.url, LinkType.hashtag]
|
||||
onTap: (link) {
|
||||
print("${link.value}");
|
||||
/// do stuff with `link`
|
||||
},
|
||||
);
|
||||
```
|
||||
|
||||
|
||||
|
|
|
@ -42,7 +42,7 @@ void main() {
|
|||
test("Should match all emails", () {
|
||||
_emails.forEach((e) {
|
||||
bool hasMatch = RegExp(emailRegExp).hasMatch(e);
|
||||
expect(hasMatch, true);
|
||||
expect(hasMatch, isTrue);
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -50,25 +50,25 @@ void main() {
|
|||
List<String> _emails = ["hello@world", "@js.com"];
|
||||
_emails.forEach((e) {
|
||||
bool hasMatch = RegExp(emailRegExp).hasMatch(e);
|
||||
expect(hasMatch, false);
|
||||
expect(hasMatch, isFalse);
|
||||
});
|
||||
});
|
||||
|
||||
test("Should match all urls", () {
|
||||
_urls.forEach((u) {
|
||||
bool hasMatch = RegExp(urlRegExp).hasMatch(u);
|
||||
expect(hasMatch, true);
|
||||
expect(hasMatch, isTrue);
|
||||
});
|
||||
});
|
||||
|
||||
test("Should match all hashtags", () {
|
||||
_hashtags.forEach((h) {
|
||||
bool hasMatch = RegExp(hashtagRegExp).hasMatch(h);
|
||||
expect(hasMatch, true);
|
||||
expect(hasMatch, isTrue);
|
||||
});
|
||||
});
|
||||
|
||||
test("Should construct regex pattern from LinkTypes and match", () {
|
||||
test("Should construct regex pattern from LinkTypes and match length", () {
|
||||
RegExp _urlRegExp = constructRegExpFromLinkType([LinkType.url]);
|
||||
RegExp _hashtagRegExp = constructRegExpFromLinkType([LinkType.hashTag]);
|
||||
RegExp _emailRegExp = constructRegExpFromLinkType([LinkType.email]);
|
||||
|
|
Loading…
Reference in New Issue