reelplexi_sdk 1.0.0
reelplexi_sdk: ^1.0.0 copied to clipboard
Official Flutter SDK for Reelplexi — stream African movies and TV series with a single API key. Includes a full API client and a plug-and-play ReelplexiPlayer widget.
example/lib/main.dart
import 'package:flutter/material.dart';
import 'package:reelplexi_sdk/reelplexi_sdk.dart';
void main() {
WidgetsFlutterBinding.ensureInitialized();
// Initialize Reelplexi SDK with your API key
Reelplexi.init(
apiKey: 'sk_test_demo_key',
baseUrl: 'https://api.reelplexi.com',
);
runApp(const ReelplexiExampleApp());
}
class ReelplexiExampleApp extends StatelessWidget {
const ReelplexiExampleApp({super.key});
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Reelplexi SDK Demo',
theme: ThemeData.dark().copyWith(
scaffoldBackgroundColor: const Color(0xFF0F0F13),
colorScheme: const ColorScheme.dark(
primary: Color(0xFFE50914),
surface: Color(0xFF1B1B22),
),
),
home: const MovieListScreen(),
);
}
}
class MovieListScreen extends StatefulWidget {
const MovieListScreen({super.key});
@override
State<MovieListScreen> createState() => _MovieListScreenState();
}
class _MovieListScreenState extends State<MovieListScreen> {
late Future<MovieListResponse> _moviesFuture;
@override
void initState() {
super.initState();
_moviesFuture = Reelplexi.client.movies.list(perPage: 20);
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text('Reelplexi Movies'),
backgroundColor: const Color(0xFF1B1B22),
),
body: FutureBuilder<MovieListResponse>(
future: _moviesFuture,
builder: (context, snapshot) {
if (snapshot.connectionState == ConnectionState.waiting) {
return const Center(child: CircularProgressIndicator());
}
if (snapshot.hasError) {
return Center(
child: Padding(
padding: const EdgeInsets.all(16.0),
child: Text(
'Error loading movies: ${snapshot.error}',
textAlign: TextAlign.center,
style: const TextStyle(color: Colors.redAccent),
),
),
);
}
final movies = snapshot.data?.data ?? [];
if (movies.isEmpty) {
return const Center(child: Text('No movies found'));
}
return ListView.builder(
itemCount: movies.length,
itemBuilder: (context, index) {
final movie = movies[index];
return ListTile(
leading: movie.posterUrl != null
? Image.network(
movie.posterUrl!,
width: 50,
fit: BoxFit.cover,
errorBuilder: (_, __, ___) => const Icon(Icons.movie),
)
: const Icon(Icons.movie),
title: Text(movie.title ?? 'Untitled'),
subtitle: Text(
[
if (movie.vj != null) 'VJ: ${movie.vj}',
if (movie.genres.isNotEmpty) movie.genres.join(', '),
].join(' • '),
maxLines: 1,
overflow: TextOverflow.ellipsis,
),
trailing: const Icon(Icons.play_circle_fill, color: Color(0xFFE50914)),
onTap: () {
Navigator.of(context).push(
MaterialPageRoute(
builder: (_) => MoviePlayerScreen(movie: movie),
),
);
},
);
},
);
},
),
);
}
}
class MoviePlayerScreen extends StatelessWidget {
final Movie movie;
const MoviePlayerScreen({super.key, required this.movie});
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text(movie.title ?? 'Player'),
backgroundColor: const Color(0xFF1B1B22),
),
body: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
AspectRatio(
aspectRatio: 16 / 9,
child: ReelplexiPlayer.movie(movieId: movie.id),
),
Padding(
padding: const EdgeInsets.all(16.0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
movie.title ?? '',
style: Theme.of(context).textTheme.headlineSmall,
),
const SizedBox(height: 8),
if (movie.overview != null)
Text(
movie.overview!,
style: Theme.of(context).textTheme.bodyMedium?.copyWith(
color: Colors.white70,
),
),
],
),
),
],
),
);
}
}