v_story_viewer 2.0.2
v_story_viewer: ^2.0.2 copied to clipboard
A high-performance Flutter story viewer like WhatsApp/Instagram. Supports image, video, text, voice stories with 3D cube transitions.
2.0.2 #
New Features #
- Built-in Text Parser - Lightweight regex-based text parsing for
VTextStory:- Markdown-style formatting: Bold (
**text**,__text__), Italic (*text*,_text_), Inline code (`code`) - Auto-detected links: URLs (http/https/www), Emails, Phone numbers
- Social patterns: @mentions, #hashtags
- Markdown links:
[text](url)syntax
- Markdown-style formatting: Bold (
- Tap Callbacks - Handle user interactions with parsed elements:
onUrlTap(String url)- URL/link tapsonPhoneTap(String phone)- Phone number tapsonEmailTap(String email)- Email tapsonMentionTap(String mention)- @mention taps (without @)onHashtagTap(String hashtag)- #hashtag taps (without #)
- Custom Styling - Override default styles for each parsed element type
- Zero Dependencies - No external markdown or parsing packages required
Usage #
VTextStory(
text: 'Hello **World**! Contact @john at john@email.com #flutter',
enableParsing: true,
parserConfig: VTextParserConfig(
onMentionTap: (mention) => openProfile(mention),
onHashtagTap: (tag) => searchHashtag(tag),
onUrlTap: (url) => launchUrl(url),
onPhoneTap: (phone) => launchDialer(phone),
onEmailTap: (email) => launchEmail(email),
// Optional custom styles
boldStyle: TextStyle(fontWeight: FontWeight.w900),
mentionStyle: TextStyle(color: Colors.blue),
),
backgroundColor: Colors.purple,
createdAt: DateTime.now(),
isSeen: false,
)
2.0.1 #
Breaking Changes #
- Enhanced Error Handling:
onErrorcallback now receivesVStoryErrorinstead ofObject- Enables pattern matching for specific error handling
- Includes original exception, stack trace, and structured error data
New Features #
- Added
VStoryErrorsealed class with 6 error types:VStoryLoadError- General content loading failureVStoryNetworkError- Network connectivity issuesVStoryTimeoutError- Request timeout with duration infoVStoryCacheError- Cache read/write failuresVStoryFormatError- Unsupported media formatVStoryPermissionError- Storage/network permission denied
- Auto-classification of errors based on exception type and message
- All errors include
message,originalError, andstackTracefields - Preset Configurations for cleaner API:
VStoryConfig.forOwner()- Optimized for viewing own stories (no reply, menu visible)VStoryConfig.forViewer()- Optimized for viewing others' stories (reply + emoji visible)VStoryConfig.minimal()- Clean, distraction-free viewing experience
- Added
VStoryConfig.copyWith()method for easy config customization - Story
copyWith()Methods for immutable updates:VImageStory.copyWith()- Create modified image story copiesVVideoStory.copyWith()- Create modified video story copiesVTextStory.copyWith()- Create modified text story copiesVVoiceStory.copyWith()- Create modified voice story copiesVCustomStory.copyWith()- Create modified custom story copies
- VStoryGroup Helpers for easier story management:
unseenStories- List of unseen storiesseenStories- List of seen storiesfirstUnseenStory- First unseen story or nulllatestStory- Most recently created storyoldestStory- Oldest story in the group
Migration Guide #
Error Handling
// Before (2.0.0)
onError: (group, item, error) {
print('Error: $error');
}
// After (2.0.1)
onError: (group, item, error) {
switch (error) {
case VStoryNetworkError():
showSnackBar('Check internet connection');
case VStoryTimeoutError():
showSnackBar('Request timed out');
case VStoryCacheError():
clearCache();
case VStoryFormatError():
log('Unsupported: ${error.format}');
case VStoryPermissionError():
requestPermission();
case VStoryLoadError():
log('Failed: ${error.message}');
}
}
Preset Configurations
// Before (2.0.0) - Manual conditional configuration
VStoryViewer(
config: VStoryConfig(
showReplyField: !isMe,
showEmojiButton: !isMe,
showMenuButton: true,
),
onMenuTap: isMe ? handleOwnerMenu : handleViewerMenu,
)
// After (2.0.1) - Clean preset configs
VStoryViewer(
config: isMe ? VStoryConfig.forOwner() : VStoryConfig.forViewer(),
onMenuTap: isMe ? handleOwnerMenu : handleViewerMenu,
)
// With customization
VStoryViewer(
config: VStoryConfig.forViewer().copyWith(
progressColor: Colors.blue,
showEmojiButton: false,
),
)
Story copyWith
// Mark a story as seen
final seenStory = imageStory.copyWith(isSeen: true);
// Update caption
final updatedStory = videoStory.copyWith(caption: 'New caption!');
VStoryGroup Helpers
// Get unseen stories only
final unseen = group.unseenStories;
// Get the first unread story
final startAt = group.firstUnseenStory;
// Get the most recent story
final latest = group.latestStory;
2.0.0 #
- Complete rewrite with sealed classes for story types
- Added
VImageStory,VVideoStory,VTextStory,VVoiceStory,VCustomStory - 3D cube transitions between user stories
- Segmented progress bar with gradient ring indicator
- RTL support for Arabic/Hebrew layouts
- Keyboard navigation for desktop/web (arrow keys, space, escape)
- Custom overlay support via
overlayBuilder - Rich text support via
richTextandtextBuilder - Exponential backoff retry for failed media (5 attempts)
- 24-hour story expiry filtering
- Comprehensive callbacks:
onStoryViewed,onReply,onSwipeUp,onMenuTap, etc. - Custom header/footer builders via
VStoryConfig - i18n support via
VStoryTexts - Memory optimized: immediate dispose of video/audio controllers
1.0.0 #
- Initial release