BlueskyText class sealed
This class provides high-performance analysis of Bluesky Social's text and features related to secure posting.
By using the analysis feature of this class, you can get the values of all the following entities contained in the text and the Indices that can be used as is when posting using the Bluesky API.
The value of this Indices is counted based on the number of byte characters
and can be used as is for ByteSlice
in the facets
parameter of
app.bsky.feed.post
in the Bluesky API.
It supports analysis of the following entities.
- Handle (like @shinyakato.dev)
- Link (like https://shinyakato.dev)
- Tag (like #hashtag)
The class also supports counting the number of characters using grapheme
,
and the length of the string that can be obtained with length is
the one counted using grapheme. In other words, as per Bluesky Social's
official specifications, an emoji is counted as one character.
How To Use
You simply pass any text to the BlueskyText object to create an instance like following.
final text = BlueskyText(
'I speak 日本語 and English 🚀 @shinyakato.dev and @shinyakato.bsky.social. '
'Visit 🚀 https://shinyakato.dev.',
);
The length of the string passed to BlueskyText can be longer than 300 characters in grapheme. But, if there is a possibility that more than 300 characters of text will be passed, be sure to check if the character count is exceeded and split the BlueskyText using the split method as follows.
final text = BlueskyText(
'I speak 日本語 and English 🚀 @shinyakato.dev and @shinyakato.bsky.social. '
'Visit 🚀 https://shinyakato.dev.',
);
if (text.isLengthLimitExceeded) {
final texts = text.split();
for (final text in texts) {
print(text.handles);
print(text.links);
print(text.entities);
}
} else {
print(text.handles);
print(text.links);
print(text.entities);
}
Constructors
- BlueskyText(String text, {bool enableMarkdown, LinkConfig? linkConfig, Replacements? replacements})
-
Returns the new instance of BlueskyText.
constfactory
Properties
- entities → Entities
-
Returns the collection of entities.
no setter
- handles → Entities
-
Returns the collection of handles.
no setter
- hashCode → int
-
The hash code for this object.
no setterinherited
- isEmojiOnly → bool
-
Returns true if this text contains only emoji, otherwise false.
no setter
- isEmpty → bool
-
Returns true if this value is empty, otherwise false.
no setter
- isLengthLimitExceeded → bool
-
Returns true if this length is more than 300 chars,
otherwise false.
no setter
- isNotEmojiOnly → bool
-
Returns true if this text not contains only emoji, otherwise false.
no setter
- isNotEmpty → bool
-
Returns true if this value is not empty, otherwise false.
no setter
- isNotLengthLimitExceeded → bool
-
Returns true if this length is not more than 300 chars,
otherwise false.
no setter
- length → int
-
Returns the length of this value.
no setter
- links → Entities
-
Returns the collection of links.
no setter
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
-
Returns the collection of tags.
no setter
- value → String
-
Returns the resource text.
no setter
Methods
-
format(
) → BlueskyText - Returns a new formatted BlueskyText based on configs.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
split(
) → List< BlueskyText> - Splits this value.
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited