Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate to null safety #443

Merged
merged 5 commits into from
Feb 27, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
241 changes: 0 additions & 241 deletions example/lib/auto_rotate.dart

This file was deleted.

26 changes: 14 additions & 12 deletions example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ class ChewieDemo extends StatefulWidget {
}

class _ChewieDemoState extends State<ChewieDemo> {
TargetPlatform _platform;
VideoPlayerController _videoPlayerController1;
VideoPlayerController _videoPlayerController2;
ChewieController _chewieController;
TargetPlatform? _platform;
late VideoPlayerController _videoPlayerController1;
late VideoPlayerController _videoPlayerController2;
ChewieController? _chewieController;

@override
void initState() {
Expand All @@ -37,17 +37,19 @@ class _ChewieDemoState extends State<ChewieDemo> {
void dispose() {
_videoPlayerController1.dispose();
_videoPlayerController2.dispose();
_chewieController.dispose();
_chewieController?.dispose();
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change is not strictly related to the migration, but it makes the test pass.

super.dispose();
}

Future<void> initializePlayer() async {
_videoPlayerController1 = VideoPlayerController.network(
'https://assets.mixkit.co/videos/preview/mixkit-forest-stream-in-the-sunlight-529-large.mp4');
await _videoPlayerController1.initialize();
_videoPlayerController2 = VideoPlayerController.network(
'https://assets.mixkit.co/videos/preview/mixkit-a-girl-blowing-a-bubble-gum-at-an-amusement-park-1226-large.mp4');
await _videoPlayerController2.initialize();
await Future.wait([
_videoPlayerController1.initialize(),
_videoPlayerController2.initialize()
]);
Comment on lines -47 to +52
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The changes here are also to make the test pass again.

_chewieController = ChewieController(
videoPlayerController: _videoPlayerController1,
autoPlay: true,
Expand Down Expand Up @@ -85,10 +87,10 @@ class _ChewieDemoState extends State<ChewieDemo> {
Expanded(
child: Center(
child: _chewieController != null &&
_chewieController
_chewieController!
.videoPlayerController.value.isInitialized
? Chewie(
controller: _chewieController,
controller: _chewieController!,
)
: Column(
mainAxisAlignment: MainAxisAlignment.center,
Expand All @@ -102,7 +104,7 @@ class _ChewieDemoState extends State<ChewieDemo> {
),
TextButton(
onPressed: () {
_chewieController.enterFullScreen();
_chewieController!.enterFullScreen();
},
child: const Text('Fullscreen'),
),
Expand All @@ -112,7 +114,7 @@ class _ChewieDemoState extends State<ChewieDemo> {
child: TextButton(
onPressed: () {
setState(() {
_chewieController.dispose();
_chewieController!.dispose();
_videoPlayerController1.pause();
_videoPlayerController1.seekTo(const Duration());
_chewieController = ChewieController(
Expand All @@ -132,7 +134,7 @@ class _ChewieDemoState extends State<ChewieDemo> {
child: TextButton(
onPressed: () {
setState(() {
_chewieController.dispose();
_chewieController!.dispose();
_videoPlayerController2.pause();
_videoPlayerController2.seekTo(const Duration());
_chewieController = ChewieController(
Expand Down
2 changes: 1 addition & 1 deletion example/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: chewie_example
description: An example of how to use the chewie for Flutter

environment:
sdk: ">=2.7.0 <3.0.0"
sdk: '>=2.12.0 <3.0.0'

dependencies:
chewie:
Expand Down
2 changes: 1 addition & 1 deletion example/test/widget_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
// gestures. You can also use WidgetTester to find child widgets in the widget
// tree, read text, and verify that the values of widget properties are correct.

import 'package:chewie_example/auto_rotate.dart';
import 'package:chewie_example/main.dart';
import 'package:flutter_test/flutter_test.dart';

void main() {
Expand Down