Skip to content

Commit 411f29b

Browse files
authored
Merge pull request #890 from diegotori/fix_issue_888
Fix issue 888
2 parents d5d66ea + 8ac8700 commit 411f29b

File tree

6 files changed

+128
-56
lines changed

6 files changed

+128
-56
lines changed

.github/workflows/ci.yml

Lines changed: 41 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -11,46 +11,51 @@ on:
1111
- '**.md'
1212
workflow_dispatch:
1313

14+
concurrency:
15+
group: ${{ github.workflow }}-${{ github.ref }}
16+
cancel-in-progress: true
17+
1418
jobs:
15-
check-format:
16-
name: Check format using dart format.
17-
runs-on: ubuntu-latest
18-
19-
steps:
20-
- name: Checkout code
21-
uses: actions/checkout@v4
22-
- name: Flutter Action
23-
uses: subosito/flutter-action@v2
24-
- name: Check format
25-
run: dart format . --set-exit-if-changed
26-
27-
lint:
28-
name: Lint
19+
# Does a sanity check that packages at least pass analysis on the N-1
20+
# versions of Flutter stable if the package claims to support that version.
21+
# This is to minimize accidentally making changes that break old versions
22+
# (which we don't commit to supporting, but don't want to actively break)
23+
# without updating the constraints.
24+
lint_and_build:
25+
name: Flutter Version ${{ matrix.flutter-version }} Lint and Build.
2926
runs-on: ubuntu-latest
30-
27+
strategy:
28+
matrix:
29+
flutter-version:
30+
# The version of Flutter to use should use the minimum Dart SDK version supported by the package,
31+
# refer to https://docs.flutter.dev/development/tools/sdk/releases.
32+
# Note: The version below should be manually updated to the latest second most recent version
33+
# after a new stable version comes out.
34+
- "3.24.5"
35+
- "3.x"
3136
steps:
32-
- name: Checkout code
37+
- name: 📚 Git Checkout
3338
uses: actions/checkout@v4
34-
- name: Flutter Action
39+
40+
- name: 🐦 Setup Flutter
3541
uses: subosito/flutter-action@v2
36-
- name: Install Package Dependencies
42+
with:
43+
flutter-version: ${{ matrix.flutter-version }}
44+
channel: stable
45+
cache: true
46+
cache-key: flutter-:os:-:channel:-:version:-:arch:-:hash:-${{ hashFiles('**/pubspec.lock') }}
47+
48+
- name: 📦 Install Dependencies
3749
run: flutter packages get
38-
- name: Get dependencies for example
39-
run: flutter pub get
40-
working-directory: example
41-
- name: Lint using flutter analyze
42-
run: flutter analyze .
43-
44-
test:
45-
name: Run tests.
46-
runs-on: ubuntu-latest
4750

48-
steps:
49-
- name: Checkout code
50-
uses: actions/checkout@v4
51-
- name: Flutter Action
52-
uses: subosito/flutter-action@v2
53-
- name: Run flutter test
54-
run: |
55-
flutter pub get
56-
flutter test
51+
- name: ✨ Check Formatting
52+
run: dart format --set-exit-if-changed lib
53+
54+
- name: 🕵️ Analyze
55+
run: flutter analyze lib
56+
57+
- name: 🧪 Run Tests
58+
run: flutter test --no-pub --coverage --test-randomize-ordering-seed random
59+
60+
- name: 📁 Upload coverage to Codecov
61+
uses: codecov/codecov-action@v5

README.md

Lines changed: 48 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,53 @@
88

99
The video player for Flutter with a heart of gold.
1010

11-
The [`video_player`](https://pub.dartlang.org/packages/video_player) plugin provides low-level access to video playback. Chewie uses the `video_player` under the hood and wraps it in a friendly Material or Cupertino UI!
11+
The [`video_player`](https://pub.dartlang.org/packages/video_player) plugin provides low-level
12+
access to video playback.
1213

13-
## Preview
14+
Chewie uses the `video_player` under the hood and wraps it in a friendly Material or Cupertino UI!
1415

15-
| MaterialControls | MaterialDesktopControls |
16-
| :--------------: | :---------------------: |
17-
| ![](https://github.com/brianegan/chewie/raw/master/assets/MaterialControls.png) | ![](https://github.com/brianegan/chewie/raw/master/assets/MaterialDesktopControls.png) |
16+
## Table of Contents
17+
1. 🚨 [IMPORTANT!!! (READ THIS FIRST)](#-important-read-this-first)
18+
2. 🔀 [Flutter Version Compatibility](#-flutter-version-compatibility)
19+
3. 🖼️ [Preview](#-preview)
20+
4. ⬇️ [Installation](#-installation)
21+
5. 🕹️ [Using it](#-using-it)
22+
6. ⚙️ [Options](#-options)
23+
7. 🔡 [Subtitles](#-subtitles)
24+
8. 🧪 [Example](#-example)
25+
9.[Migrating from Chewie < 0.9.0](#-migrating-from-chewie--090)
26+
10. 🗺️ [Roadmap](#-roadmap)
27+
11. 📱 [iOS warning](#-ios-warning-)
28+
29+
30+
## 🚨 IMPORTANT!!! (READ THIS FIRST)
31+
This library is __NOT__ responsible for any issues caused by `video_player`, since it's merely a UI
32+
layer on top of it.
33+
34+
In other words, if you see any `PlatformException`s being thrown in your app due to video playback,
35+
they are exclusive to the `video_player` library.
36+
37+
Instead, please raise an issue related to it with the [Flutter Team](https://github.com/flutter/flutter/issues/new/choose).
38+
39+
## 🔀 Flutter Version Compatibility
40+
41+
This library will at the very least make a solid effort to support the second most recent version
42+
of Flutter released. In other words, it will adopt `N-1` version support at
43+
the bare minimum.
44+
45+
However, this cannot be guaranteed due to major changes between Flutter versions. Should that occur,
46+
future updates will be released as major or minor versions as needed.
47+
48+
## 🖼️ Preview
49+
50+
| MaterialControls | MaterialDesktopControls |
51+
|:-------------------------------------------------------------------------------:|:--------------------------------------------------------------------------------------:|
52+
| ![](https://github.com/brianegan/chewie/raw/master/assets/MaterialControls.png) | ![](https://github.com/brianegan/chewie/raw/master/assets/MaterialDesktopControls.png) |
1853

1954
### CupertinoControls
2055
![](https://github.com/brianegan/chewie/raw/master/assets/CupertinoControls.png)
2156

22-
## Installation
57+
## ⬇️ Installation
2358

2459
In your `pubspec.yaml` file within your Flutter Project add `chewie` and `video_player` under dependencies:
2560

@@ -29,7 +64,7 @@ dependencies:
2964
video_player: <latest_version>
3065
```
3166
32-
## Using it
67+
## 🕹️ Using it
3368
3469
```dart
3570
import 'package:chewie/chewie.dart';
@@ -61,7 +96,7 @@ void dispose() {
6196
}
6297
```
6398

64-
## Options
99+
## ⚙️ Options
65100

66101
![](https://github.com/brianegan/chewie/raw/master/assets/Options.png)
67102

@@ -127,7 +162,7 @@ optionsTranslation: OptionsTranslation(
127162
),
128163
```
129164

130-
## Subtitles
165+
## 🔡 Subtitles
131166

132167
> Since version 1.1.0, Chewie supports subtitles.
133168
@@ -195,11 +230,11 @@ Subtitle(
195230

196231
Use the `subtitleBuilder` function to customize how subtitles are rendered, allowing you to modify text styles, add padding, or apply other customizations to your subtitles.
197232

198-
## Example
233+
## 🧪 Example
199234

200235
Please run the app in the [`example/`](https://github.com/brianegan/chewie/tree/master/example) folder to start playing!
201236

202-
## Migrating from Chewie < 0.9.0
237+
## Migrating from Chewie < 0.9.0
203238

204239
Instead of passing the `VideoPlayerController` and your options to the `Chewie` widget you now pass them to the `ChewieController` and pass that later to the `Chewie` widget.
205240

@@ -225,7 +260,7 @@ final playerWidget = Chewie(
225260
);
226261
```
227262

228-
## Roadmap
263+
## 🗺️ Roadmap
229264

230265
- [x] MaterialUI
231266
- [x] MaterialDesktopUI
@@ -251,7 +286,7 @@ final playerWidget = Chewie(
251286
- [ ] Screen-Mirroring / Casting (Google Chromecast)
252287

253288

254-
## iOS warning
289+
## 📱 iOS warning
255290

256291
The video_player plugin used by chewie will only work in iOS simulators if you are on flutter 1.26.0 or above. You may need to switch to the beta channel `flutter channel beta`
257292
Please refer to this [issue](https://github.com/flutter/flutter/issues/14647).
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import 'package:flutter/material.dart';
2+
3+
//ignore_for_file: deprecated_member_use
4+
extension ColorCompatExtensions on Color {
5+
/// Returns a new color that matches this color with the given opacity.
6+
///
7+
/// This is a compatibility layer that ensures compatibility with Flutter
8+
/// versions below 3.27. In Flutter 3.27 and later, `Color.withOpacity`
9+
/// has been deprecated in favor of `Color.withValues`.
10+
///
11+
/// This method bridges the gap by providing a consistent way to adjust
12+
/// the opacity of a color across different Flutter versions.
13+
///
14+
/// **Important:** Once the minimum supported Flutter version is bumped
15+
/// to 3.27 or higher, this method should be removed and replaced with
16+
/// `withValues(alpha: opacity)`.
17+
///
18+
/// See also:
19+
/// * [Color.withOpacity], which is deprecated in Flutter 3.27 and later.
20+
/// * [Color.withValues], the recommended replacement for `withOpacity`.
21+
Color withOpacityCompat(double opacity) {
22+
// Compatibility layer that uses the legacy withOpacity method, while
23+
// ignoring the deprecation for now (in order to guarantee N-1 minimum
24+
// version compatibility).
25+
// Once it's removed from a future update, we'll have to replace uses of
26+
// this method with withValues(alpha: opacity).
27+
// TODO: Replace this bridge method once the above holds true.
28+
return withOpacity(opacity);
29+
}
30+
}

lib/src/material/material_controls.dart

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import 'package:chewie/src/center_seek_button.dart';
55
import 'package:chewie/src/chewie_player.dart';
66
import 'package:chewie/src/chewie_progress_colors.dart';
77
import 'package:chewie/src/helpers/utils.dart';
8+
import 'package:chewie/src/material/color_compat_extensions.dart';
89
import 'package:chewie/src/material/material_progress_bar.dart';
910
import 'package:chewie/src/material/widgets/options_dialog.dart';
1011
import 'package:chewie/src/material/widgets/playback_speed_dialog.dart';
@@ -470,7 +471,7 @@ class _MaterialControlsState extends State<MaterialControls>
470471
text: '/ ${formatDuration(duration)}',
471472
style: TextStyle(
472473
fontSize: 14.0,
473-
color: Colors.white.withValues(alpha: .75),
474+
color: Colors.white.withOpacityCompat(.75),
474475
fontWeight: FontWeight.normal,
475476
),
476477
)
@@ -683,9 +684,9 @@ class _MaterialControlsState extends State<MaterialControls>
683684
playedColor: Theme.of(context).colorScheme.secondary,
684685
handleColor: Theme.of(context).colorScheme.secondary,
685686
bufferedColor:
686-
Theme.of(context).colorScheme.surface.withValues(alpha: 0.5),
687+
Theme.of(context).colorScheme.surface.withOpacityCompat(0.5),
687688
backgroundColor:
688-
Theme.of(context).disabledColor.withValues(alpha: .5),
689+
Theme.of(context).disabledColor.withOpacityCompat(.5),
689690
),
690691
draggableProgressBar: chewieController.draggableProgressBar,
691692
),

lib/src/material/material_desktop_controls.dart

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import 'package:chewie/src/center_play_button.dart';
55
import 'package:chewie/src/chewie_player.dart';
66
import 'package:chewie/src/chewie_progress_colors.dart';
77
import 'package:chewie/src/helpers/utils.dart';
8+
import 'package:chewie/src/material/color_compat_extensions.dart';
89
import 'package:chewie/src/material/material_progress_bar.dart';
910
import 'package:chewie/src/material/widgets/options_dialog.dart';
1011
import 'package:chewie/src/material/widgets/playback_speed_dialog.dart';
@@ -649,9 +650,9 @@ class _MaterialDesktopControlsState extends State<MaterialDesktopControls>
649650
playedColor: Theme.of(context).colorScheme.secondary,
650651
handleColor: Theme.of(context).colorScheme.secondary,
651652
bufferedColor:
652-
Theme.of(context).colorScheme.surface.withValues(alpha: 0.5),
653+
Theme.of(context).colorScheme.surface.withOpacityCompat(0.5),
653654
backgroundColor:
654-
Theme.of(context).disabledColor.withValues(alpha: 0.5),
655+
Theme.of(context).disabledColor.withOpacityCompat(0.5),
655656
),
656657
draggableProgressBar: chewieController.draggableProgressBar,
657658
),

pubspec.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ version: 1.9.0
44
homepage: https://github.com/fluttercommunity/chewie
55

66
environment:
7-
sdk: '>=3.3.0 <4.0.0'
8-
flutter: ">=3.27.0"
7+
sdk: '>=3.5.0 <4.0.0'
8+
flutter: ">=3.24.0"
99

1010
dependencies:
1111
cupertino_icons: ^1.0.5

0 commit comments

Comments
 (0)