27 lines
845 B
Dart
Raw Normal View History

2023-11-18 10:38:13 +08:00
import 'package:flutter/material.dart';
import 'package:video_player/video_player.dart';
import 'video_player_control.dart';
class ControllerWidget extends InheritedWidget {
const ControllerWidget(
{required this.controlKey, required this.child, required this.controller, required this.videoInit, required this.title, Key? key
}) : super(key: key, child: child);
2023-11-18 10:38:13 +08:00
final String title;
final GlobalKey<VideoPlayerControlState> controlKey;
final Widget child;
final VideoPlayerController controller;
final bool videoInit;
//定义一个便捷方法方便子树中的widget获取共享数据
static ControllerWidget? of(BuildContext context) {
return context.dependOnInheritedWidgetOfExactType<ControllerWidget>();
}
@override
bool updateShouldNotify(InheritedWidget oldWidget) {
return false;
}
}