Skip to content

Commit

Permalink
feat:增加视频号功能,支持创建上传视频。
Browse files Browse the repository at this point in the history
  • Loading branch information
LeeeYudE committed Aug 15, 2022
1 parent 0193210 commit 569a56b
Show file tree
Hide file tree
Showing 77 changed files with 7,181 additions and 243 deletions.
7 changes: 5 additions & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ on:
tags:
- 'build'

env:
tag_name : v1.0.1

jobs:

apk:
Expand Down Expand Up @@ -53,8 +56,8 @@ jobs:
env:
GITHUB_TOKEN: ${{ secrets.RELEASE_TOKEN }}
with:
tag_name: v1.0.0
release_name: v1.0.0
tag_name: ${{env.tag_name}}
release_name: ${{env.tag_name}}
- name: Upload Release APK
id: upload_release_asset
uses: actions/upload-release-asset@v1.0.1
Expand Down
19 changes: 12 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,29 +4,30 @@ A new Wechat project.

# 介绍
wechat_flutter是flutter版微信,目前功能还在持续迭代,尽量还原原版微信功能。
Flutter版本:2.10.1
Flutter版本:3.0.0

#测试账号 18202003769 密码 Bb123456

下载体验(Android)
[https://github.com/LeeeYudE/flutter_wechat/releases/download/v1.0.0/app-release.apk](https://github.com/LeeeYudE/flutter_wechat/releases/download/v1.0.0/app-release.apk)
[https://github.com/LeeeYudE/flutter_wechat/releases/download/v1.0.1/app-release.apk](https://github.com/LeeeYudE/flutter_wechat/releases/download/v1.0.1/app-release.apk)

<img src="assets/screenshot/qrcode.png" style="zoom:30%;" />

# 效果图

| ![1.gif](https://github.com/LeeeYudE/flutter_wechat/blob/master/assets/screenshot/screenshot0.gif) | ![2.gif](https://github.com/LeeeYudE/flutter_wechat/blob/master/assets/screenshot/screenshot1.gif) | ![3.gif](https://github.com/LeeeYudE/flutter_wechat/blob/master/assets/screenshot/screenshot2.gif) |
|------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------|
| ![4.gif](https://github.com/LeeeYudE/flutter_wechat/blob/master/assets/screenshot/screenshot3.gif) | ![5.gif](https://github.com/LeeeYudE/flutter_wechat/blob/master/assets/screenshot/screenshot4.gif) | ![6.gif](https://github.com/LeeeYudE/flutter_wechat/blob/master/assets/screenshot/screenshot5.gif) |
| ![6.gif](https://github.com/LeeeYudE/flutter_wechat/blob/master/assets/screenshot/screenshot6.gif) | ![7.gif](https://github.com/LeeeYudE/flutter_wechat/blob/master/assets/screenshot/screenshot7.gif) |

| ![1.gif](https://github.com/LeeeYudE/flutter_wechat/blob/master/assets/screenshot/screenshot0.gif) | ![2.gif](https://github.com/LeeeYudE/flutter_wechat/blob/master/assets/screenshot/screenshot1.gif) | ![3.gif](https://github.com/LeeeYudE/flutter_wechat/blob/master/assets/screenshot/screenshot2.gif) |
|--------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------|
| ![4.gif](https://github.com/LeeeYudE/flutter_wechat/blob/master/assets/screenshot/screenshot3.gif) | ![5.gif](https://github.com/LeeeYudE/flutter_wechat/blob/master/assets/screenshot/screenshot4.gif) | ![6.gif](https://github.com/LeeeYudE/flutter_wechat/blob/master/assets/screenshot/screenshot5.gif) |
| ------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------ | ---------------------------------------------------------------------------------------------------- |
| ![4.gif](https://github.com/LeeeYudE/flutter_wechat/blob/master/assets/screenshot/screenshot6.gif) | ![5.gif](https://github.com/LeeeYudE/flutter_wechat/blob/master/assets/screenshot/screenshot7.gif) | ![8.gif](https://github.com/LeeeYudE/flutter_wechat/blob/master/assets/screenshot/screenshot8.gif) |

#Api方案采用Leancloud
* 数据存储文档:https://zh-docs.leancloud.app/leanstorage_guide-flutter.html
* IM聊天文档:https://zh-docs.leancloud.app/realtime-guide-beginner.html

# log

* 2022.08.15 增加视频号流程,支持上传视频。
* 2022.08.02 创建朋友圈增加定位选择流程。
* 2022.08.01 完成摇一摇页面,增加朋友圈点赞/评论流程。
* 2022.07.30 增加朋友圈列表数据显示。
Expand All @@ -44,6 +45,10 @@ Flutter版本:2.10.1
* 2022.06.27 创建主页面,创建二维码名片页面(支持名片二维码保存到本地),创建好友搜索页面。
* 2022.06.25 完成登录和注册流程

# todo
* 播放器增加缓存
* 支持Uniapp小程序跳转
* IMSDK有BUG,图片/录音/文件类型的发送流程暂未完成,等待官方修复。

#git type用于说明 commit 的类别,只允许使用下面7个标识
* feat:新功能(feature)
Expand Down
2 changes: 1 addition & 1 deletion android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ android {
defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "com.example.charco.wechat"
minSdkVersion 21
minSdkVersion 24
targetSdkVersion flutter.targetSdkVersion
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
Expand Down
Binary file added assets/images/discover/ff_Icon_channels.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/discover/icon_channels_comment.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/discover/icon_channels_favorite.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/discover/icon_channels_forword.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/discover/icon_channels_like.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/discover/icon_channels_liked.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/icon/no_data.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions assets/lottie/loading.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"v":"4.8.0","meta":{"g":"LottieFiles AE ","a":"","k":"","d":"","tc":""},"fr":25,"ip":0,"op":23,"w":500,"h":500,"nm":"Comp 1","ddd":0,"assets":[],"layers":[{"ddd":0,"ind":1,"ty":4,"nm":"Shape Layer 2","sr":1,"ks":{"o":{"a":0,"k":100,"ix":11},"r":{"a":0,"k":0,"ix":10},"p":{"a":1,"k":[{"i":{"x":0.667,"y":1},"o":{"x":0.333,"y":0},"t":0,"s":[292.879,246.15,0],"to":[-17.836,0,0],"ti":[0,0,0]},{"i":{"x":0.667,"y":1},"o":{"x":0.333,"y":0},"t":11.5,"s":[185.86,246.15,0],"to":[0,0,0],"ti":[-17.836,0,0]},{"t":23,"s":[292.879,246.15,0]}],"ix":2},"a":{"a":0,"k":[-146.25,68.75,0],"ix":1},"s":{"a":0,"k":[374.035,374.035,100],"ix":6}},"ao":0,"shapes":[{"ty":"gr","it":[{"ind":0,"ty":"sh","ix":1,"ks":{"a":0,"k":{"i":[[7.594,0],[0,-7.594],[-7.594,0],[0,7.594]],"o":[[-7.594,0],[0,7.594],[7.594,0],[0,-7.594]],"v":[[0,-13.75],[-13.75,0],[0,13.75],[13.75,0]],"c":true},"ix":2},"nm":"Path 1","mn":"ADBE Vector Shape - Group","hd":false},{"ty":"fl","c":{"a":0,"k":[0.12941176470588237,0.7176470588235294,0.7725490196078432,1],"ix":4},"o":{"a":0,"k":100,"ix":5},"r":1,"bm":0,"nm":"Fill 1","mn":"ADBE Vector Graphic - Fill","hd":false},{"ty":"tr","p":{"a":0,"k":[-146.25,68.75],"ix":2},"a":{"a":0,"k":[0,0],"ix":1},"s":{"a":0,"k":[100,100],"ix":3},"r":{"a":0,"k":-9.395,"ix":6},"o":{"a":0,"k":100,"ix":7},"sk":{"a":0,"k":0,"ix":4},"sa":{"a":0,"k":0,"ix":5},"nm":"Transform"}],"nm":"Ellipse 1","np":3,"cix":2,"bm":0,"ix":1,"mn":"ADBE Vector Group","hd":false}],"ip":0,"op":125,"st":0,"bm":0},{"ddd":0,"ind":2,"ty":4,"nm":"Shape Layer 1","sr":1,"ks":{"o":{"a":0,"k":100,"ix":11},"r":{"a":0,"k":0,"ix":10},"p":{"a":1,"k":[{"i":{"x":0.667,"y":1},"o":{"x":0.333,"y":0},"t":0,"s":[188.879,246.15,0],"to":[17.002,0,0],"ti":[0,0,0]},{"i":{"x":0.667,"y":1},"o":{"x":0.333,"y":0},"t":11.5,"s":[290.893,246.15,0],"to":[0,0,0],"ti":[17.002,0,0]},{"t":23,"s":[188.879,246.15,0]}],"ix":2},"a":{"a":0,"k":[-146.25,68.75,0],"ix":1},"s":{"a":0,"k":[374.035,374.035,100],"ix":6}},"ao":0,"shapes":[{"ty":"gr","it":[{"ind":0,"ty":"sh","ix":1,"ks":{"a":0,"k":{"i":[[7.594,0],[0,-7.594],[-7.594,0],[0,7.594]],"o":[[-7.594,0],[0,7.594],[7.594,0],[0,-7.594]],"v":[[0,-13.75],[-13.75,0],[0,13.75],[13.75,0]],"c":true},"ix":2},"nm":"Path 1","mn":"ADBE Vector Shape - Group","hd":false},{"ty":"fl","c":{"a":0,"k":[0.09019607843137255,0.3607843137254902,0.5764705882352941,1],"ix":4},"o":{"a":0,"k":100,"ix":5},"r":1,"bm":0,"nm":"Fill 1","mn":"ADBE Vector Graphic - Fill","hd":false},{"ty":"tr","p":{"a":0,"k":[-146.25,68.75],"ix":2},"a":{"a":0,"k":[0,0],"ix":1},"s":{"a":0,"k":[100,100],"ix":3},"r":{"a":0,"k":-9.395,"ix":6},"o":{"a":0,"k":100,"ix":7},"sk":{"a":0,"k":0,"ix":4},"sa":{"a":0,"k":0,"ix":5},"nm":"Transform"}],"nm":"Ellipse 1","np":3,"cix":2,"bm":0,"ix":1,"mn":"ADBE Vector Group","hd":false}],"ip":0,"op":125,"st":0,"bm":0},{"ddd":0,"ind":3,"ty":4,"nm":"Shape Layer 3","sr":1,"ks":{"o":{"a":0,"k":100,"ix":11},"r":{"a":0,"k":0,"ix":10},"p":{"a":0,"k":[251,258,0],"ix":2},"a":{"a":0,"k":[1,8,0],"ix":1},"s":{"a":0,"k":[100,100,100],"ix":6}},"ao":0,"shapes":[{"ty":"gr","it":[{"ty":"rc","d":1,"s":{"a":0,"k":[518,524],"ix":2},"p":{"a":0,"k":[0,0],"ix":3},"r":{"a":0,"k":0,"ix":4},"nm":"Rectangle Path 1","mn":"ADBE Vector Shape - Rect","hd":false},{"ty":"fl","c":{"a":0,"k":[0,0,0,1],"ix":4},"o":{"a":0,"k":100,"ix":5},"r":1,"bm":0,"nm":"Fill 1","mn":"ADBE Vector Graphic - Fill","hd":false},{"ty":"tr","p":{"a":0,"k":[1,8],"ix":2},"a":{"a":0,"k":[0,0],"ix":1},"s":{"a":0,"k":[100,100],"ix":3},"r":{"a":0,"k":0,"ix":6},"o":{"a":0,"k":100,"ix":7},"sk":{"a":0,"k":0,"ix":4},"sa":{"a":0,"k":0,"ix":5},"nm":"Transform"}],"nm":"Rectangle 1","np":3,"cix":2,"bm":0,"ix":1,"mn":"ADBE Vector Group","hd":false}],"ip":125,"op":125,"st":0,"bm":0,"hidden":0}],"markers":[]}
Binary file modified assets/screenshot/qrcode.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/screenshot/screenshot8.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 0 additions & 6 deletions build.sh

This file was deleted.

10 changes: 10 additions & 0 deletions build_Release.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#! /bin/bash

# 打包显示的日志

_tag=v1.0.1

git tag ${_tag}
git push --tags
git commit --allow-empty -m "[build] Release ${_tag}"
git push origin $branchg
5 changes: 5 additions & 0 deletions build_apk.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#! /bin/bash

# 打包显示的日志

flutter build apk --release
28 changes: 28 additions & 0 deletions lib/app_pages.dart
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,13 @@ import 'package:wechat/page/main/contacts/add_friend_page.dart';
import 'package:wechat/page/main/contacts/friend_detail_page.dart';
import 'package:wechat/page/main/contacts/new_friend_page.dart';
import 'package:wechat/page/main/contacts/search_friend_page.dart';
import 'package:wechat/page/main/discover/page/channels/channels_create_page.dart';
import 'package:wechat/page/main/discover/page/channels/channels_page.dart';
import 'package:wechat/page/main/discover/create_friend_circle_page.dart';
import 'package:wechat/page/main/discover/friend_circle_page.dart';
import 'package:wechat/page/main/discover/page/channels/channels_preview_page.dart';
import 'package:wechat/page/main/discover/page/channels/channels_select_cover_page.dart';
import 'package:wechat/page/main/discover/page/channels/channels_video_edit_page.dart';
import 'package:wechat/page/main/discover/shake_page.dart';
import 'package:wechat/page/main/map/nearby_location_page.dart';
import 'package:wechat/page/main/map/preview_loctaion_page.dart';
Expand Down Expand Up @@ -199,6 +204,29 @@ class AppPages {
name: RedPacketDetailPage.routeName,
page: () => RedPacketDetailPage(),
),
_getPage(
name: ChannelsPage.routeName,
page: () => ChannelsPage(),
),
_getPage(
name: ChannelsVideoEditPage.routeName,
page: () => ChannelsVideoEditPage(),
popGesture: false,
fullscreenDialog:true,
),
_getPage(
name: ChannelsCreatePage.routeName,
page: () => ChannelsCreatePage(),
),
_getPage(
name: ChannelsSelectCoverPage.routeName,
page: () => const ChannelsSelectCoverPage(),
fullscreenDialog:true,
),
_getPage(
name: ChannelsPreviewPage.routeName,
page: () => const ChannelsPreviewPage(),
),
];

static GetPage _getPage({
Expand Down
5 changes: 4 additions & 1 deletion lib/base/app_ui.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,12 @@ import 'package:flutter/material.dart';
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
import '../color/colors.dart';
import '../language/strings.dart';
import '../utils/utils.dart';
import '../widget/load_widget.dart';
import 'package:wechat/core.dart';

import '../widget/lottie_widget.dart';

/// @author Barry
/// @date 2020/11/17
/// describe:需要复写的一些AppUi相关基类
Expand Down Expand Up @@ -72,7 +75,7 @@ class AppUI extends AbstractAppUI {
return Column(
children: [
const Spacer(flex: 1),
LoadWidget(size: 100.w,color: Colours.c_999999),
LottieWidget(assetPath: Utils.getLottiePath('loading'), height: 200.w,width: 200.w,),
const Spacer(flex: 2),
],
);
Expand Down
25 changes: 12 additions & 13 deletions lib/base/base_getx.dart
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ abstract class BaseXController extends GetxController {
DialogUtil.disimssLoading();
}

lcPost(Function function,{ValueChanged<Exception>? onError,bool? showloading = true,bool? showToast = true,String? loadingMsg,bool changeState = false , bool updated = true,}) async {
Future<bool> lcPost(Function function,{ValueChanged<Exception>? onError,bool? showloading = true,bool? showToast = true,String? loadingMsg,bool changeState = false , bool updated = true,}) async {
if(showloading??false) {
showLoading(msg: loadingMsg);
}
Expand All @@ -64,16 +64,14 @@ abstract class BaseXController extends GetxController {
}else if(updated) {
update();
}
}on LCException catch (e){
if(showToast??false){
e.message.toast();
}
if(changeState){
setErrorState();
}
onError?.call(e);
debugPrint('${e.code} : ${e.message}');
if(showloading??false) {
disimssLoading();
}
return true;
}on Exception catch (e){
if(e is LCException){
debugPrint('${e.code} : ${e.message}');
}
if(showToast??false){
e.toString().toast();
}
Expand All @@ -82,9 +80,10 @@ abstract class BaseXController extends GetxController {
}
onError?.call(e);
e.printError();
}
if(showloading??false) {
disimssLoading();
if(showloading??false) {
disimssLoading();
}
return false;
}

}
Expand Down
41 changes: 41 additions & 0 deletions lib/base/base_getx_refresh.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import 'package:wechat/core.dart';
import 'package:flutter/cupertino.dart';
import 'package:get/get.dart';
import 'package:leancloud_storage/leancloud.dart';
import 'package:wechat/utils/dialog_util.dart';

import 'base_getx.dart';
import 'constant.dart';

typedef OnQueryList = Future Function(List<LCObject> list);

///Controller
abstract class BaseXRefreshController extends BaseXController {

int _page = 0;
RxList<LCObject> list = <LCObject>[].obs;
bool canLoad = true;

Future<bool> queryList(LCQuery query,{bool refresh = false,OnQueryList? onQueryList}){
return lcPost(() async {
var lcQuery = query;
lcQuery.limit(Constant.PAGE_SIZE);
lcQuery.skip(refresh?0:Constant.PAGE_SIZE * _page);
List<LCObject> find = await lcQuery.find(cachePolicy: CachePolicy.networkElseCache)??[];
canLoad = find.length >= Constant.PAGE_SIZE;
if(refresh){
list.clear();
}
await onQueryList?.call(find);
list.addAll(find);
if(refresh){
_page = 1;
}else{
_page ++ ;
}
},showloading: false,updated: false,changeState: list.isEmpty);
}


}

7 changes: 5 additions & 2 deletions lib/base/base_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ abstract class BaseView<T> extends GetView<T> {
StatelessElement createElement() {
debugPrint('charco, createElement=> build-$this');
onInit();
WidgetsBinding.instance?.addPostFrameCallback((timeStamp) {
WidgetsBinding.instance.addPostFrameCallback((timeStamp) {
debugPrint('charco, createElement=> onReady-$this');
onReady();
});
Expand All @@ -35,7 +35,7 @@ abstract class BaseGetBuilder<T extends GetxController> extends GetView<T> {
StatelessElement createElement() {
debugPrint('charco, createElement=> build-$this');
onInit();
WidgetsBinding.instance?.addPostFrameCallback((timeStamp) {
WidgetsBinding.instance.addPostFrameCallback((timeStamp) {
debugPrint('charco, createElement=> onReady-$this');
onReady();
});
Expand All @@ -48,12 +48,15 @@ abstract class BaseGetBuilder<T extends GetxController> extends GetView<T> {
@override
Widget build(BuildContext context) {
return GetBuilder<T>(
tag: getTag(),
init: getController()??controller,
builder: (controller) {
return controllerBuilder(context,controller);
});
}

String? getTag() => null;

///获取控制器,为null会直接使用默认的
T? getController();

Expand Down
2 changes: 2 additions & 0 deletions lib/base/constant.dart
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ class Constant{

static const String OBJECT_NAME_RED_PACKET = 'redPacket';
static const String OBJECT_NAME_FRIEND_CIRCLE = 'friendCircle';
static const String OBJECT_NAME_CHANNLES = 'channles';
static const String OBJECT_NAME_CHANNLES_COMMENTS = 'channlesComments';

static final double MAX_PHOTO_WIDTH = 600.w;
static final double MAX_PHOTO_HEIGHT = 600.w;
Expand Down
1 change: 1 addition & 0 deletions lib/color/colors.dart
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ class Colours {
static const Color c_f0f0f0 = Color(0xFFf0f0f0);
static const Color c_FA9E3B = Color(0xFFFA9E3B);
static const Color c_FCE5BF = Color(0xFFFCE5BF);
static const Color c_ffce53 = Color(0xFFffce53);

static const Color line_color = Color(0xFFA3A3A4);

Expand Down
23 changes: 15 additions & 8 deletions lib/controller/chat_manager_controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,21 @@ class ChatManagerController extends BaseXController {
late Client imClient;

initClient() async {
imClient = Client(id: UserController.instance.username);
await imClient.open();
imClient.onMessage = _onMessage;
imClient.onMessageUpdated = _onMessageUpdated;
imClient.onMessageDelivered = _onMessageDelivered;
imClient.onMessageRead = _onMessageRead;
imClient.onUnreadMessageCountUpdated = _onUnreadMessageCountUpdated;
chatIndex();
lcPost(() async {
imClient = Client(id: UserController.instance.username);
await imClient.open();
imClient.onMessage = _onMessage;
imClient.onMessageUpdated = _onMessageUpdated;
imClient.onMessageDelivered = _onMessageDelivered;
imClient.onMessageRead = _onMessageRead;
imClient.onUnreadMessageCountUpdated = _onUnreadMessageCountUpdated;
chatIndex();
},onError: (e){
Future.delayed(const Duration(seconds: 3),(){
initClient();
});
},showloading: false,showToast: false);

}

removeCurrentConversation(){
Expand Down
18 changes: 11 additions & 7 deletions lib/controller/video_manager.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ class VideoManager{

static final Map<String,VideoPlayerController> _controllerMap = {};

static VideoPlayerController getVideoController(String url,{bool cache = true}) {
if(_controllerMap.containsKey(url) && cache){
return _controllerMap[url]!;
static VideoPlayerController getVideoController(String url,{String? cacheId}) {
if(cacheId != null && _controllerMap.containsKey(cacheId)){
return _controllerMap[cacheId]!;
}
VideoPlayerController _videoPlayerController;
if (url.startsWith('http')) {
Expand All @@ -19,13 +19,17 @@ class VideoManager{
final file = File(url);
_videoPlayerController = VideoPlayerController.file(file);
}
_videoPlayerController.initialize();
_controllerMap[url] = _videoPlayerController;
// _videoPlayerController.initialize();
if(cacheId != null){
_controllerMap[cacheId] = _videoPlayerController;
}
return _videoPlayerController;
}

static removeChewieController(String url){
_controllerMap.remove(url);
static removeChewieController(String? cacheId){
if(cacheId != null) {
_controllerMap.remove(cacheId);
}
}


Expand Down
2 changes: 1 addition & 1 deletion lib/ext/widget_ext.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import 'package:flutter/services.dart';
extension WidgetExt on Widget{

addPostFrameCallback(FrameCallback frameCallback){
WidgetsBinding.instance?.addPostFrameCallback(frameCallback);
WidgetsBinding.instance.addPostFrameCallback(frameCallback);
}

}
Expand Down
Loading

0 comments on commit 569a56b

Please sign in to comment.