flutter_subtitle
0.0.6, released a year ago by an unverified publisher
Displays WebVTT or SRT subtitles in Flutter video players.
WASM-ready
What it does
Parses WebVTT and SRT subtitle files and provides controllers and widgets to render them over video playback. Works with common video players like Chewie and video_player.
AI-written summary of version 0.0.6, based on the package's README and metadata. Report an inaccuracy
Use it when
- You need to show subtitles/captions for video content in a Flutter app
- You require built‑in support for WebVTT and SRT formats without writing your own parser
Skip it when
- You need advanced subtitle styling or format support beyond WebVTT/SRT
- You require a full‑featured captioning solution with multiple languages or accessibility features
Strengths
- Simple API for loading and displaying subtitles
- Supports both WebVTT and SRT out of the box
- Integrates easily with Chewie and video_player
Weaknesses
- Limited to basic subtitle rendering; no extensive styling options
- No support for other subtitle formats (e.g., ASS)
Setup
- Kind
- Flutter widgets
- Effort
- Low
- Code generation
- No
- Direct dependencies
- 0
import 'dart:convert' show utf8;
import 'package:chewie/chewie.dart';
import 'package:flutter/material.dart';
import 'package:flutter_subtitle/flutter_subtitle.dart' hide Subtitle;
import 'package:video_player/video_player.dart';
import 'package:http/http.dart' as http;
// inside your widget
final body = utf8.decode((await http.get(Uri.parse('https://example.com/subtitles.vtt'))).bodyBytes);
final subtitleController = SubtitleController.string(body, format: SubtitleFormat.webvtt);
final videoController = VideoPlayerController.networkUrl(Uri.parse('https://example.com/video.mp4'));
await videoController.initialize();
final chewieController = ChewieController(
videoPlayerController: videoController,
subtitleBuilder: (context, subtitle) => SubtitleView(text: subtitle),
);
chewieController.setSubtitle(subtitleController.subtitles.map((e) => Subtitle(index:e.number,start:Duration(milliseconds:e.start),end:Duration(milliseconds:e.end),text:e.text)).toList());