bluesky_text 1.5.3
bluesky_text: ^1.5.3 copied to clipboard
Provides the easiest and most powerful way to analyze the text for Bluesky Social.
The Easiest & Most Powerful Way to Analyze the Text for Bluesky Social 🦋
1. Guide 🌎 #
Provides the easiest and most powerful way to analyze the text on Bluesky Social in Dart and Flutter apps.
Have you ever had trouble parsing mentions or links in the text you post when using Bluesky Social's API? If so, this is the library you are looking for!
1.1. Features ⭐ #
- ✅ Zero Dependency
- ✅ Automatic Detection of
Handle,Link,Tagin text - ✅ Supports Automatic Conversion to Facet
- ✅ 100% Compatible with bluesky
- ✅ Supports Unicode Grapheme Clusters
- ✅ Supports Safe Text Splitting
- ✅ Works in All Languages
- ✅ Supports Markdown Style Links
- ✅ Well Documented and Well Tested
- ✅ 100% Null Safety
1.2. Getting Started 💪 #
Pass any text to BlueskyText, read the detected entities, and convert it into
the text + facets you post with the Bluesky API — all zero-dependency.
import 'package:bluesky_text/bluesky_text.dart';
Future<void> main() async {
final text = BlueskyText(
'I speak 日本語 and English 🚀 @shinyakato.dev and @shinyakato.bsky.social. '
'Visit 🚀 https://shinyakato.dev.',
);
// Extract entities. Each carries its value and byte indices.
print(text.handles); // @shinyakato.dev, @shinyakato.bsky.social
print(text.links); // https://shinyakato.dev
print(text.entities); // handles, links and tags in document order
// Build everything needed to create a post in one call: the formatted text,
// its facets, and any handles that failed to resolve to a DID.
final data = await text.toPostData();
if (data.unresolvedHandles.isNotEmpty) {
print('Could not resolve: ${data.unresolvedHandles}');
}
print(data.text); // formatted, posting-ready text
print(data.facets); // facets ready for `app.bsky.feed.post`
}
toPostData({String? service, HandleResolver? resolver}) resolves mention DIDs
against bsky.social by default; pass a service to target another PDS, or a
resolver to serve DIDs from your own cache instead of a per-handle network
call. The returned facets map straight onto RichtextFacet.fromJson when
posting with bluesky.
See example or official documents from following links.