diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4bf72c2f9..c41375da9 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -11,46 +11,51 @@ on: - '**.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: + name: Flutter Version ${{ matrix.flutter-version }} Lint and Build. runs-on: ubuntu-latest - + 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. + # 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: 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 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). diff --git a/lib/src/material/color_compat_extensions.dart b/lib/src/material/color_compat_extensions.dart new file mode 100644 index 000000000..bff4f3071 --- /dev/null +++ b/lib/src/material/color_compat_extensions.dart @@ -0,0 +1,30 @@ +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. + /// + /// 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. + 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..98719ed09 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -4,8 +4,8 @@ version: 1.9.0 homepage: https://github.com/fluttercommunity/chewie environment: - sdk: '>=3.3.0 <4.0.0' - flutter: ">=3.27.0" + sdk: '>=3.5.0 <4.0.0' + flutter: ">=3.24.0" dependencies: cupertino_icons: ^1.0.5