Extending mobile video playback to smart TVs is a key requirement for modern media applications. The easy_chromecast_plugin Flutter package makes it straightforward to cast video streams directly from iOS and Android devices to Google Cast receiver devices like Chromecast and Android TV.
Built on top of Pigeon for type-safe native platform interop and backed by Kotlin on Android, this plugin abstracts the underlying Cast SDK into clean Dart interfaces.
When to Use easy_chromecast_plugin
Consider using this plugin when you need to send media playback from mobile screens to television screens. Key use cases include:
- Streaming on-demand video files (.mp4) and HTTP Live Streaming (.m3u8) playlists.
- Broadcasting live IPTV feeds or news broadcasts directly to home TVs.
- Enabling living room presentation or educational watch-together experiences.
Note: The plugin currently focuses on mobile platforms (Android and iOS). Web and desktop support are not available at this time.
Installation
Add the package to your Flutter project using the standard terminal command:
flutter pub add easy_chromecast_pluginPlatform Setup Notes
Because Google Cast relies on native SDK capabilities, native platform configurations are required before initializing the cast controller in Dart:
- Android: Ensure your app manifest includes appropriate network permissions and configures an
OptionsProviderclass for the Google Cast SDK. - iOS: Configure your
Info.plistwith required local network permission keys (such asNSLocalNetworkUsageDescriptionandNSBonjourServices) so your app can discover local Chromecast receivers.
Always verify the latest platform configuration steps directly on pub.dev or the official documentation.
Basic Implementation Example
Below is a complete, runnable example demonstrating how to initialize the plugin, discover local Cast receivers, connect to a target device, and send a stream for remote playback:
import 'package:flutter/material.dart';
import 'package:easy_chromecast_plugin/easy_chromecast_plugin.dart';
void main() => runApp(const MyApp());
class MyApp extends StatelessWidget {
const MyApp({Super.key});
@override
Widget build(BuildContext context) {
return const MaterialApp(
home: CastDemoPage(),
);
}
}
class CastDemoPage extends StatefulWidget {
const CastDemoPage({Super.key});
@override
State<CastDemoPage> createState() => _CastDemoPageState();
}
class _CastDemoPageState extends State<CastDemoPage> {
final _cast = EasyChromecastPlugin();
bool _isInitializing = true;
@override
void initState() {
super.initState();
_initCast();
}
Future<void> _initCast() async {
await _cast.initialize();
if (mounted) {
setState(() {
_isInitializing = false;
});
}
}
Future<void> _startCasting() async {
final devices = await _cast.discoverDevices();
if (devices.isNotEmpty) {
await _cast.connect(devices.first.id);
await _cast.loadMedia(
url: 'https://example.com/video.m3u8',
title: 'Sample Stream',
mimeType: 'application/x-mpegurl',
);
}
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text('Chromecast Demo'),
),
body: Center(
child: _isInitializing
? const CircularProgressIndicator()
: ElevatedButton(
onPressed: _startCasting,
child: const Text('Connect & Cast Stream'),
),
),
);
}
}Pros & Limitations
Pros
- Type-safe API: Generated via Pigeon for reliable inter-process call contracts without manual string-based MethodChannel code.
- Broad Format Support: Plays standard media extensions like
.mp4,.m3u8, and.tsstreams. - Cross-Platform Mobile: Unified Dart API for both Android and iOS targets.
Limitations & Watchouts
- Platform Scope: No web, macOS, or Windows desktop playback capabilities.
- DRM Handling: Limited support for complex Digital Rights Management implementations out of the box.
- Native Setup: Requires native Android/iOS project file modifications prior to building.
Package Alternatives
If your project has specialized requirements, you might also evaluate alternatives such as flutter_cast_framework or cast_video_player.
Frequently Asked Questions
Which video formats does the easy_chromecast_plugin support?
The plugin supports popular media formats including HLS (.m3u8), MPEG-TS (.ts), and standard MP4 files (.mp4).
Does easy_chromecast_plugin support Web or Desktop targets?
No, the plugin currently targets Android and iOS platforms.
How does easy_chromecast_plugin communicate with native Cast SDKs?
It uses Pigeon to generate type-safe bindings between Dart and native Kotlin/Swift platforms with low invocation overhead.