123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755 |
- import 'dart:io';
- import 'package:dio/dio.dart';
- import 'package:file_picker/file_picker.dart';
- import 'package:file_preview/file_preview.dart';
- import 'package:flutter/cupertino.dart';
- import 'package:flutter/material.dart';
- import 'package:flutter/services.dart';
- import 'package:path_provider/path_provider.dart';
- import 'package:video_player/video_player.dart';
- import 'package:video_thumbnail/video_thumbnail.dart';
- import '../base/YSBase.dart';
- import 'YSAlertView.dart';
- import 'YSNetWork.dart';
- import 'YSTools.dart';
- String fileUrl = 'https://cdn.datangyun.cc/';
- class YSFileView extends StatelessWidget {
- final List fileArray;
- const YSFileView({Key? key, required this.fileArray}) : super(key: key);
- @override
- Widget build(BuildContext context) {
- return LayoutBuilder(builder: (context,conSize){
- return GridView.builder(gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
- crossAxisCount: 4,
- childAspectRatio: 54/35,
- crossAxisSpacing: hsp(15),
- mainAxisSpacing: hsp(15)
- ), itemBuilder: (context,index){
- Map item = fileArray[index];
- return item['type']==1?YSImageView(
- url: item['url'],
- ):YSVideoView(
- url: item['url']
- );
- },shrinkWrap: true,padding: const EdgeInsets.all(0),physics: const NeverScrollableScrollPhysics(),itemCount: fileArray.length,);
- });
- }
- }
- class YSUploadFileView2 extends StatefulWidget {
- final List fileArray;
- const YSUploadFileView2({Key? key, required this.fileArray}) : super(key: key);
- @override
- YSUploadFileView2State createState() => YSUploadFileView2State();
- }
- class YSUploadFileView2State extends State<YSUploadFileView2> {
- @override
- void initState() {
- super.initState();
- }
- @override
- Widget build(BuildContext context) {
- return LayoutBuilder(builder: (context,conSize){
- return GridView.builder(gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
- crossAxisCount: 4,
- childAspectRatio: 54/35,
- crossAxisSpacing: hsp(15),
- mainAxisSpacing: hsp(15)
- ), itemBuilder: (context,index){
- return GestureDetector(
- onTap: () async{
- // LogUtil.d('obj');
- // return;
- if(index==0){//&&widget.fileArray.isEmpty
- if(widget.fileArray.length==4){
- ysFlutterToast('最多添加4个文件');
- return;
- }
- FocusScope.of(context).unfocus();
- bool isAgree = await permissionHandler('file');
- if(isAgree==false)return;
- List<String> allowedExtensions = ['jpg','jpeg','png','mp4'];
- bool isMp4 = widget.fileArray.any((element) => '${element['url']}'.contains('mp4'));
- if(isMp4){
- allowedExtensions.remove('mp4');
- }
- FilePickerResult? result = await FilePicker.platform.pickFiles(
- type: FileType.custom,//'excel', 'word', 'pdf',
- allowedExtensions: allowedExtensions,
- );
- if(result!=null){
- LogUtil.d(result.files);
- if(result.files.isNotEmpty){
- Map fileMap = {};
- for (var element in result.files) {
- // if(element.size/1000000>20){
- // ysFlutterToast('文件不能超过20M');
- // return;
- // }
- fileMap['path'] = element.path;
- fileMap['name'] = element.name;
- }
- if('${fileMap['path']}'.contains('mp4')){
- widget.fileArray.insert(0, fileMap);
- }else{
- widget.fileArray.add(fileMap);
- }
- setState(() {});
- _postFileData(fileMap);
- }
- }
- }
- },
- child: index==0?Container(
- color: const Color(0xFF8A93A0),
- alignment: Alignment.center,
- child: Icon(Icons.file_copy,size: hsp(10),color: Colors.white,),
- ):Container(
- child: widget.fileArray[index-1]['url']!=null?Stack(
- children: [
- YSDocView(url: widget.fileArray[index-1]['url'],),
- Positioned(right: 0,top: 0,height: hsp(15),width: hsp(15),child: GestureDetector(
- onTap: (){
- widget.fileArray.removeAt(index-1);
- setState(() {});
- },
- behavior: HitTestBehavior.opaque,
- child: Container(
- decoration: const BoxDecoration(
- color: Colors.black54,
- borderRadius: BorderRadius.only(bottomLeft: Radius.circular(50))
- ),
- alignment: Alignment.topRight,
- padding: EdgeInsets.only(top: hsp(2),right: hsp(2)),
- child: Icon(Icons.close,size: hsp(8),color: Colors.white,),
- ),
- ),)
- ],
- ):widget.fileArray[index-1]['path']!=null?Stack(
- children: [
- YSDocView(url: widget.fileArray[index-1]['path'],),
- ClipRRect(
- child: Container(
- alignment: Alignment.center,
- height: conSize.maxWidth/2,
- width: conSize.maxWidth/2,
- child: CircularProgressIndicator(
- value: widget.fileArray[index-1]['rota'],
- color: Colors.black54,
- valueColor: const AlwaysStoppedAnimation(Colors.transparent),
- strokeWidth: conSize.maxWidth/6,
- ),
- ),
- ),
- if(widget.fileArray[index-1]['isError']==true)Container(
- color: Colors.black54,
- child: Stack(
- children: [
- GestureDetector(
- onTap: (){
- Map item = widget.fileArray[index-1];
- item.remove('isError');
- _postFileData(item);
- },
- behavior: HitTestBehavior.opaque,
- child: Container(
- alignment: Alignment.center,
- child: Text('上传失败\n重新上传',style: TextStyle(fontSize: zsp(8),color: const Color(0xFFACB5C5)),),
- ),
- ),
- Positioned(right: 0,top: 0,height: hsp(15),width: hsp(15),child: GestureDetector(
- onTap: (){
- widget.fileArray.removeAt(index-1);
- setState(() {});
- },
- behavior: HitTestBehavior.opaque,
- child: Container(
- decoration: const BoxDecoration(
- color: Colors.white60,
- borderRadius: BorderRadius.only(bottomLeft: Radius.circular(50))
- ),
- alignment: Alignment.topRight,
- padding: EdgeInsets.only(top: hsp(2),right: hsp(2)),
- child: Icon(Icons.close,size: hsp(8),color: Colors.black,),
- ),
- ),),
- ],
- ),
- )
- ],
- ):Container(),
- ),
- );
- },shrinkWrap: true,padding: const EdgeInsets.all(0),physics: const NeverScrollableScrollPhysics(),itemCount: widget.fileArray.length+1,);
- });
- }
- _postFileData(Map fileMap) async{
- FormData formData = FormData.fromMap(Map<String, dynamic>.from({}));
- formData.files.add(
- MapEntry('file', await MultipartFile.fromFile(fileMap['path'] ,filename: fileMap['name']))
- );
- if (!mounted) return;
- YSNetWork.ysRequestHttp2(context, type: RequestType.post, api: '/upload/${'${fileMap['path']}'.contains('mp4')==true?'video':'img'}',parameter: formData,imageSetter: (value){
- fileMap['rota'] = value;
- setState(() {});
- }, successSetter: (value) {
- if(value['msg']!=null){
- fileMap['isError'] = true;
- }else{
- Map data = value['data']??{};
- fileMap['url'] = data['img']??data['video']??'';
- }
- setState(() {});
- },isLoading: true);
- }
- }
- uploadFile(BuildContext context,ValueSetter valueSetter) async{
- List<String> allowedExtensions = ['jpg','jpeg','png'];
- FilePickerResult? result = await FilePicker.platform.pickFiles(
- type: FileType.custom,//'excel', 'word', 'pdf',
- allowedExtensions: allowedExtensions,
- );
- if(result!=null){
- LogUtil.d(result.files);
- if(result.files.isNotEmpty){
- Map fileMap = {};
- for (var element in result.files) {
- fileMap['path'] = element.path;
- fileMap['name'] = element.name;
- }
- FormData formData = FormData.fromMap(Map<String, dynamic>.from({}));
- formData.files.add(
- MapEntry('file', await MultipartFile.fromFile(fileMap['path'] ,filename: fileMap['name']))
- );
- // ignore: use_build_context_synchronously
- YSNetWork.ysRequestHttp2(context, type: RequestType.post, api: '/upload/${'${fileMap['path']}'.contains('mp4')==true?'video':'img'}',parameter: formData,imageSetter: (value){
- fileMap['rota'] = value;
- }, successSetter: (value) {
- if(value['msg']!=null){
- fileMap['isError'] = true;
- }else{
- Map data = value['data']??{};
- fileMap['url'] = data['img']??data['video']??'';
- valueSetter(fileMap);
- }
- });
- }
- }
- }
- class YSUploadFileView extends StatefulWidget {
- final bool isInvoice;
- final List fileArray;
- const YSUploadFileView({Key? key, required this.fileArray,this.isInvoice = false}) : super(key: key);
- @override
- YSUploadFileViewState createState() => YSUploadFileViewState();
- }
- class YSUploadFileViewState extends State<YSUploadFileView> {
- bool _isInvoice = false;
- @override
- void initState() {
- _isInvoice = widget.isInvoice;
- super.initState();
- }
- @override
- Widget build(BuildContext context) {
- return LayoutBuilder(builder: (context,conSize){
- return GridView.builder(gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
- crossAxisCount: 4,
- childAspectRatio: 54/35,
- crossAxisSpacing: hsp(15),
- mainAxisSpacing: hsp(15)
- ), itemBuilder: (context,index){
- return GestureDetector(
- onTap: (){
- FocusScope.of(context).unfocus();
- if(index==0){
- if(_isInvoice&&widget.fileArray.isNotEmpty)return;
- ysShowBottomAlertView(context, YSChooseFileView(valueSetter: (fileMap) async{
- bool isInvoice = fileMap['invoice']??false;
- _isInvoice = isInvoice;
- int type = fileMap['type']??1;
- var value = fileMap['value'];
- if(value is List){
- List valueArray = value;
- for (var element in valueArray) {
- Map fileMap = {'path':element.path,'name':element.name,'type':type};
- widget.fileArray.add(fileMap);
- setState(() {});
- _postFileData(fileMap);
- }
- }else{
- Map fileMap = {'path':value.path,'name':value.name,'type':type};
- widget.fileArray.add(fileMap);
- setState(() {});
- _postFileData(fileMap);
- }
- },isPhoto: widget.isInvoice,),isBarr: true);
- }
- },
- child: index==0?Container(
- color: const Color(0xFFF7F8FA),
- alignment: Alignment.center,
- child: Icon(Icons.camera_alt,size: hsp(20),color: const Color(0xFFDCDEE0),),
- ):Container(
- child: widget.fileArray[index-1]['url']!=null?Stack(
- children: [
- widget.fileArray[index-1]['type']!=1?YSVideoView(
- url: widget.fileArray[index-1]['url']
- ):YSImageView(url: widget.fileArray[index-1]['url'],),
- Positioned(right: 0,top: 0,height: hsp(30),width: hsp(30),child: GestureDetector(
- onTap: (){
- widget.fileArray.removeAt(index-1);
- setState(() {});
- },
- behavior: HitTestBehavior.opaque,
- child: Container(
- decoration: const BoxDecoration(
- color: Colors.black54,
- borderRadius: BorderRadius.only(bottomLeft: Radius.circular(50))
- ),
- alignment: Alignment.topRight,
- padding: EdgeInsets.only(top: hsp(2),right: hsp(2)),
- child: Icon(Icons.close,size: hsp(20),color: Colors.white,),
- ),
- ),)
- ],
- ):widget.fileArray[index-1]['path']!=null?Stack(
- children: [
- '${widget.fileArray[index-1]['path']}'.contains('mp4')?YSVideoView(
- url: widget.fileArray[index-1]['path']
- ):YSImageView(url: widget.fileArray[index-1]['path'],),
- Container(
- padding: EdgeInsets.all(hsp(25)),
- height: 100,
- width: 100,
- child: CircularProgressIndicator(
- value: widget.fileArray[index-1]['rota'],
- color: Colors.lightBlueAccent,
- backgroundColor: Colors.white,
- strokeWidth: 4,
- ),
- )
- ],
- ):Container(),
- ),
- );
- },shrinkWrap: true,padding: const EdgeInsets.all(0),physics: const NeverScrollableScrollPhysics(),itemCount: widget.fileArray.length+1,);
- });
- }
- _postFileData(Map fileMap) async{
- FormData formData = FormData.fromMap(Map<String, dynamic>.from({}));
- formData.files.add(
- MapEntry('file', await MultipartFile.fromFile(fileMap['path'] ,filename: fileMap['name']))
- );
- if (!mounted) return;
- YSNetWork.ysRequestHttp2(context, type: RequestType.post, api: 'file/upload',parameter: formData,imageSetter: (value){
- fileMap['rota'] = value;
- setState(() {});
- }, successSetter: (value) {
- List data = value['data']??[];
- for (var element in data) {
- fileMap['url'] = element['filePath'];
- }
- setState(() {});
- if(_isInvoice){
- YSNetWork.ysRequestHttp(context, type: RequestType.post, api: 'energyConsumptionOil/appCheckInvoice', parameter: {
- 'check':fileMap['url']
- }, successSetter: (dict){
- Map info = dict['data'];
- CustomerValueNotification(info).dispatch(context);
- });
- }
- LogUtil.d(fileMap);
- });
- }
- }
- class YSDocView extends StatefulWidget {
- final String url;
- const YSDocView({Key? key, required this.url}) : super(key: key);
- @override
- YSDocViewState createState() => YSDocViewState();
- }
- class YSDocViewState extends State<YSDocView> {
- @override
- void initState() {
- super.initState();
- }
- @override
- Widget build(BuildContext context) {
- return widget.url.contains('.png')||widget.url.contains('.jpg')||widget.url.contains('.jpeg')?YSImageView(
- url: widget.url
- ):widget.url.contains('.mp4')?YSVideoView(
- url: widget.url
- ):GestureDetector(
- onTap: (){
- // return;
- Navigator.of(context).push(
- CupertinoPageRoute(builder: (context){
- return YSDocDetailView(path: widget.url);
- })
- );
- },
- child: Container(
- alignment: Alignment.center,
- child: Icon(Icons.insert_drive_file_sharp,color: Colors.orange,size: hsp(60),),
- ),
- );
- }
- }
- class YSDocDetailView extends StatelessWidget {
- final String path;
- const YSDocDetailView({Key? key, required this.path}) : super(key: key);
- @override
- Widget build(BuildContext context) {
- return YSBase(
- ysTitle: '文件预览',
- ysColor: Colors.white,
- ysChild: SizedBox(
- height: ysHeight(context),
- width: ysWidth(context),
- child: FilePreviewWidget(
- width: ysHeight(context),//宽
- height: ysWidth(context),//高
- callBack: FilePreviewCallBack(onShow: () {
- LogUtil.d("文件打开成功");
- }, onDownload: (progress) {
- LogUtil.d("文件下载进度$progress");
- }, onFail: (code, msg) {
- LogUtil.d("文件打开失败 $code $msg");
- }),
- path: path,//本地路径或者http链接
- ),
- ),
- );
- }
- }
- class YSImageView extends StatelessWidget {
- final String url;
- const YSImageView({Key? key, required this.url}) : super(key: key);
- @override
- Widget build(BuildContext context) {
- return GestureDetector(
- onTap: (){
- Navigator.of(context).push(
- CupertinoPageRoute(builder: (context){
- return YSPreviewImageView(url: url.contains('carbon')==true?'$fileUrl$url':url);
- })
- );
- },
- child: url.contains('carbon')?Image.network(
- '$fileUrl$url',
- fit: BoxFit.cover,
- width: double.infinity,
- height: double.infinity,
- ):Image.file(
- File(url),
- fit: BoxFit.cover,
- width: double.infinity,
- height: double.infinity,
- ),
- );
- }
- }
- class YSVideoView extends StatefulWidget {
- final String url;
- const YSVideoView({Key? key, required this.url}) : super(key: key);
- @override
- YSVideoViewState createState() => YSVideoViewState();
- }
- class YSVideoViewState extends State<YSVideoView> {
- @override
- void initState() {
- super.initState();
- _getImage();
- }
- _getImage() async{
- final uint8List = await VideoThumbnail.thumbnailData(
- video: widget.url,
- imageFormat: ImageFormat.JPEG,
- );
- YSData().image = Image.memory(uint8List!,fit: BoxFit.fill,height: double.infinity,width: double.infinity,);
- }
- @override
- Widget build(BuildContext context) {
- return GestureDetector(
- onTap: (){
- if(widget.url.contains('carbon')){
- Navigator.of(context).push(
- CupertinoPageRoute(builder: (context){
- return YSVideoHorizontal(url: '$fileUrl${widget.url}');
- })
- );
- }
- },
- behavior: HitTestBehavior.opaque,
- child: Center(
- child: Stack(
- alignment: Alignment.center,
- children: [
- YSData().image,
- if(widget.url.contains('carbon'))Center(
- child: Icon(Icons.play_circle_fill,color: Colors.white,size: hsp(20),),
- )
- ],
- ),
- ),
- )
- ;
- }
- }
- class YSPreviewImageView extends StatelessWidget {
- final String url;
- const YSPreviewImageView({Key? key, required this.url}) : super(key: key);
- @override
- Widget build(BuildContext context) {
- return GestureDetector(
- onTap: (){
- Navigator.pop(context);
- },
- child: Container(
- height: ysHeight(context),
- width: ysHeight(context),
- color: Colors.black,
- child: url.contains('http')?Image.network(
- url,
- fit: BoxFit.cover,
- width: double.infinity,
- height: double.infinity,
- ):Image.file(
- File(url),
- fit: BoxFit.cover,
- width: double.infinity,
- height: double.infinity,
- ),
- ),
- );
- }
- }
- class YSVideoHorizontal extends StatefulWidget {
- final String url;
- final String title;
- const YSVideoHorizontal({Key? key, required this.url, this.title = ''}) : super(key: key);
- @override
- YSVideoHorizontalState createState() => YSVideoHorizontalState();
- }
- class YSVideoHorizontalState extends State<YSVideoHorizontal> {
- late StateSetter _playSet,_progressSet;
- String _startTime = '00:00:00';
- String _endTime = '00:00:00';
- late VideoPlayerController _controller;
- @override
- void initState() {
- // SystemChrome.setEnabledSystemUIMode(SystemUiMode.manual, overlays: []);
- // SystemChrome.setPreferredOrientations([
- // DeviceOrientation.landscapeLeft, //全屏时旋转方向,左边
- // ]);
- _getPlayer();
- super.initState();
- }
- _getPlayer() {
- // LogUtil.d(widget.url);
- //https://media.w3.org/2010/05/sintel/trailer.mp4
- if(widget.url.contains('http')){
- _controller = VideoPlayerController.network(widget.url)..initialize().then((_) {
- _controller.play();
- setState(() {});
- })..addListener(() {
- Duration duration = _controller.value.duration;
- Duration position = _controller.value.position;
- _endTime = '${'${duration.inHours}'.padLeft(2,'0')}:${'${duration.inMinutes}'.padLeft(2,'0')}:${'${duration.inSeconds}'.padLeft(2,'0')}';
- _startTime = '${'${position.inHours}'.padLeft(2,'0')}:${'${position.inMinutes}'.padLeft(2,'0')}:${'${position.inSeconds}'.padLeft(2,'0')}';
- if(mounted){
- _progressSet(() {});
- }
- });
- }else{
- _controller = VideoPlayerController.file(File(widget.url))..initialize().then((_) {
- _controller.play();
- setState(() {});
- })..addListener(() {
- Duration duration = _controller.value.duration;
- Duration position = _controller.value.position;
- _endTime = '${'${duration.inHours}'.padLeft(2,'0')}:${'${duration.inMinutes}'.padLeft(2,'0')}:${'${duration.inSeconds}'.padLeft(2,'0')}';
- _startTime = '${'${position.inHours}'.padLeft(2,'0')}:${'${position.inMinutes}'.padLeft(2,'0')}:${'${position.inSeconds}'.padLeft(2,'0')}';
- if(mounted){
- _progressSet(() {});
- }
- });
- }
- }
- @override
- void dispose() {
- _controller.dispose();
- // SystemChrome.setEnabledSystemUIMode(SystemUiMode.manual, overlays: SystemUiOverlay.values);
- // SystemChrome.setPreferredOrientations([
- // DeviceOrientation.portraitUp,
- // ]);
- super.dispose();
- }
- @override
- Widget build(BuildContext context) {
- return Scaffold(
- backgroundColor: Colors.black,
- body: SizedBox(
- height: ysHeight(context),
- width: ysWidth(context),
- child: Stack(
- children: <Widget>[
- _controller.value.aspectRatio<1?Center(
- child: AspectRatio(
- aspectRatio: _controller.value.aspectRatio,
- child: VideoPlayer(_controller),
- ),
- ):VideoPlayer(_controller),
- _pauseView(controller: _controller),
- Container(
- width: ysWidth(context),
- height: hsp(30),
- margin: EdgeInsets.only(left: hsp(15),right: hsp(35),top: ysTOP(context)+hsp(10)),
- child: Row(
- children: [
- GestureDetector(
- onTap: (){Navigator.pop(context);},
- child: Icon(Icons.chevron_left,size: hsp(30),color: Colors.white,),
- ),
- SizedBox(
- width: ysWidth(context)-hsp(80),
- child: Text(widget.title,style: TextStyle(fontSize: zsp(16),color: Colors.white),),
- )
- ],
- ),
- ),
- StatefulBuilder(
- builder: (context,progressSet){
- _progressSet = progressSet;
- return Container(
- margin: EdgeInsets.only(top: ysHeight(context)-hsp(50),left: hsp(15),right: hsp(15)),
- child: Row(
- children: [
- SizedBox(
- width: hsp(100),
- child: Row(
- children: [
- GestureDetector(
- onTap: (){
- _playSet(() {
- _controller.value.isPlaying?_controller.pause() : _controller.play();
- });
- progressSet(() {});
- },
- child: Icon(_controller.value.isPlaying?Icons.pause:Icons.play_arrow,size: hsp(25),color: Colors.white,),
- ),
- Container(
- alignment: Alignment.center,
- width: hsp(75),
- child: Text(_startTime,style: TextStyle(fontSize: zsp(12),color: Colors.white),),
- )
- ],
- ),
- ),
- SizedBox(
- width: ysWidth(context)-hsp(230),
- height:6.5,
- child: VideoProgressIndicator(
- _controller,
- allowScrubbing: true,
- colors: const VideoProgressColors(playedColor: Colors.white,backgroundColor: Colors.black),
- )
- ),
- SizedBox(
- width: hsp(100),
- child: Row(
- children: [
- Container(
- alignment: Alignment.center,
- width: hsp(75),
- child: Text(_endTime,style: TextStyle(fontSize: zsp(12),color: Colors.white),),
- ),
- GestureDetector(
- onTap: (){Navigator.pop(context);},
- child: Icon(Icons.api,size: hsp(20),color: Colors.white,),
- )
- ],
- )
- ),
- ],
- ),
- );
- },
- ),
- ],
- ),
- ),
- );
- }
- _pauseView({required VideoPlayerController controller}) {
- return StatefulBuilder(
- builder: (context,playSet){
- _playSet = playSet;
- return Stack(
- children: <Widget>[
- AnimatedSwitcher(
- duration: const Duration(milliseconds: 50),
- reverseDuration: const Duration(milliseconds: 200),
- child: controller.value.isPlaying? Container():Container(
- alignment: Alignment.center,
- color: Colors.transparent,
- child: const Icon(
- Icons.play_circle_filled,
- color: Colors.white,
- size: 50,
- ),
- ),
- ),
- GestureDetector(
- onTap: () {
- playSet(() {
- controller.value.isPlaying ? controller.pause() : controller.play();
- });
- _progressSet(() {});
- },
- ),
- ],
- );
- },
- );
- }
- }
|