interrogation_page.dart 30 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766
  1. import 'package:flutter/material.dart';
  2. import 'package:liftmanager/res/gaps.dart';
  3. import 'package:liftmanager/net/api_service.dart';
  4. import 'package:liftmanager/utils/toast.dart';
  5. import 'package:liftmanager/widgets/app_bar.dart';
  6. import 'package:liftmanager/internal/search/search_router.dart';
  7. import 'package:liftmanager/widgets/app_search_bar.dart';
  8. import 'package:liftmanager/res/resources.dart';
  9. import 'package:liftmanager/routers/fluro_navigator.dart';
  10. import 'package:liftmanager/widgets/load_image.dart';
  11. import 'package:liftmanager/widgets/selected_image_change.dart';
  12. import 'package:image_picker/image_picker.dart';
  13. import 'dart:io';
  14. import 'package:flutter_screenutil/flutter_screenutil.dart';
  15. import 'package:liftmanager/internal/bbs/bbs_router.dart';
  16. import 'dart:convert';
  17. import 'package:shared_preferences/shared_preferences.dart';
  18. import 'package:liftmanager/common/common.dart';
  19. import 'package:flustars/flustars.dart' as flustars;
  20. import 'package:liftmanager/utils/theme_utils.dart';
  21. import 'package:chewie/chewie.dart';
  22. import 'package:liftmanager/utils/oss_upload.dart';
  23. import 'package:video_player/video_player.dart';
  24. import 'package:liftmanager/widgets/selected_video_change.dart';
  25. import 'package:liftmanager/utils/utils.dart';
  26. import 'package:orientation/orientation.dart';
  27. import 'package:flutter/services.dart';
  28. import 'package:liftmanager/utils/fast_notification.dart';
  29. class InterrogationPage extends StatefulWidget {
  30. InterrogationPage(this.brandName,this.brandId);
  31. final String brandName;
  32. final String brandId;
  33. @override
  34. State<StatefulWidget> createState() {
  35. return InterrogationPageState();
  36. }
  37. }
  38. class InterrogationPageState extends State<InterrogationPage> {
  39. // NewsDetailItem item = NewsDetailItem();
  40. List<String> imagesUrl = [];
  41. String videoUrl;
  42. String str;
  43. double percent = 0.0;
  44. String addressName = "";
  45. VideoPlayerController _controller;
  46. VideoPlayerController _controllerFile;
  47. @override
  48. void initState() {
  49. super.initState();
  50. print(widget.brandName);
  51. print(widget.brandId);
  52. print(65656);
  53. }
  54. //图片
  55. upLoadFileOnce(path) {
  56. showLoading(context, "正在上传...");
  57. NewApiService().upload(path, onSuccess: (res) {
  58. // imagesUrl.add(res.path);
  59. dismissLoading(context);
  60. setState(() {
  61. imagesUrl.add(res.pathUrl);
  62. });
  63. }, onError: (code, msg) {
  64. dismissLoading(context);
  65. toasts(msg);
  66. });
  67. }
  68. //视频
  69. upLoadFileOnceVideo(path) {
  70. showLoading(context, "正在上传...");
  71. NewApiService().upload(path, onSuccess: (res) {
  72. // imagesUrl.add(res.path);
  73. dismissLoading(context);
  74. setState(() {
  75. // videoUrl.add(res.pathUrl);
  76. // imagesUrlVideo.add(res.coverUrl);
  77. });
  78. }, onError: (code, msg) {
  79. dismissLoading(context);
  80. toasts(msg);
  81. });
  82. }
  83. ///选择图片
  84. void selectPicker(type) {
  85. showDialog(
  86. context: context,
  87. builder: (BuildContext context) {
  88. return SimpleDialog(
  89. title: Text("选择方式"),
  90. children: ["拍照", '从手机相册选择'].map((String value) {
  91. print("$value");
  92. return SimpleDialogOption(
  93. child: Text(
  94. "${value}",
  95. style: TextStyle(fontSize: 16, fontWeight: FontWeight.w500),
  96. ),
  97. onPressed: () {
  98. if(type=="image"){
  99. _getImage(value == '拍照' ? 1 : 0);
  100. }else if (type=="video") {
  101. _getVideo(value == '拍照' ? 1 : 0);
  102. }
  103. Navigator.of(context).pop();
  104. },
  105. );
  106. }).toList());
  107. });
  108. }
  109. void _getImage(int key) async {
  110. try {
  111. var _imageFile = await ImagePicker.pickImage(
  112. source: key == 1 ? ImageSource.camera : ImageSource.gallery,
  113. maxWidth: 800,
  114. imageQuality: 95);
  115. print(_imageFile);
  116. print(3333);
  117. if (_imageFile != null) {
  118. // images.add(_imageFile);
  119. upLoadFileOnce(_imageFile.path);
  120. // setState(() {});
  121. }
  122. } catch (e) {
  123. toasts("没有权限,无法打开相册!");
  124. }
  125. }
  126. void _getVideo(int key) async {
  127. print(key);
  128. print(333);
  129. try {
  130. await ImagePicker.pickVideo(
  131. source: key == 1 ? ImageSource.camera : ImageSource.gallery,
  132. )
  133. .then((File f) async{
  134. if (f != null) {
  135. _controllerFile = VideoPlayerController.file(f);
  136. _controllerFile.initialize().then((val){
  137. _controllerFile.setLooping(true);
  138. int seconds = _controllerFile.value.duration.inSeconds;
  139. print("视频时长:$seconds");
  140. int fileSize=f.lengthSync();//单位B
  141. print("视频大小:${fileSize}");
  142. print("视频大小:${f.path}");
  143. if (seconds <= 300) {
  144. _uploadImage(f.path);
  145. // upLoadFileOnce(_imageFile.path);
  146. // setState(() {});
  147. }else {
  148. toasts("视频时长不能大于5分钟!");
  149. }
  150. }).catchError((error){
  151. print(error);
  152. print("error");
  153. toasts("上传失败,不支持此格式");
  154. });}
  155. })
  156. ;
  157. } catch (e) {
  158. toasts("没有权限,无法打开相册!");
  159. }
  160. }
  161. void _uploadImage(filePath) async {
  162. showPercent(context, (){
  163. dismissLoading(context);
  164. toasts("上传失败");
  165. },(){
  166. if(videoUrl == null && str != null){
  167. setState(() {
  168. videoUrl = str;
  169. print("videoUrl:"+videoUrl);
  170. dismissLoading(context);
  171. toasts("上传成功");
  172. });
  173. }
  174. });
  175. String uploadName = OssUtil.instance.getImageUploadName(filePath);
  176. await NewApiService.uploadImage(context, uploadName, filePath).then((data) {
  177. if (data.statusCode == 200) {
  178. str = NewApiUrl.URL_UPLOAD_IMAGE_OSS + "/" + uploadName;
  179. print("str:"+str);
  180. print(videoUrl);
  181. if(str != null){
  182. Map obj = {
  183. "uploadName":uploadName,
  184. "success":true
  185. };
  186. FastNotification.push("percent",obj);
  187. }
  188. }else {
  189. Map obj = {
  190. "uploadName":uploadName,
  191. "success":false
  192. };
  193. FastNotification.push("percent",obj);
  194. }
  195. }).catchError((data) {
  196. Map obj = {
  197. "uploadName":uploadName,
  198. "success":false
  199. };
  200. FastNotification.push("percent",obj);
  201. });
  202. }
  203. // 焦点控制
  204. // FocusNode _focusNode1 = new FocusNode();
  205. GlobalKey _formKey= new GlobalKey<FormState>();
  206. TextEditingController _questionController = new TextEditingController();
  207. TextEditingController _methodController = new TextEditingController();
  208. FocusNode blankNode = FocusNode();
  209. @override
  210. Widget build(BuildContext context) {
  211. double width = MediaQuery.of(context).size.width;
  212. // 监听FocusNode
  213. // _focusNode1.addListener((){
  214. // // _focusNode1.hasFocus 是否聚焦
  215. // print(_focusNode1.hasFocus);
  216. // });
  217. return Scaffold(
  218. resizeToAvoidBottomPadding: false,//不让键盘弹上去
  219. appBar: MyAppBar(
  220. centerTitle: "我要提问",
  221. ),
  222. body: GestureDetector(
  223. onTap: (){
  224. // 点击空白页面关闭键盘
  225. FocusScope.of(context).requestFocus(blankNode);
  226. },
  227. child: Stack(
  228. children:<Widget>[
  229. Container(
  230. padding: EdgeInsets.only(bottom:ScreenUtil().setWidth(80)),
  231. child: ListView(
  232. children: <Widget>[
  233. Form(
  234. key: _formKey, //设置globalKey,用于后面获取FormState
  235. // autovalidate: true, //开启自动校验
  236. child: Column(
  237. children: <Widget>[
  238. Container(
  239. padding: EdgeInsets.only(left:ScreenUtil().setWidth(15),right:ScreenUtil().setWidth(15),top:ScreenUtil().setWidth(10),bottom:ScreenUtil().setWidth(10)),
  240. decoration: BoxDecoration(
  241. border: Border(
  242. bottom: BorderSide(width: 0.5, color: Colours.line),
  243. ),
  244. ),
  245. child: Row(
  246. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  247. children:<Widget>[
  248. Text(
  249. "电梯品牌",
  250. style: TextStyle(
  251. // fontSize:ScreenUtil().setSp(14)
  252. ),
  253. textAlign:TextAlign.start,
  254. ),
  255. Text(
  256. widget.brandName,
  257. style: TextStyle(
  258. color:Color(0xff999999),
  259. // fontSize:ScreenUtil().setSp(14)
  260. ),
  261. textAlign:TextAlign.start,
  262. ),
  263. ]
  264. ),
  265. ),
  266. Row(
  267. crossAxisAlignment: CrossAxisAlignment.start,
  268. mainAxisAlignment: MainAxisAlignment.start,
  269. children: <Widget>[
  270. Container(
  271. padding:EdgeInsets.only(left:ScreenUtil().setWidth(15),top:ScreenUtil().setWidth(10),bottom:ScreenUtil().setWidth(5)),
  272. child: Text(
  273. "问题描述",
  274. style: TextStyle(
  275. // fontSize:ScreenUtil().setSp(14),
  276. ),
  277. textAlign:TextAlign.left,
  278. ),
  279. ),
  280. ],
  281. ),
  282. Container(
  283. height:120,
  284. padding: EdgeInsets.only(left:ScreenUtil().setWidth(15),right:ScreenUtil().setWidth(15),bottom:ScreenUtil().setWidth(20)),
  285. child: TextFormField(
  286. // autofocus: true,
  287. maxLength: 50,
  288. cursorColor: Color(0xffcccccc),
  289. controller: _questionController,
  290. maxLines:5,
  291. decoration: InputDecoration(
  292. contentPadding: EdgeInsets.all(0),
  293. hintText: '请详细描述事故问题和现场情况',
  294. hintStyle:TextStyle(
  295. color: Color(0xffcccccc),
  296. // fontSize: ScreenUtil().setSp(14),
  297. ),
  298. focusedBorder: InputBorder.none,
  299. border: InputBorder.none,
  300. // filled: true, // 背景色
  301. // fillColor: Colors.cyan.withAlpha(35),
  302. // icon: Icon(Icons.person)
  303. ),
  304. // 校验
  305. validator: (val) {
  306. return val.trim().length > 0 ? null : "不能为空";
  307. }
  308. ),
  309. ),
  310. SizedBox(
  311. height:6,
  312. child: Container(
  313. color:ThemeUtils.getDialogTextFieldColor(context)
  314. ),
  315. ),
  316. Row(
  317. crossAxisAlignment: CrossAxisAlignment.start,
  318. mainAxisAlignment: MainAxisAlignment.start,
  319. children: <Widget>[
  320. Container(
  321. padding:EdgeInsets.only(left:ScreenUtil().setWidth(15),top:ScreenUtil().setWidth(10),bottom:ScreenUtil().setWidth(5)),
  322. child: Text(
  323. "已尝试方法",
  324. style: TextStyle(
  325. // fontSize:ScreenUtil().setSp(14),
  326. ),
  327. textAlign:TextAlign.left,
  328. ),
  329. ),
  330. ],
  331. ),
  332. Container(
  333. height:120,
  334. padding: EdgeInsets.only(left:ScreenUtil().setWidth(15),right:ScreenUtil().setWidth(15),bottom:ScreenUtil().setWidth(20)),
  335. child: TextFormField(
  336. // autofocus: true,
  337. maxLength: 50,
  338. cursorColor: Color(0xffcccccc),
  339. controller: _methodController,
  340. maxLines:5,
  341. decoration: InputDecoration(
  342. contentPadding: EdgeInsets.all(0),
  343. hintText: '请详细描述已尝试方法以及结果',
  344. hintStyle:TextStyle(
  345. color: Color(0xffcccccc),
  346. // fontSize: ScreenUtil().setSp(14),
  347. ),
  348. focusedBorder: InputBorder.none,
  349. border: InputBorder.none,
  350. // filled: true, // 背景色
  351. // fillColor: Colors.cyan.withAlpha(35),
  352. // icon: Icon(Icons.person)
  353. ),
  354. // 校验
  355. validator: (val) {
  356. return val.trim().length > 0 ? null : "不能为空";
  357. }
  358. ),
  359. ),
  360. SizedBox(
  361. height:6,
  362. child: Container(
  363. color:ThemeUtils.getDialogTextFieldColor(context)
  364. ),
  365. ),
  366. Container(
  367. width: width,
  368. padding: EdgeInsets.only(left:15,top:15),
  369. child: Text(
  370. "上传图片:",
  371. style: TextStyle(
  372. fontSize:
  373. ScreenUtil()
  374. .setSp(14),
  375. ),
  376. textAlign: TextAlign.left,
  377. ),
  378. ),
  379. Container(
  380. color: ThemeUtils.getTabsBg(context),
  381. child: GridView.builder(
  382. shrinkWrap: true,
  383. padding: const EdgeInsets.fromLTRB(8.0, 12, 8.0, 12.0),
  384. physics: NeverScrollableScrollPhysics(),
  385. gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
  386. crossAxisCount: 3, childAspectRatio: 1.18),
  387. itemCount: imagesUrl.length >= 9 ? 9 : imagesUrl.length + 1,
  388. itemBuilder: (_, index) {
  389. return Stack(
  390. children: <Widget>[
  391. Center(
  392. child: SelectedImage(
  393. image: index < imagesUrl.length ? imagesUrl[index] : null,
  394. index:index,
  395. onTap: () {
  396. if(index >= imagesUrl.length){
  397. selectPicker("image");
  398. }
  399. FocusScope.of(context).requestFocus(FocusNode());
  400. print(index);
  401. print(imagesUrl);
  402. }),
  403. ),
  404. index < imagesUrl.length?Positioned(
  405. top:0,
  406. right:0,
  407. child:GestureDetector(
  408. onTap: (){
  409. print(index);
  410. imagesUrl.remove(imagesUrl[index]);
  411. setState(() {
  412. });
  413. },
  414. child:Icon(
  415. IconData(
  416. 0xe62a,
  417. fontFamily:"myfont"
  418. ),
  419. size: 24.0,
  420. color:Color(0xff999999),
  421. ),
  422. )
  423. ):Container(child: null,)
  424. ],
  425. );
  426. },
  427. )
  428. ),
  429. SizedBox(
  430. height:6,
  431. child: Container(
  432. color:ThemeUtils.getDialogTextFieldColor(context)
  433. ),
  434. ),
  435. Container(
  436. width: width,
  437. padding: EdgeInsets.only(left:15,top:15),
  438. child: Text(
  439. "上传视频:",
  440. style: TextStyle(
  441. fontSize:
  442. ScreenUtil()
  443. .setSp(14),
  444. ),
  445. textAlign: TextAlign.left,
  446. ),
  447. ),
  448. Container(
  449. width: width,
  450. padding: EdgeInsets.only(left:15,bottom:15),
  451. child: Text(
  452. "(建议时长3分钟,建议大小50M)",
  453. style: TextStyle(
  454. color: Colors.red,
  455. fontSize:
  456. ScreenUtil()
  457. .setSp(14),
  458. ),
  459. textAlign: TextAlign.left,
  460. ),
  461. ),
  462. // Container(
  463. // color: ThemeUtils.getTabsBg(context),
  464. // child: GridView.builder(
  465. // shrinkWrap: true,
  466. // padding: const EdgeInsets.fromLTRB(8.0, 12, 8.0, 12.0),
  467. // physics: NeverScrollableScrollPhysics(),
  468. // gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
  469. // crossAxisCount: 3, childAspectRatio: 1.18),
  470. // itemCount: videoUrl.length >= 1 ? 1 : videoUrl.length + 1,
  471. // itemBuilder: (_, index) {
  472. // return Stack(
  473. // children: <Widget>[
  474. // Center(
  475. // child: SelectedImage(
  476. // image: index < videoUrl.length ? imagesUrlVideo[index] : null,
  477. // index:index,
  478. // onTap: () {
  479. // if(index >= videoUrl.length){
  480. // selectPicker("video");
  481. // }
  482. // FocusScope.of(context).requestFocus(FocusNode());
  483. // print(index);
  484. // print(videoUrl);
  485. // }),
  486. // ),
  487. // index < videoUrl.length?Positioned(
  488. // top:0,
  489. // right:0,
  490. // child:GestureDetector(
  491. // onTap: (){
  492. // print(index);
  493. // videoUrl.remove(videoUrl[index]);
  494. // imagesUrlVideo.remove(imagesUrlVideo[index]);
  495. // setState(() {
  496. // });
  497. // },
  498. // child:Icon(
  499. // IconData(
  500. // 0xe62a,
  501. // fontFamily:"myfont"
  502. // ),
  503. // size: 24.0,
  504. // color:Color(0xff999999),
  505. // ),
  506. // )
  507. // ):Container(child: null,)
  508. // ],
  509. // );
  510. // },
  511. // )
  512. // ),
  513. Container(
  514. color: ThemeUtils.getDialogTextFieldColor(context),
  515. child: GridView.builder(
  516. shrinkWrap: true,
  517. padding: const EdgeInsets.fromLTRB(8.0, 12, 8.0, 12.0),
  518. physics: NeverScrollableScrollPhysics(),
  519. gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
  520. crossAxisCount: 1, childAspectRatio: 1.18),
  521. itemCount: 1,
  522. itemBuilder: (_, index) {
  523. return Stack(
  524. children: <Widget>[
  525. Center(
  526. child: SelectedVideo(
  527. image: videoUrl,
  528. index: index,
  529. videoPlay:videoPlay(),
  530. onTap: () {
  531. if(videoUrl == null){
  532. selectPicker("video");
  533. }
  534. },
  535. ),
  536. ),
  537. videoUrl != null
  538. ? Positioned(
  539. top: 0,
  540. right: 0,
  541. child: GestureDetector(
  542. onTap: () {
  543. print(index);
  544. // imagesUrl = null;
  545. setState(() {
  546. videoUrl = null;
  547. str = null;
  548. _controller.pause();
  549. // player.reset();
  550. });
  551. },
  552. child: Icon(
  553. IconData(0xe62a, fontFamily: "myfont"),
  554. size: 24.0,
  555. color: Color(0xff999999),
  556. ),
  557. ),
  558. )
  559. : Container(
  560. child: null,
  561. )
  562. ],
  563. );
  564. },
  565. ),
  566. ),
  567. ],
  568. ),
  569. )
  570. ]
  571. )
  572. ),
  573. Positioned(
  574. bottom:0,
  575. left:0,
  576. child:Container(
  577. width: width,
  578. padding: EdgeInsets.only(top:ScreenUtil().setWidth(15),bottom:ScreenUtil().setWidth(15),left:ScreenUtil().setWidth(25),right:ScreenUtil().setWidth(25)),
  579. color:ThemeUtils.getDialogTextFieldColor(context),
  580. child: Container(
  581. height:ScreenUtil().setWidth(44),
  582. decoration: BoxDecoration(
  583. borderRadius: BorderRadius.circular(22.0),
  584. gradient: const LinearGradient(
  585. colors: [Color(0xFF00D9FF), Color(0xFF0287FF)]),
  586. ),
  587. child: FlatButton(
  588. // padding: EdgeInsets.all(15.0),
  589. child: Text("提交"),
  590. textColor: Colors.white,
  591. // textColor: Colors.white,
  592. onPressed: () {
  593. // if(imagesUrl.length<1){
  594. // toasts("请上传图片");
  595. // return;
  596. // }
  597. String imgs = "";
  598. if(imagesUrl.length > 0){
  599. imgs = imagesUrl.join(",");
  600. }
  601. // String videoImgs = "";
  602. // if(videoUrl.length > 0){
  603. // videoImgs = videoUrl.join(",");
  604. // }
  605. if((_formKey.currentState as FormState).validate()){
  606. dynamic obj = {
  607. "dataTable":"1",
  608. "brandId":widget.brandId,
  609. "expression":_questionController.text,
  610. "usedMethods":_methodController.text,
  611. "imgs":imgs,
  612. "videoUrl":videoUrl,
  613. "createUserId":int.parse(flustars.SpUtil.getString(Constant.userId)),
  614. "chargerId":1
  615. };
  616. showLoading(context, "正在提交...");
  617. NewApiService().createCase(obj, onSuccess: (res) {
  618. dismissLoading(context);
  619. toasts("提交成功");
  620. FocusScope.of(context).requestFocus(FocusNode());
  621. print(res);
  622. print(999999);
  623. setDataId(res);
  624. setType("1");
  625. print(widget.brandId);
  626. if(_controller!=null){
  627. _controller.pause();
  628. }
  629. NavigatorUtils.push(context, "${BbsRouter.expertList}?id=${widget.brandId}");
  630. }, onError: (code, msg) {
  631. dismissLoading(context);
  632. toasts(msg);
  633. });
  634. }
  635. },
  636. ),
  637. ),
  638. )
  639. )
  640. ]
  641. ),
  642. ),
  643. );
  644. }
  645. void setDataId (int id)async{
  646. SharedPreferences prefs = await SharedPreferences.getInstance();
  647. prefs.setInt("dataId", id);
  648. }
  649. void setType (String type)async{
  650. SharedPreferences prefs = await SharedPreferences.getInstance();
  651. prefs.setString("questionType", type);
  652. }
  653. Widget videoPlay() {
  654. _controller = VideoPlayerController.network(
  655. Utils.getImagePath(videoUrl)
  656. // imgFontUrl + detailObj.url
  657. );
  658. double width = MediaQuery.of(context).size.width;
  659. return
  660. // Container(
  661. // width: width,
  662. // height: width*0.6,
  663. // alignment: Alignment.center,
  664. // child: FijkView(
  665. // player: player,
  666. // color: Colors.black,
  667. // fit:FijkFit.fill,
  668. // // cover: NetworkImage(detailObj.cover),
  669. // // cover: new Image(image: detailObj.cover!=null&& detailObj.cover!=""?NetworkImage(detailObj.cover):AssetImage("assets/images/video_image.png"),).image,
  670. // //
  671. // ),
  672. // );
  673. Container(
  674. padding: EdgeInsets.only(
  675. left: ScreenUtil().setWidth(15),
  676. right: ScreenUtil().setWidth(15),
  677. top: ScreenUtil().setWidth(15)),
  678. child: ClipRRect(
  679. borderRadius: BorderRadius.circular(5),
  680. child:
  681. new Chewie(
  682. controller: ChewieController(
  683. videoPlayerController:
  684. // VideoPlayerController.network(
  685. // imgFontUrl + detailObj.url
  686. // ),
  687. _controller,
  688. aspectRatio: 3 / 2,
  689. allowFullScreen:false,
  690. autoPlay: false,
  691. looping: true,
  692. // startAt: Duration(seconds: 1,minutes: 1),
  693. showControls: true,
  694. deviceOrientationsAfterFullScreen:[DeviceOrientation.portraitUp],
  695. // 占位图
  696. // placeholder: Image.network(
  697. // imgFontUrl+detailObj.cover,
  698. // fit: BoxFit.contain,
  699. // ),
  700. // 是否在 UI 构建的时候就加载视频
  701. autoInitialize: true,
  702. // 拖动条样式颜色
  703. materialProgressColors:
  704. new ChewieProgressColors(
  705. playedColor: Colors.red,
  706. handleColor: Colors.blue,
  707. backgroundColor: Colors.grey,
  708. bufferedColor: Colors.lightGreen,
  709. ),
  710. ),
  711. ),
  712. )
  713. );
  714. }
  715. }