Я не хочу, чтобы мое видео выглядело растянутым. Я использую Chewie
пакет флаттера в качестве моего видеоплеера.
Я пытался использовать _controller.value.size.aspectRatio
, но он возвращает ошибку The getter 'aspectRatio' was called on null.
вот мой код, чтобы получить видео из галереи:
Future uploadVideoFromGallery() async {
print("CALLED");
Map<PermissionGroup, PermissionStatus> permissions =
await PermissionHandler().requestPermissions(
[PermissionGroup.storage, PermissionGroup.camera]);
if (permissions[PermissionGroup.storage] == PermissionStatus.granted) {
var videoFile = await ImagePicker.pickVideo(source: ImageSource.gallery);
if (videoFile != null) {
getVideoThumbnail(videoFile.path);
setState(() {
isFileImage = false;
image = videoFile;
_controller = VideoPlayerController.file(image);
});
print(videoFile.path);
}
} else {
debugPrint('permission not granted');
}
}
и вот мой код для размещения videoFile
:
Chewie(
controller: ChewieController(
videoPlayerController: _controller,
aspectRatio: _controller.value.size.aspectRatio,
materialProgressColors: ChewieProgressColors(
playedColor: Color(colorSecondary),
handleColor: Color(colorPrimary),
bufferedColor: Color(colorPrimary),
),
placeholder: Container(
color: Colors.grey,
),
autoInitialize: true,
looping: false,
errorBuilder: (context, errorMessage) {
return Center(
child: Text(
errorMessage,
style: TextStyle(color: Color(colorText)),
),
);
},
),
)