Skip to content

Commit

Permalink
Set minimum Flutter 3 for just_audio
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanheise committed May 15, 2023
1 parent 3f61f23 commit 4b63240
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 25 deletions.
4 changes: 4 additions & 0 deletions just_audio/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 0.9.33

* Update minimum flutter version to 3.0.

## 0.9.32

* Fix ignored tag parameter in AudioSource.asset().
Expand Down
7 changes: 4 additions & 3 deletions just_audio/analysis_options.yaml
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
include: package:flutter_lints/flutter.yaml

analyzer:
strong-mode:
implicit-casts: false
implicit-dynamic: false
language:
strict-casts: true
strict-inference: true
strict-raw-types: true

linter:
rules:
Expand Down
2 changes: 1 addition & 1 deletion just_audio/example/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ environment:
dependencies:
flutter:
sdk: flutter
audio_session: ^0.1.11
audio_session: ^0.1.14
rxdart: ^0.27.7
just_audio_mpv: ^0.1.6
just_audio_windows: ^0.2.0
Expand Down
16 changes: 8 additions & 8 deletions just_audio/lib/just_audio.dart
Original file line number Diff line number Diff line change
Expand Up @@ -86,13 +86,13 @@ class AudioPlayer {
/// implementation. When switching between active and inactive modes, this is
/// used to cancel the subscription to the previous platform's events and
/// subscribe to the new platform's events.
StreamSubscription? _playbackEventSubscription;
StreamSubscription<PlaybackEventMessage>? _playbackEventSubscription;

/// The subscription to the data event channel of the current platform
/// implementation. When switching between active and inactive modes, this is
/// used to cancel the subscription to the previous platform's events and
/// subscribe to the new platform's events.
StreamSubscription? _playerDataSubscription;
StreamSubscription<PlayerDataMessage>? _playerDataSubscription;

final String _id;
final _proxy = _ProxyHttpServer();
Expand Down Expand Up @@ -614,8 +614,8 @@ class AudioPlayer {
}

Timer? currentTimer;
StreamSubscription? durationSubscription;
StreamSubscription? playbackEventSubscription;
StreamSubscription<Duration?>? durationSubscription;
StreamSubscription<PlaybackEvent>? playbackEventSubscription;
void yieldPosition(Timer timer) {
if (controller.isClosed) {
timer.cancel();
Expand Down Expand Up @@ -1992,13 +1992,13 @@ class _ProxyHttpServer {
String _requestKey(Uri uri) => '${uri.path}?${uri.query}';

/// Start the server if it is not already running.
Future ensureRunning() async {
Future<dynamic> ensureRunning() async {
if (_running) return;
return await start();
}

/// Starts the server.
Future start() async {
Future<dynamic> start() async {
_running = true;
_server = await HttpServer.bind(InternetAddress.loopbackIPv4, 0);
_server.listen((request) async {
Expand All @@ -2015,7 +2015,7 @@ class _ProxyHttpServer {
}

/// Stops the server
Future stop() async {
Future<dynamic> stop() async {
if (!_running) return;
_running = false;
return await _server.close();
Expand Down Expand Up @@ -2841,7 +2841,7 @@ class LockCachingAudioSource extends StreamAudioSource {
final mimeFile = await _mimeFile;
await mimeFile.writeAsString(mimeType);
final inProgressResponses = <_InProgressCacheResponse>[];
late StreamSubscription subscription;
late StreamSubscription<List<int>> subscription;
var percentProgress = 0;
void updateProgress(int newPercentProgress) {
if (newPercentProgress != percentProgress) {
Expand Down
17 changes: 11 additions & 6 deletions just_audio/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,21 +1,26 @@
name: just_audio
description: A feature-rich audio player for Flutter. Loop, clip and concatenate any sound from any source (asset/file/URL/stream) in a variety of audio formats with gapless playback.
version: 0.9.32
version: 0.9.33
repository: https://github.com/ryanheise/just_audio/tree/minor/just_audio
issue_tracker: https://github.com/ryanheise/just_audio/issues
topics:
- audio
- sound
- player
- background

environment:
sdk: ">=2.12.0 <3.0.0"
flutter: ">=1.12.13+hotfix.5"
sdk: ">=2.14.0 <4.0.0"
flutter: ">=3.0.0"

dependencies:
just_audio_platform_interface: ^4.2.0
just_audio_platform_interface: ^4.2.1
# just_audio_platform_interface:
# path: ../just_audio_platform_interface
just_audio_web: ^0.4.7
just_audio_web: ^0.4.8
# just_audio_web:
# path: ../just_audio_web
audio_session: ^0.1.11
audio_session: ^0.1.14
rxdart: '>=0.26.0 <0.28.0'
path: ^1.8.0
path_provider: ^2.0.0
Expand Down
21 changes: 14 additions & 7 deletions just_audio/test/just_audio_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,18 @@ void runTests() {
}

setUp(() {
audioSessionChannel.setMockMethodCallHandler((MethodCall methodCall) async {
_ambiguate(TestDefaultBinaryMessengerBinding.instance)!
.defaultBinaryMessenger
.setMockMethodCallHandler(audioSessionChannel,
(MethodCall methodCall) async {
return null;
});
});

tearDown(() {
audioSessionChannel.setMockMethodCallHandler(null);
_ambiguate(TestDefaultBinaryMessengerBinding.instance)!
.defaultBinaryMessenger
.setMockMethodCallHandler(audioSessionChannel, null);
});

test('init', () async {
Expand Down Expand Up @@ -346,7 +351,7 @@ void runTests() {
stopwatch.start();

var completer = Completer<dynamic>();
late StreamSubscription subscription;
late StreamSubscription<Duration> subscription;
subscription = player.positionStream.listen((position) {
if (position >= position1) {
subscription.cancel();
Expand Down Expand Up @@ -1091,7 +1096,7 @@ void runTests() {
playing: false,
);
var completer = Completer<dynamic>();
late StreamSubscription subscription;
late StreamSubscription<Duration> subscription;
subscription = player.positionStream.listen((position) {
expectDuration(position, Duration.zero);
subscription.cancel();
Expand Down Expand Up @@ -1170,7 +1175,7 @@ void runTests() {
);
expect(player.currentIndex, 0);
var completer = Completer<dynamic>();
late StreamSubscription subscription;
late StreamSubscription<Duration> subscription;
subscription = player.positionStream.listen((position) {
expectDuration(position, Duration.zero);
subscription.cancel();
Expand Down Expand Up @@ -1743,7 +1748,7 @@ class MockWebServer {
late HttpServer _server;
int get port => _server.port;

Future start() async {
Future<void> start() async {
_server = await HttpServer.bind(InternetAddress.loopbackIPv4, 0);
_server.listen((request) async {
final response = request.response;
Expand All @@ -1766,7 +1771,9 @@ class MockWebServer {
});
}

Future stop() => _server.close();
Future<void> stop() => _server.close();
}

class MyHttpOverrides extends HttpOverrides {}

T? _ambiguate<T>(T? value) => value;

0 comments on commit 4b63240

Please sign in to comment.