From d8b40363c60d0af9159250e18570a5942cac2bc0 Mon Sep 17 00:00:00 2001 From: Diego Tori Date: Tue, 14 Jan 2025 20:18:41 -0500 Subject: [PATCH 01/10] Added withOpacityCompact extension to ensure compatibility with Flutter versions below 3.27. --- lib/src/material/color_compat_extensions.dart | 30 +++++++++++++++++++ lib/src/material/material_controls.dart | 7 +++-- .../material/material_desktop_controls.dart | 5 ++-- pubspec.yaml | 2 +- 4 files changed, 38 insertions(+), 6 deletions(-) create mode 100644 lib/src/material/color_compat_extensions.dart diff --git a/lib/src/material/color_compat_extensions.dart b/lib/src/material/color_compat_extensions.dart new file mode 100644 index 000000000..dac464f6e --- /dev/null +++ b/lib/src/material/color_compat_extensions.dart @@ -0,0 +1,30 @@ +import 'package:flutter/material.dart'; + +extension ColorCompatExtensions on Color { + /// Returns a new color that matches this color with the given opacity. + /// + /// This is a compatibility layer that ensures compatibility with Flutter + /// versions below 3.27. In Flutter 3.27 and later, `Color.withOpacity` + /// has been deprecated in favor of `Color.withValues`. + /// + /// This method bridges the gap by providing a consistent way to adjust + /// the opacity of a color across different Flutter versions. + /// + /// **Important:** Once the minimum supported Flutter version is bumped + /// to 3.27 or higher, this method should be removed and replaced with + /// `withValues(alpha: opacity)`. + /// + /// See also: + /// * [Color.withOpacity], which is deprecated in Flutter 3.27 and later. + /// * [Color.withValues], the recommended replacement for `withOpacity`. + Color withOpacityCompat(double opacity) { + // Compatibility layer that uses the legacy withOpacity method, while + // ignoring the deprecation for now (in order to guarantee N-1 minimum + // version compatibility). + // Once it's removed from a future update, we'll have to replace uses of + // this method with withValues(alpha: opacity). + // TODO: Replace this bridge method once the above holds true. + //ignore: deprecated_member_use + return withOpacity(opacity); + } +} diff --git a/lib/src/material/material_controls.dart b/lib/src/material/material_controls.dart index f5b5410c6..0fbd6f1b7 100644 --- a/lib/src/material/material_controls.dart +++ b/lib/src/material/material_controls.dart @@ -5,6 +5,7 @@ import 'package:chewie/src/center_seek_button.dart'; import 'package:chewie/src/chewie_player.dart'; import 'package:chewie/src/chewie_progress_colors.dart'; import 'package:chewie/src/helpers/utils.dart'; +import 'package:chewie/src/material/color_compat_extensions.dart'; import 'package:chewie/src/material/material_progress_bar.dart'; import 'package:chewie/src/material/widgets/options_dialog.dart'; import 'package:chewie/src/material/widgets/playback_speed_dialog.dart'; @@ -470,7 +471,7 @@ class _MaterialControlsState extends State text: '/ ${formatDuration(duration)}', style: TextStyle( fontSize: 14.0, - color: Colors.white.withValues(alpha: .75), + color: Colors.white.withOpacityCompat(.75), fontWeight: FontWeight.normal, ), ) @@ -683,9 +684,9 @@ class _MaterialControlsState extends State playedColor: Theme.of(context).colorScheme.secondary, handleColor: Theme.of(context).colorScheme.secondary, bufferedColor: - Theme.of(context).colorScheme.surface.withValues(alpha: 0.5), + Theme.of(context).colorScheme.surface.withOpacityCompat(0.5), backgroundColor: - Theme.of(context).disabledColor.withValues(alpha: .5), + Theme.of(context).disabledColor.withOpacityCompat(.5), ), draggableProgressBar: chewieController.draggableProgressBar, ), diff --git a/lib/src/material/material_desktop_controls.dart b/lib/src/material/material_desktop_controls.dart index 2bdf19fbb..c29767b1a 100644 --- a/lib/src/material/material_desktop_controls.dart +++ b/lib/src/material/material_desktop_controls.dart @@ -5,6 +5,7 @@ import 'package:chewie/src/center_play_button.dart'; import 'package:chewie/src/chewie_player.dart'; import 'package:chewie/src/chewie_progress_colors.dart'; import 'package:chewie/src/helpers/utils.dart'; +import 'package:chewie/src/material/color_compat_extensions.dart'; import 'package:chewie/src/material/material_progress_bar.dart'; import 'package:chewie/src/material/widgets/options_dialog.dart'; import 'package:chewie/src/material/widgets/playback_speed_dialog.dart'; @@ -649,9 +650,9 @@ class _MaterialDesktopControlsState extends State playedColor: Theme.of(context).colorScheme.secondary, handleColor: Theme.of(context).colorScheme.secondary, bufferedColor: - Theme.of(context).colorScheme.surface.withValues(alpha: 0.5), + Theme.of(context).colorScheme.surface.withOpacityCompat(0.5), backgroundColor: - Theme.of(context).disabledColor.withValues(alpha: 0.5), + Theme.of(context).disabledColor.withOpacityCompat(0.5), ), draggableProgressBar: chewieController.draggableProgressBar, ), diff --git a/pubspec.yaml b/pubspec.yaml index 7c0f269ff..aa4f10b50 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -5,7 +5,7 @@ homepage: https://github.com/fluttercommunity/chewie environment: sdk: '>=3.3.0 <4.0.0' - flutter: ">=3.27.0" + flutter: ">=3.24.0" dependencies: cupertino_icons: ^1.0.5 From bc53041b593d968ff78ed80aae19249e6ac7dcfd Mon Sep 17 00:00:00 2001 From: Diego Tori Date: Tue, 14 Jan 2025 20:18:53 -0500 Subject: [PATCH 02/10] Updated readme. --- README.md | 61 +++++++++++++++++++++++++++++++++++++++++++------------ 1 file changed, 48 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index e7581c503..cfc9ea72c 100644 --- a/README.md +++ b/README.md @@ -8,18 +8,53 @@ The video player for Flutter with a heart of gold. -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! +The [`video_player`](https://pub.dartlang.org/packages/video_player) plugin provides low-level +access to video playback. -## Preview +Chewie uses the `video_player` under the hood and wraps it in a friendly Material or Cupertino UI! -| MaterialControls | MaterialDesktopControls | -| :--------------: | :---------------------: | -| ![](https://github.com/brianegan/chewie/raw/master/assets/MaterialControls.png) | ![](https://github.com/brianegan/chewie/raw/master/assets/MaterialDesktopControls.png) | +## Table of Contents +1. 🚨 [IMPORTANT!!! (READ THIS FIRST)](#-important-read-this-first) +2. πŸ”€ [Flutter Version Compatibility](#-flutter-version-compatibility) +3. πŸ–ΌοΈ [Preview](#-preview) +4. ⬇️ [Installation](#-installation) +5. πŸ•ΉοΈ [Using it](#-using-it) +6. βš™οΈ [Options](#-options) +7. πŸ”‘ [Subtitles](#-subtitles) +8. πŸ§ͺ [Example](#-example) +9. βͺ [Migrating from Chewie < 0.9.0](#-migrating-from-chewie--090) +10. πŸ—ΊοΈ [Roadmap](#-roadmap) +11. πŸ“± [iOS warning](#-ios-warning-) + + +## 🚨 IMPORTANT!!! (READ THIS FIRST) +This library is __NOT__ responsible for any issues caused by `video_player`, since it's merely a UI +layer on top of it. + +In other words, if you see any `PlatformException`s being thrown in your app due to video playback, +they are exclusive to the `video_player` library. + +Instead, please raise an issue related to it with the [Flutter Team](https://github.com/flutter/flutter/issues/new/choose). + +## πŸ”€ Flutter Version Compatibility + +This library will at the very least make a solid effort to support the second most recent version +of Flutter released. In other words, it will adopt `N-1` version support at +the bare minimum. + +However, this cannot be guaranteed due to major changes between Flutter versions. Should that occur, +future updates will be released as major or minor versions as needed. + +## πŸ–ΌοΈ Preview + +| MaterialControls | MaterialDesktopControls | +|:-------------------------------------------------------------------------------:|:--------------------------------------------------------------------------------------:| +| ![](https://github.com/brianegan/chewie/raw/master/assets/MaterialControls.png) | ![](https://github.com/brianegan/chewie/raw/master/assets/MaterialDesktopControls.png) | ### CupertinoControls ![](https://github.com/brianegan/chewie/raw/master/assets/CupertinoControls.png) -## Installation +## ⬇️ Installation In your `pubspec.yaml` file within your Flutter Project add `chewie` and `video_player` under dependencies: @@ -29,7 +64,7 @@ dependencies: video_player: ``` -## Using it +## πŸ•ΉοΈ Using it ```dart import 'package:chewie/chewie.dart'; @@ -61,7 +96,7 @@ void dispose() { } ``` -## Options +## βš™οΈ Options ![](https://github.com/brianegan/chewie/raw/master/assets/Options.png) @@ -127,7 +162,7 @@ optionsTranslation: OptionsTranslation( ), ``` -## Subtitles +## πŸ”‘ Subtitles > Since version 1.1.0, Chewie supports subtitles. @@ -195,11 +230,11 @@ Subtitle( 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. -## Example +## πŸ§ͺ Example Please run the app in the [`example/`](https://github.com/brianegan/chewie/tree/master/example) folder to start playing! -## Migrating from Chewie < 0.9.0 +## βͺ Migrating from Chewie < 0.9.0 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. @@ -225,7 +260,7 @@ final playerWidget = Chewie( ); ``` -## Roadmap +## πŸ—ΊοΈ Roadmap - [x] MaterialUI - [x] MaterialDesktopUI @@ -251,7 +286,7 @@ final playerWidget = Chewie( - [ ] Screen-Mirroring / Casting (Google Chromecast) -## iOS warning +## πŸ“± iOS warning 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` Please refer to this [issue](https://github.com/flutter/flutter/issues/14647). From 12aebccba0d9ba21246a6e01b349d05a29d69faf Mon Sep 17 00:00:00 2001 From: Diego Tori Date: Tue, 14 Jan 2025 20:24:49 -0500 Subject: [PATCH 03/10] Ignoring withOpacity for the entire Dart extensions file. --- lib/src/material/color_compat_extensions.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/src/material/color_compat_extensions.dart b/lib/src/material/color_compat_extensions.dart index dac464f6e..bff4f3071 100644 --- a/lib/src/material/color_compat_extensions.dart +++ b/lib/src/material/color_compat_extensions.dart @@ -1,5 +1,6 @@ import 'package:flutter/material.dart'; +//ignore_for_file: deprecated_member_use extension ColorCompatExtensions on Color { /// Returns a new color that matches this color with the given opacity. /// @@ -24,7 +25,6 @@ extension ColorCompatExtensions on Color { // Once it's removed from a future update, we'll have to replace uses of // this method with withValues(alpha: opacity). // TODO: Replace this bridge method once the above holds true. - //ignore: deprecated_member_use return withOpacity(opacity); } } From 746795df789c1097956fd5902e3aaa4099dd5e6f Mon Sep 17 00:00:00 2001 From: Diego Tori Date: Tue, 14 Jan 2025 20:44:29 -0500 Subject: [PATCH 04/10] Added revamped workflow that now tests this library against both the current and N-1 version of Flutter. --- .github/workflows/ci.yml | 81 ++++++++++++++++++++++------------------ 1 file changed, 44 insertions(+), 37 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4bf72c2f9..9513d4602 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,5 +1,10 @@ name: CI +env: + # Note: The version below should be manually updated to the latest second most recent version + # after a new stable version comes out. + flutter_n_minus_one_version: "3.24.5" + on: pull_request: paths-ignore: @@ -9,48 +14,50 @@ on: - master paths-ignore: - '**.md' - workflow_dispatch: + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true jobs: - check-format: - name: Check format using dart format. - runs-on: ubuntu-latest - - steps: - - name: Checkout code - uses: actions/checkout@v4 - - name: Flutter Action - uses: subosito/flutter-action@v2 - - name: Check format - run: dart format . --set-exit-if-changed - - lint: - name: Lint + # Does a sanity check that packages at least pass analysis on the N-1 + # versions of Flutter stable if the package claims to support that version. + # This is to minimize accidentally making changes that break old versions + # (which we don't commit to supporting, but don't want to actively break) + # without updating the constraints. + lint_and_build: + strategy: + matrix: + flutter-version: + # The version of Flutter to use should use the minimum Dart SDK version supported by the package, + # refer to https://docs.flutter.dev/development/tools/sdk/releases. + - ${{ env.flutter_n_minus_one_version }} + - "3.x" + name: Checks formatting, lints, and tests this library against a specific Flutter version. runs-on: ubuntu-latest - steps: - - name: Checkout code + - name: πŸ“š Git Checkout uses: actions/checkout@v4 - - name: Flutter Action + + - name: 🐦 Setup Flutter uses: subosito/flutter-action@v2 - - name: Install Package Dependencies + with: + flutter-version: ${{matrix.flutter-version}} + channel: stable + cache: true + cache-key: flutter-:os:-:channel:-:version:-:arch:-:hash:-${{ hashFiles('**/pubspec.lock') }} + + - name: πŸ“¦ Install Dependencies run: flutter packages get - - name: Get dependencies for example - run: flutter pub get - working-directory: example - - name: Lint using flutter analyze - run: flutter analyze . - - test: - name: Run tests. - runs-on: ubuntu-latest - steps: - - name: Checkout code - uses: actions/checkout@v4 - - name: Flutter Action - uses: subosito/flutter-action@v2 - - name: Run flutter test - run: | - flutter pub get - flutter test + - name: ✨ Check Formatting + run: dart format --set-exit-if-changed lib + + - name: πŸ•΅οΈ Analyze + run: flutter analyze lib + + - name: πŸ§ͺ Run Tests + run: flutter test --no-pub --coverage --test-randomize-ordering-seed random + + - name: πŸ“ Upload coverage to Codecov + uses: codecov/codecov-action@v5 From 48eea7d02462ff6577679db4c8e77d67d6ca0466 Mon Sep 17 00:00:00 2001 From: Diego Tori Date: Tue, 14 Jan 2025 20:55:02 -0500 Subject: [PATCH 05/10] Added default flutter version inputs to use with the job matrix. --- .github/workflows/ci.yml | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9513d4602..5f74a33b1 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,10 +1,5 @@ name: CI -env: - # Note: The version below should be manually updated to the latest second most recent version - # after a new stable version comes out. - flutter_n_minus_one_version: "3.24.5" - on: pull_request: paths-ignore: @@ -14,10 +9,20 @@ on: - master paths-ignore: - '**.md' - -concurrency: - group: ${{ github.workflow }}-${{ github.ref }} - cancel-in-progress: true + workflow_dispatch: + inputs: + flutter_n_minus_one_version: + description: The N-1 version of Flutter. + required: false + # The version of Flutter to use should use the minimum Dart SDK version supported by the package, + # refer to https://docs.flutter.dev/development/tools/sdk/releases. + # Note: The version below should be manually updated to the latest second most recent version + # after a new stable version comes out. + default: "3.24.5" + flutter_current_version: + description: The current version of Flutter. + required: false + default: "3.x" jobs: # Does a sanity check that packages at least pass analysis on the N-1 @@ -29,10 +34,8 @@ jobs: strategy: matrix: flutter-version: - # The version of Flutter to use should use the minimum Dart SDK version supported by the package, - # refer to https://docs.flutter.dev/development/tools/sdk/releases. - - ${{ env.flutter_n_minus_one_version }} - - "3.x" + - ${{ inputs.flutter_n_minus_one_version }} + - ${{ inputs.flutter_current_version }} name: Checks formatting, lints, and tests this library against a specific Flutter version. runs-on: ubuntu-latest steps: From a29521f27679b71f06a5124fcef14e0b7723e247 Mon Sep 17 00:00:00 2001 From: Diego Tori Date: Tue, 14 Jan 2025 20:58:22 -0500 Subject: [PATCH 06/10] Added more descriptive name to new task. --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 5f74a33b1..1f6bdf5fc 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -36,7 +36,7 @@ jobs: flutter-version: - ${{ inputs.flutter_n_minus_one_version }} - ${{ inputs.flutter_current_version }} - name: Checks formatting, lints, and tests this library against a specific Flutter version. + name: Flutter version ${{matrix.flutter-version}} Lint and Build. runs-on: ubuntu-latest steps: - name: πŸ“š Git Checkout From 0d2516b9bcab7417bd6454d8d0079c7d6191859e Mon Sep 17 00:00:00 2001 From: Diego Tori Date: Tue, 14 Jan 2025 21:00:19 -0500 Subject: [PATCH 07/10] Added more descriptive name to new task, take two. --- .github/workflows/ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1f6bdf5fc..fe9f96901 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -31,13 +31,13 @@ jobs: # (which we don't commit to supporting, but don't want to actively break) # without updating the constraints. lint_and_build: + name: Flutter version ${{ matrix.flutter-version }} Lint and Build. + runs-on: ubuntu-latest strategy: matrix: flutter-version: - ${{ inputs.flutter_n_minus_one_version }} - ${{ inputs.flutter_current_version }} - name: Flutter version ${{matrix.flutter-version}} Lint and Build. - runs-on: ubuntu-latest steps: - name: πŸ“š Git Checkout uses: actions/checkout@v4 From 5a214f19984adbf978aa1d8105c0eb59279d76b6 Mon Sep 17 00:00:00 2001 From: Diego Tori Date: Tue, 14 Jan 2025 21:06:23 -0500 Subject: [PATCH 08/10] Added minimum Dart version supported by minimum Flutter version. --- pubspec.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pubspec.yaml b/pubspec.yaml index aa4f10b50..98719ed09 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -4,7 +4,7 @@ version: 1.9.0 homepage: https://github.com/fluttercommunity/chewie environment: - sdk: '>=3.3.0 <4.0.0' + sdk: '>=3.5.0 <4.0.0' flutter: ">=3.24.0" dependencies: From acaf684923a851fc1d338fbd162c402f1e168db4 Mon Sep 17 00:00:00 2001 From: Diego Tori Date: Tue, 14 Jan 2025 21:06:52 -0500 Subject: [PATCH 09/10] Added more descriptive name to new task, take three. --- .github/workflows/ci.yml | 25 ++++++++----------------- 1 file changed, 8 insertions(+), 17 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index fe9f96901..e55ad28f7 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -10,19 +10,6 @@ on: paths-ignore: - '**.md' workflow_dispatch: - inputs: - flutter_n_minus_one_version: - description: The N-1 version of Flutter. - required: false - # The version of Flutter to use should use the minimum Dart SDK version supported by the package, - # refer to https://docs.flutter.dev/development/tools/sdk/releases. - # Note: The version below should be manually updated to the latest second most recent version - # after a new stable version comes out. - default: "3.24.5" - flutter_current_version: - description: The current version of Flutter. - required: false - default: "3.x" jobs: # Does a sanity check that packages at least pass analysis on the N-1 @@ -31,13 +18,17 @@ jobs: # (which we don't commit to supporting, but don't want to actively break) # without updating the constraints. lint_and_build: - name: Flutter version ${{ matrix.flutter-version }} Lint and Build. + name: Flutter Version ${{ matrix.flutter-version }} Lint and Build. runs-on: ubuntu-latest strategy: matrix: flutter-version: - - ${{ inputs.flutter_n_minus_one_version }} - - ${{ inputs.flutter_current_version }} + # The version of Flutter to use should use the minimum Dart SDK version supported by the package, + # refer to https://docs.flutter.dev/development/tools/sdk/releases. + # Note: The version below should be manually updated to the latest second most recent version + # after a new stable version comes out. + - "3.24.5" + - "3.x" steps: - name: πŸ“š Git Checkout uses: actions/checkout@v4 @@ -45,7 +36,7 @@ jobs: - name: 🐦 Setup Flutter uses: subosito/flutter-action@v2 with: - flutter-version: ${{matrix.flutter-version}} + flutter-version: ${{ matrix.flutter-version }} channel: stable cache: true cache-key: flutter-:os:-:channel:-:version:-:arch:-:hash:-${{ hashFiles('**/pubspec.lock') }} From 8ac8700b980949d4cc8c5aeb120c6bd2a59bb054 Mon Sep 17 00:00:00 2001 From: Diego Tori Date: Tue, 14 Jan 2025 21:08:10 -0500 Subject: [PATCH 10/10] Added Github Workflow concurrency. --- .github/workflows/ci.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e55ad28f7..c41375da9 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -11,6 +11,10 @@ on: - '**.md' workflow_dispatch: +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + jobs: # Does a sanity check that packages at least pass analysis on the N-1 # versions of Flutter stable if the package claims to support that version.