Skip to main content

flutter_radio_player 5.0.0-dev.2 copy "flutter_radio_player: ^5.0.0-dev.2" to clipboard
flutter_radio_player: ^5.0.0-dev.2 copied to clipboard

Online Radio Player for Flutter with background playback, lock screen controls, and streaming support for Android and iOS.

example/lib/main.dart

import 'package:flutter_radio_player/flutter_radio_player.dart';
import 'package:material_ui/material_ui.dart';

final player = FlutterRadioPlayer.instance;

void main() {
  WidgetsFlutterBinding.ensureInitialized();
  player.setSources(const [
    RadioSource(
      url: 'https://s2-webradio.antenne.de/chillout?icy=https',
      title: 'Antenne Chillout',
    ),
    RadioSource(
      url: 'https://radio.lotustechnologieslk.net:2020/stream/sunfmgarden?icy=https',
      title: 'SunFM - Sri Lanka',
    ),
  ]);
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Radio Player',
      theme: ThemeData(
        colorSchemeSeed: Colors.deepPurple,
        brightness: Brightness.dark,
        useMaterial3: true,
      ),
      home: Scaffold(
        appBar: AppBar(title: const Text('Flutter Radio Player')),
        body: RadioPlayerBuilder(
          builder: (context, state) => Column(
            children: [
              if (state.isLoading) const LinearProgressIndicator(),
              const SizedBox(height: 24),
              Text(
                state.nowPlaying?.title ?? state.currentSource?.title ?? '',
                style: Theme.of(context).textTheme.titleLarge,
                textAlign: TextAlign.center,
              ),
              if (state.error case final error?)
                Text(
                  error.message,
                  style: TextStyle(color: Theme.of(context).colorScheme.error),
                ),
              IconButton(
                iconSize: 48,
                icon: Icon(state.isPlaying ? Icons.pause : Icons.play_arrow),
                onPressed: player.playOrPause,
              ),
              Slider(value: state.volume, onChanged: player.setVolume),
              for (final (index, source) in state.sources.indexed)
                ListTile(
                  title: Text(source.title ?? source.url),
                  selected: index == state.currentIndex,
                  onTap: () => player.play(index: index),
                ),
            ],
          ),
        ),
      ),
    );
  }
}
137
likes
160
points
244
downloads

Documentation

API reference

Publisher

unverified uploader

Weekly Downloads

Online Radio Player for Flutter with background playback, lock screen controls, and streaming support for Android and iOS.

Repository (GitHub)
View/report issues

License

MIT (license)

Dependencies

flutter, flutter_radio_player_android, flutter_radio_player_ios, flutter_radio_player_platform_interface

More

Packages that depend on flutter_radio_player

Packages that implement flutter_radio_player