flutter app untuk unitstock
選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。
 
 
 
 
 

834 行
46 KiB

  1. import 'dart:typed_data';
  2. import 'Util/UnitModel.dart';
  3. import 'Util/photo_viewer.dart';
  4. import 'package:flutter/cupertino.dart';
  5. import 'package:flutter/material.dart';
  6. import 'package:image_picker/image_picker.dart';
  7. import 'Util/DBHelper.dart';
  8. import 'Util/Util.dart';
  9. import 'main.dart';
  10. import 'package:intl/intl.dart';
  11. class UnitDetails extends StatefulWidget {
  12. Unit unit;
  13. UnitDetails({this.unit});
  14. @override
  15. _UnitDetailsState createState() => _UnitDetailsState();
  16. }
  17. class _UnitDetailsState extends State<UnitDetails> {
  18. final tipeController = TextEditingController();
  19. final rangkaController = TextEditingController();
  20. final colorController = TextEditingController();
  21. final kodeController = TextEditingController();
  22. final mesinController = TextEditingController();
  23. final tahunController = TextEditingController();
  24. final stateController = TextEditingController();
  25. final channelController = TextEditingController();
  26. // insertUnit _unitDetails;
  27. bool isChanged = false;
  28. Util util = new Util();
  29. List<Uint8List> images = [];
  30. List<int> blobIds = [];
  31. List<int> deleteBlobIds = [];
  32. List<jenisDrop> dropMenu = [];
  33. List<String> jenisImages = [];
  34. int jenisLength=0;
  35. Unit _currentUnit;
  36. List<blobImage> blobList = [];
  37. // List<Unit> allUnits = [];
  38. loadUnitDetails(context)async{
  39. _currentUnit = widget.unit;
  40. tipeController.text= _currentUnit.tipe;
  41. rangkaController.text = _currentUnit.rangka;
  42. colorController.text = _currentUnit.warna;
  43. kodeController.text = _currentUnit.kode;
  44. mesinController.text = _currentUnit.mesin;
  45. tahunController.text = _currentUnit.tahun;
  46. stateController.text = _currentUnit.state;
  47. channelController.text = (_currentUnit.channel==null||_currentUnit.channel==""||_currentUnit.channel=="null")?'-':_currentUnit.channel;
  48. await loadBlob();
  49. }
  50. // loadTipe() async{
  51. // allUnits.clear();
  52. // allUnits = await DBHelper.database.getAllUnits();
  53. // }
  54. loadBlob()async{
  55. var result = await DBHelper.database.getBlobUnits(mesinController.text);
  56. if(result!=null){
  57. setState(() {
  58. blobList = result;
  59. });
  60. // for(int i =0; i<result.length;i++){
  61. // images.add(result[i].blob_file);
  62. // blobIds.add(result[i].blob_id);
  63. // jenisImages.add(result[i].jenis);
  64. // }
  65. // dropMenu = result;
  66. // jenisLength = result.length;
  67. // if(jenisImages.length!=0){
  68. // for (int i =0;i<jenisImages.length;i++){
  69. // dropMenu.removeWhere((element) => element.value==jenisImages[i]);
  70. // }
  71. // }
  72. }
  73. }
  74. @override
  75. void initState() {
  76. // TODO: implement initState
  77. super.initState();
  78. WidgetsBinding.instance.addPostFrameCallback((_) async {
  79. util.showLoading(context);
  80. await Future.sync(()async{await loadUnitDetails(context);});
  81. Navigator.pop(context);
  82. });
  83. }
  84. @override
  85. Widget build(BuildContext context) {
  86. // if(allUnits.length!=0){
  87. // print(allUnits[0].tipe);
  88. //// loadTipe();
  89. // }
  90. return Scaffold(
  91. resizeToAvoidBottomInset: true,
  92. appBar: AppBar(
  93. backgroundColor: Colors.transparent,
  94. elevation: 0.0,
  95. iconTheme: IconThemeData(
  96. color: Colors.indigo,
  97. ),
  98. title: Text((widget.unit.flag=='FALSE')?'Inserting New Unit':'Editing Unit',style: TextStyle(color: Colors.indigo),),
  99. ),
  100. body: WillPopScope(
  101. onWillPop: ()async{
  102. if(widget.unit.flag=='TRUE'){
  103. if(isChanged){
  104. await showDialog(context: context,builder: (context)=>
  105. Material(
  106. color: Colors.white.withOpacity(0.9),
  107. child: Center(
  108. child: Container(
  109. decoration: BoxDecoration(
  110. color: Colors.white,
  111. boxShadow: [
  112. BoxShadow(
  113. color: Colors.grey.withOpacity(0.5),
  114. spreadRadius: 2,
  115. blurRadius: 2,
  116. offset: Offset(0, 0), // changes position of shadow
  117. ),
  118. ],
  119. borderRadius: BorderRadius.circular(5)
  120. ),
  121. height:220,
  122. // height: MediaQuery.of(context).size.height/4.8,
  123. width: MediaQuery.of(context).size.width*0.75,
  124. child: Column(
  125. children: <Widget>[
  126. Flexible(
  127. flex:3,
  128. child: Container(
  129. padding: EdgeInsets.only(top:10,left: 10,right: 10),
  130. alignment: Alignment.center,
  131. decoration: BoxDecoration(
  132. // color: Colors.indigo,
  133. borderRadius: BorderRadius.only(topLeft: Radius.circular(5),topRight: Radius.circular(5))
  134. ),
  135. child: Column(
  136. mainAxisSize: MainAxisSize.min,
  137. crossAxisAlignment: CrossAxisAlignment.center,
  138. children: <Widget>[
  139. Icon(Icons.warning,size: 70,color: Colors.indigo,),
  140. ],
  141. ),
  142. ),
  143. ),
  144. Flexible(
  145. flex: 1,
  146. child: Container(
  147. padding: EdgeInsets.only(left: 20,right: 20),
  148. alignment: Alignment.centerLeft,
  149. child: Text('Data belum disimpan. Lanjutkan ?',style: TextStyle(fontWeight: FontWeight.w500,fontSize: 14,color: Colors.black.withOpacity(0.6)),)
  150. ),
  151. ),
  152. Flexible(
  153. flex: 1,
  154. child: Container(
  155. padding: EdgeInsets.only(bottom:10),
  156. child: Row(
  157. mainAxisAlignment: MainAxisAlignment.end,
  158. children: <Widget>[
  159. TextButton(
  160. child: Text('Proceed'),
  161. // color: Colors.red,
  162. onPressed: (){
  163. Navigator.pop(context);
  164. Navigator.pop(context);
  165. },
  166. ),
  167. TextButton(
  168. child: Text('Cancel'),
  169. // color: Colors.grey,
  170. onPressed: (){
  171. Navigator.pop(context);
  172. },
  173. ),
  174. ],
  175. ),
  176. ),
  177. )
  178. ],
  179. ),
  180. ),
  181. ),
  182. ),
  183. );
  184. }
  185. else Navigator.pop(context);
  186. }
  187. else{
  188. bool not_empty = (stateController.text!='-'&&mesinController.text!='-'&&tahunController.text!='-'&&kodeController.text!='-'&&colorController.text!='-'&&rangkaController.text!='-'&&tipeController.text!='-');
  189. if(blobList.where((element) => element.blob_file!=null).length!=0){
  190. await showDialog(context: context,builder: (context)=>
  191. Material(
  192. color: Colors.white.withOpacity(0.9),
  193. child: Center(
  194. child: Container(
  195. decoration: BoxDecoration(
  196. color: Colors.white,
  197. boxShadow: [
  198. BoxShadow(
  199. color: Colors.grey.withOpacity(0.5),
  200. spreadRadius: 2,
  201. blurRadius: 2,
  202. offset: Offset(0, 0), // changes position of shadow
  203. ),
  204. ],
  205. borderRadius: BorderRadius.circular(5)
  206. ),
  207. height:220,
  208. // height: MediaQuery.of(context).size.height/4.8,
  209. width: MediaQuery.of(context).size.width*0.75,
  210. child: Column(
  211. children: <Widget>[
  212. Flexible(
  213. flex:3,
  214. child: Container(
  215. padding: EdgeInsets.only(top:10,left: 10,right: 10),
  216. alignment: Alignment.center,
  217. decoration: BoxDecoration(
  218. // color: Colors.indigo,
  219. borderRadius: BorderRadius.only(topLeft: Radius.circular(5),topRight: Radius.circular(5))
  220. ),
  221. child: Column(
  222. mainAxisSize: MainAxisSize.min,
  223. crossAxisAlignment: CrossAxisAlignment.center,
  224. children: <Widget>[
  225. Icon(Icons.warning,size: 70,color: Colors.indigo,),
  226. ],
  227. ),
  228. ),
  229. ),
  230. Flexible(
  231. flex: 1,
  232. child: Container(
  233. padding: EdgeInsets.only(left: 20,right: 20),
  234. alignment: Alignment.centerLeft,
  235. child: Text('Data belum disimpan. Lanjutkan ?',style: TextStyle(fontWeight: FontWeight.w500,fontSize: 14,color: Colors.black.withOpacity(0.6)),)
  236. ),
  237. ),
  238. Flexible(
  239. flex: 1,
  240. child: Container(
  241. padding: EdgeInsets.only(bottom:10),
  242. child: Row(
  243. mainAxisAlignment: MainAxisAlignment.end,
  244. children: <Widget>[
  245. TextButton(
  246. child: Text('Back',style: TextStyle(color: Colors.indigo),),
  247. onPressed: (){
  248. Navigator.pop(context);
  249. Navigator.pop(context);
  250. },
  251. ),
  252. TextButton(
  253. child: Text('Cancel',style: TextStyle(color: Colors.indigo)),
  254. onPressed: (){
  255. Navigator.pop(context);
  256. },
  257. ),
  258. ],
  259. ),
  260. ),
  261. )
  262. ],
  263. ),
  264. ),
  265. ),
  266. ),
  267. );
  268. }
  269. else Navigator.pop(context);
  270. }
  271. return false;
  272. },
  273. child: Container(
  274. padding: EdgeInsets.only(left:10,right: 10,bottom: 10),
  275. child: Column(
  276. children: <Widget>[
  277. // SizedBox(height: MediaQuery.of(context).size.height/25,),
  278. Expanded(
  279. child: Row(
  280. children: <Widget>[
  281. Flexible(
  282. flex: 4,
  283. child: Container(
  284. height: MediaQuery.of(context).size.height,
  285. child:
  286. ListView.builder(
  287. // itemCount: ((images.length+1)>jenisLength)?jenisLength:images.length+1,
  288. itemCount: blobList.length,
  289. itemBuilder: (context, index){
  290. // Uint8List image = ((images.length==0)||(images.length<(index+1)))?null:images[index];
  291. Uint8List image = blobList[index].blob_file;
  292. return Padding(
  293. padding: const EdgeInsets.only(top: 10,right: 10),
  294. child: Material(
  295. child: InkWell(
  296. onTap: ()async{
  297. if(image==null){
  298. // var selected = await showDialog(
  299. // context: context,
  300. // builder: (context){
  301. // var selected = dropMenu[0].value;
  302. // return WillPopScope(
  303. // onWillPop: ()async{
  304. // Navigator.pop(context,false);
  305. // return false;
  306. // },
  307. // child: AlertDialog(
  308. // content: StatefulBuilder(
  309. // builder: (context,setState){
  310. // return DropdownButtonFormField(
  311. // decoration: InputDecoration.collapsed(),
  312. // value: selected,
  313. // onChanged: (value){
  314. // setState(() {
  315. // selected = value;
  316. // });
  317. // },
  318. // items: dropMenu.map((item) {
  319. // return new DropdownMenuItem<String>(
  320. // value: item.value,
  321. // child: Row(
  322. // children: <Widget>[
  323. // Text(item.value),
  324. //// (item.optional=='TRUE')?Container():Text(' *',style: TextStyle(color: Colors.red),)
  325. // ],
  326. // ),
  327. // );
  328. // }).toList(),
  329. // );
  330. // },
  331. // ),
  332. // actions: <Widget>[
  333. // TextButton(
  334. // child: Text('Done'),
  335. // onPressed: ()async{
  336. // jenisImages.add(selected);
  337. //
  338. // Navigator.pop(context,true);
  339. // },
  340. // ),
  341. // TextButton(
  342. // child: Text('Cancel'),
  343. // onPressed: (){
  344. // Navigator.pop(context,false);
  345. // },
  346. // ),
  347. // ],
  348. // ),
  349. // );
  350. // }
  351. // );
  352. // if (selected){
  353. XFile temp = await ImagePicker().pickImage(source: ImageSource.camera,maxWidth: 800,imageQuality: 80);
  354. if(temp!=null){
  355. isChanged = true;
  356. blobList[index].blob_file = await temp.readAsBytes();
  357. // if(widget.idInsert!=null) {
  358. // blobIds.add(null);
  359. // isChanged = true;
  360. // }
  361. setState(() {
  362. });
  363. }
  364. // else {
  365. // jenisImages.removeLast();
  366. // }
  367. // await loadDropMenu();
  368. // }
  369. }
  370. else {
  371. // List<jenisDrop> dropNewMenu = new List<jenisDrop>.from(dropMenu);
  372. // dropNewMenu.add(new jenisDrop(value: jenisImages[index]));
  373. var result = await Navigator.push(context, MaterialPageRoute(builder: (context) => PhotoViewer(image,id: widget.unit.id.toString()+'.$index',jenis: blobList[index].jenis,)));
  374. if(result!=null){
  375. blobList[index] = result['byte'];
  376. isChanged = true;
  377. // images[index] = result['byte'];
  378. // jenisImages[index] = result['jenis'];
  379. // await loadDropMenu();
  380. // if(widget.idInsert!=null) {
  381. // isChanged = true;
  382. // }
  383. setState(() {
  384. });
  385. }
  386. }
  387. },
  388. splashColor: Colors.grey,
  389. child: Column(
  390. children: <Widget>[
  391. Container(padding: EdgeInsets.all(5),child: Text(blobList[index].jenis)),
  392. Stack(
  393. children: <Widget>[
  394. Container(
  395. decoration: BoxDecoration(
  396. color: Colors.grey.withOpacity(0.7),
  397. image: (image!=null)?DecorationImage(
  398. image: MemoryImage(image),
  399. fit: BoxFit.cover
  400. ):null,
  401. ),
  402. height: MediaQuery.of(context).size.width*0.35,
  403. width: MediaQuery.of(context).size.width*0.35,
  404. child: (image==null)?Icon(Icons.add):null,
  405. ),
  406. (image!=null)?Container(
  407. height: MediaQuery.of(context).size.width*0.35,
  408. width: MediaQuery.of(context).size.width*0.35,
  409. alignment: Alignment.topRight,
  410. child: InkWell(
  411. onTap: ()async{
  412. // if(widget.idInsert!=null){
  413. // isChanged = true;
  414. // deleteBlobIds.add(blobIds[index]);
  415. // blobIds.removeAt(index);
  416. // }
  417. setState(() {
  418. blobList[index].blob_file = null;
  419. // images.removeAt(index);
  420. // jenisImages.removeAt(index);
  421. });
  422. // await loadDropMenu();
  423. },
  424. child: Container(
  425. padding: EdgeInsets.all(5),
  426. child: Icon(Icons.cancel,color: Colors.red,)),
  427. ),
  428. ):Container(),
  429. ],
  430. ),
  431. ],
  432. ),
  433. ),
  434. ),
  435. );
  436. })
  437. ),
  438. ),
  439. Flexible(
  440. flex: 6,
  441. child: Container(
  442. alignment: Alignment.topLeft,
  443. padding: EdgeInsets.only(top: 10),
  444. child: SingleChildScrollView(
  445. scrollDirection: Axis.vertical,
  446. child: Column(
  447. mainAxisAlignment: MainAxisAlignment.start,
  448. children: <Widget>[
  449. // Divider(),
  450. // Row(
  451. // mainAxisAlignment: MainAxisAlignment.spaceBetween,
  452. // children: <Widget>[
  453. // Expanded(
  454. // child:
  455. // textfield??Container(),
  456. // ),
  457. // ],
  458. // ),
  459. Padding(
  460. padding: const EdgeInsets.all(5.0),
  461. child: Text('Units Details',style: TextStyle(fontSize: 18,fontWeight: FontWeight.bold),),
  462. ),
  463. Divider(),
  464. Row(
  465. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  466. children: <Widget>[
  467. Text('Tipe : '),
  468. Expanded(
  469. child:
  470. TextFormField(
  471. enabled: false,
  472. style: TextStyle(color: Colors.grey),
  473. controller: tipeController,
  474. decoration: InputDecoration.collapsed(hintText: null),
  475. ),
  476. ),
  477. ],
  478. ),
  479. Divider(),
  480. Row(
  481. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  482. children: <Widget>[
  483. Text('Mesin : '),
  484. Expanded(
  485. child: TextFormField(
  486. enabled: false,
  487. style: TextStyle(color: Colors.grey),
  488. controller: mesinController,
  489. decoration: InputDecoration.collapsed(hintText: null),
  490. ),
  491. ),
  492. ],
  493. ),
  494. Divider(),
  495. Row(
  496. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  497. children: <Widget>[
  498. Text('Rangka : '),
  499. Expanded(
  500. child: TextFormField(
  501. enabled: false,
  502. style: TextStyle(color: Colors.grey),
  503. controller: rangkaController,
  504. decoration: InputDecoration.collapsed(hintText: null),
  505. ),
  506. ),
  507. ],
  508. ),
  509. Divider(),
  510. Row(
  511. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  512. children: <Widget>[
  513. Text('Kode : '),
  514. Expanded(
  515. child: TextFormField(
  516. enabled: false,
  517. style: TextStyle(color: Colors.grey),
  518. controller: kodeController,
  519. decoration: InputDecoration.collapsed(hintText: null),
  520. ),
  521. ),
  522. ],
  523. ),
  524. Divider(),
  525. Row(
  526. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  527. children: <Widget>[
  528. Text('Tahun : '),
  529. Expanded(
  530. child: TextFormField(
  531. enabled: false,
  532. style: TextStyle(color: Colors.grey),
  533. controller: tahunController,
  534. decoration: InputDecoration.collapsed(hintText: null),
  535. ),
  536. ),
  537. ],
  538. ),
  539. Divider(),
  540. Row(
  541. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  542. children: <Widget>[
  543. Text('Warna : '),
  544. Expanded(
  545. child: TextFormField(
  546. enabled: false,
  547. style: TextStyle(color: Colors.grey),
  548. controller: colorController,
  549. decoration: InputDecoration.collapsed(hintText: null),
  550. ),
  551. ),
  552. ],
  553. ),
  554. Divider(),
  555. Row(
  556. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  557. children: <Widget>[
  558. Text('State : '),
  559. Expanded(
  560. child: TextFormField(
  561. enabled: false,
  562. style: TextStyle(color: Colors.grey),
  563. controller: stateController,
  564. decoration: InputDecoration.collapsed(hintText: null),
  565. ),
  566. ),
  567. ],
  568. ),
  569. Divider(),
  570. Row(
  571. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  572. children: <Widget>[
  573. Text('Channel : '),
  574. Expanded(
  575. child: TextFormField(
  576. enabled: false,
  577. style: TextStyle(color: Colors.grey),
  578. controller: channelController,
  579. decoration: InputDecoration.collapsed(hintText: null),
  580. ),
  581. ),
  582. ],
  583. ),
  584. Divider(),
  585. Row(
  586. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  587. children: <Widget>[
  588. TextButton(
  589. style: TextButton.styleFrom(
  590. backgroundColor: Colors.green,
  591. ),
  592. child: Text((widget.unit.flag=='FALSE')?'Add':'Save'),
  593. onPressed: ()async{
  594. bool succeed = false;
  595. String errMsg = '';
  596. util.showLoading(context);
  597. await Future.sync(()async{
  598. if(currentPosisiton!=null) {
  599. if(blobList.where((element) => element.blob_file!=null).length==blobList.length){
  600. for(int i = 0 ; i<blobList.length;i++){
  601. blobList[i].lat = currentPosisiton.latitude.toString();
  602. blobList[i].long = currentPosisiton.longitude.toString();
  603. var result = await DBHelper.database.updateBlob(blobList[i]);
  604. succeed = (result!=null);
  605. if(!succeed) {
  606. i = blobList.length;
  607. errMsg = "Gagal menyimpan foto unit!";
  608. }
  609. }
  610. if(succeed){
  611. _currentUnit.timestamp = DateFormat('dd-MM-yyyy HH:mm:ss').format(DateTime.now());
  612. _currentUnit.flag = 'TRUE';
  613. var result = await DBHelper.database.updateUnit(_currentUnit);
  614. succeed = (result!=null);
  615. if(!succeed) {
  616. errMsg = "Gagal menyimpan data unit!";
  617. }
  618. }
  619. }
  620. else{
  621. succeed = false;
  622. errMsg ='Tolong lengkapi data foto';
  623. }
  624. }
  625. else{
  626. succeed = false;
  627. errMsg ='Gagal mengamil koordinat lokasi. Tolong cek gps.';
  628. }
  629. });
  630. Navigator.pop(context);
  631. if(!ModalRoute.of(context).isCurrent)Navigator.pop(context);
  632. if(succeed) Navigator.pop(context,succeed);
  633. util.showFlushbar(context, (succeed)?'Data terupdate':errMsg,color: (succeed)?Colors.grey:Colors.red);
  634. },
  635. ),
  636. TextButton(
  637. child: Text('Cancel'),
  638. onPressed: ()async {
  639. if(widget.unit.flag=='TRUE'){
  640. if(isChanged){
  641. await showDialog(context: context,builder: (context)=>
  642. Material(
  643. color: Colors.white.withOpacity(0.9),
  644. child: Center(
  645. child: Container(
  646. decoration: BoxDecoration(
  647. color: Colors.white,
  648. boxShadow: [
  649. BoxShadow(
  650. color: Colors.grey.withOpacity(0.5),
  651. spreadRadius: 2,
  652. blurRadius: 2,
  653. offset: Offset(0, 0), // changes position of shadow
  654. ),
  655. ],
  656. borderRadius: BorderRadius.circular(5)
  657. ),
  658. height:220,
  659. // height: MediaQuery.of(context).size.height/4.8,
  660. width: MediaQuery.of(context).size.width*0.75,
  661. child: Column(
  662. children: <Widget>[
  663. Flexible(
  664. flex:3,
  665. child: Container(
  666. padding: EdgeInsets.only(top:10,left: 10,right: 10),
  667. alignment: Alignment.center,
  668. decoration: BoxDecoration(
  669. // color: Colors.indigo,
  670. borderRadius: BorderRadius.only(topLeft: Radius.circular(5),topRight: Radius.circular(5))
  671. ),
  672. child: Column(
  673. mainAxisSize: MainAxisSize.min,
  674. crossAxisAlignment: CrossAxisAlignment.center,
  675. children: <Widget>[
  676. Icon(Icons.warning,size: 70,color: Colors.indigo,),
  677. ],
  678. ),
  679. ),
  680. ),
  681. Flexible(
  682. flex: 1,
  683. child: Container(
  684. padding: EdgeInsets.only(left: 20,right: 20),
  685. alignment: Alignment.centerLeft,
  686. child: Text('Data belum disimpan. Lanjutkan ?',style: TextStyle(fontWeight: FontWeight.w500,fontSize: 14,color: Colors.black.withOpacity(0.6)),)
  687. ),
  688. ),
  689. Flexible(
  690. flex: 1,
  691. child: Container(
  692. padding: EdgeInsets.only(bottom:10),
  693. child: Row(
  694. mainAxisAlignment: MainAxisAlignment.end,
  695. children: <Widget>[
  696. TextButton(
  697. child: Text('Proceed'),
  698. onPressed: (){
  699. Navigator.pop(context);
  700. Navigator.popUntil(context,ModalRoute.withName('/stocking'));
  701. },
  702. ),
  703. TextButton(
  704. child: Text('Cancel'),
  705. // color: Colors.grey,
  706. onPressed: (){
  707. Navigator.pop(context);
  708. },
  709. ),
  710. ],
  711. ),
  712. ),
  713. )
  714. ],
  715. ),
  716. ),
  717. ),
  718. ),
  719. );
  720. }
  721. else Navigator.pop(context);
  722. }
  723. else {
  724. // bool not_empty = (stateController.text!='-'&&mesinController.text!='-'&&tahunController.text!='-'&&kodeController.text!='-'&&colorController.text!='-'&&rangkaController.text!='-'&&tipeController.text!='-');
  725. if(blobList.where((element) => element.blob_file!=null).length!=0){
  726. await showDialog(context: context,builder: (context)=>
  727. Material(
  728. color: Colors.white.withOpacity(0.9),
  729. child: Center(
  730. child: Container(
  731. decoration: BoxDecoration(
  732. color: Colors.white,
  733. boxShadow: [
  734. BoxShadow(
  735. color: Colors.grey.withOpacity(0.5),
  736. spreadRadius: 2,
  737. blurRadius: 2,
  738. offset: Offset(0, 0), // changes position of shadow
  739. ),
  740. ],
  741. borderRadius: BorderRadius.circular(5)
  742. ),
  743. height:220,
  744. // height: MediaQuery.of(context).size.height/4.8,
  745. width: MediaQuery.of(context).size.width*0.75,
  746. child: Column(
  747. children: <Widget>[
  748. Flexible(
  749. flex:3,
  750. child: Container(
  751. padding: EdgeInsets.only(top:10,left: 10,right: 10),
  752. alignment: Alignment.center,
  753. decoration: BoxDecoration(
  754. // color: Colors.indigo,
  755. borderRadius: BorderRadius.only(topLeft: Radius.circular(5),topRight: Radius.circular(5))
  756. ),
  757. child: Column(
  758. mainAxisSize: MainAxisSize.min,
  759. crossAxisAlignment: CrossAxisAlignment.center,
  760. children: <Widget>[
  761. Icon(Icons.warning,size: 70,color: Colors.indigo,),
  762. ],
  763. ),
  764. ),
  765. ),
  766. Flexible(
  767. flex: 1,
  768. child: Container(
  769. padding: EdgeInsets.only(left: 20,right: 20),
  770. alignment: Alignment.centerLeft,
  771. child: Text('Data belum disimpan. Lanjutkan ?',style: TextStyle(fontWeight: FontWeight.w500,fontSize: 14,color: Colors.black.withOpacity(0.6)),)
  772. ),
  773. ),
  774. Flexible(
  775. flex: 1,
  776. child: Container(
  777. padding: EdgeInsets.only(bottom:10),
  778. child: Row(
  779. mainAxisAlignment: MainAxisAlignment.end,
  780. children: <Widget>[
  781. TextButton(
  782. child: Text('Back'),
  783. onPressed: (){
  784. Navigator.pop(context);
  785. Navigator.popUntil(context,ModalRoute.withName('/stocking'));
  786. },
  787. ),
  788. TextButton(
  789. child: Text('Cancel'),
  790. onPressed: (){
  791. Navigator.pop(context);
  792. },
  793. ),
  794. ],
  795. ),
  796. ),
  797. )
  798. ],
  799. ),
  800. ),
  801. ),
  802. ),
  803. );
  804. }
  805. else Navigator.pop(context);
  806. }
  807. },
  808. style: TextButton.styleFrom(
  809. backgroundColor: Colors.redAccent,
  810. ),
  811. )
  812. ],
  813. )
  814. ],
  815. ),
  816. ),
  817. ),
  818. )
  819. ],
  820. ),
  821. ),
  822. ],
  823. ),
  824. ),
  825. ),
  826. );
  827. }
  828. }