FakeRadioPlayer class
An in-memory player for tests, following the same rules as the native
players: setSources selection, kept play state on next and
previous, wrap-around, the volume clamp and the index RangeError.
play goes straight to PlaybackStatus.playing.
final fake = FakeRadioPlayer.install();
await tester.pumpWidget(const MyApp());
fake.state = fake.state.copyWith(
nowPlaying: const NowPlayingInfo(title: 'Miles Davis - So What'),
);
- Inheritance
-
- Object
- PlatformInterface
- FlutterRadioPlayerPlatform
- FakeRadioPlayer
Properties
-
calls
→ List<
String> -
Commands received, in order, e.g.
play,play(index: 2),pause,stop,setVolume(0.5).final - hashCode → int
-
The hash code for this object.
no setterinherited
- options ↔ RadioPlayerOptions
-
The options last set with
setOptions.getter/setter pair - runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- state ↔ RadioPlayerState
-
The fake's current state.
getter/setter pair
-
stateStream
→ Stream<
RadioPlayerState> -
Native state snapshots: the current one once a listener is attached,
then every change. May emit duplicates.
no setteroverride
Methods
-
next(
) → Future< RadioPlayerState> -
Moves to the next source, keeping the play state.
override
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
pause(
) → Future< RadioPlayerState> -
Pauses playback.
override
-
play(
{int? index}) → Future< RadioPlayerState> -
Plays the current source, or source
indexif given.override -
playOrPause(
) → Future< RadioPlayerState> -
Pauses if playback is requested, otherwise plays. Decided natively.
override
-
previous(
) → Future< RadioPlayerState> -
Moves to the previous source, keeping the play state.
override
-
setOptions(
RadioPlayerOptions options) → Future< RadioPlayerState> -
Replaces the options of the shared player.
override
-
setSources(
List< RadioSource> sources, {int? initialIndex, bool autoPlay = false}) → Future<RadioPlayerState> -
Replaces the source list; see
FlutterRadioPlayer.setSources.override -
setVolume(
double volume) → Future< RadioPlayerState> -
Sets the player volume, 0.0 to 1.0.
override
-
stop(
) → Future< RadioPlayerState> -
Stops playback and closes the stream; keeps sources and settings.
override
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Methods
-
install(
) → FakeRadioPlayer - Registers a new fake as the platform and resets FlutterRadioPlayer.instance to idle. Call it at the start of every test; the singleton object stays the same.