video_upload.dart 32 KB

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