Flutter app for Asset Management
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.
 
 
 
 

1017 lignes
68 KiB

  1. import 'package:flutter/cupertino.dart';
  2. import 'package:flutter/material.dart';
  3. import 'main.dart';
  4. import 'util/Models.dart';
  5. import 'util/dbHandler.dart';
  6. import 'asset_details.dart';
  7. class Stocking extends StatefulWidget {
  8. Stocking({Key key}) : super(key: key);
  9. @override
  10. _StockingState createState() => _StockingState();
  11. }
  12. class _StockingState extends State<Stocking> with TickerProviderStateMixin {
  13. final searchCon = new TextEditingController();
  14. String search = '';
  15. TabController _tabController;
  16. List<Asset> refAsset = [];
  17. List<Asset> insertAsset = [];
  18. bool isLoading = false;
  19. List<String> lokasi = [];
  20. List<String> ruangan = [];
  21. List<String> kategori = [];
  22. String _currentloc='All';
  23. String _currentruang='All';
  24. String _currentkategori='All';
  25. loadAsset({loading=false})async{
  26. if(loading) {
  27. setState(() {
  28. isLoading = true;
  29. });
  30. }
  31. var result = (search=='')?await DBHelper.database.getAllAsset():await DBHelper.database.filterAllAsset(search.toUpperCase());
  32. if(result!=null){
  33. if(_currentloc!='All') result.removeWhere((element) => (element.lantai!=_currentloc));
  34. if(_currentruang!='All') result.removeWhere((element) => (element.ruangan!=_currentruang));
  35. if(_currentkategori!='All') result.removeWhere((element) => (element.kategori!=_currentkategori));
  36. setState(() {
  37. refAsset = result;
  38. });
  39. // print(result.length);
  40. }
  41. result = (search=='')?await DBHelper.database.getAllInsertAsset():await DBHelper.database.filterAllInsertAsset(search.toUpperCase());
  42. if(result!=null){
  43. print(result.length);
  44. if(_currentloc!='All'){
  45. if(_currentloc!='Appended'){
  46. result.removeWhere((element) => (element.lantai!=_currentloc));
  47. }
  48. else{
  49. result.removeWhere((element) => (element.asset_desc!=''));
  50. }
  51. }
  52. if(_currentruang!='All') result.removeWhere((element) => (element.ruangan!=_currentruang));
  53. setState(() {
  54. insertAsset = result.reversed.toList();
  55. });
  56. if(_currentkategori!='All') result.removeWhere((element) => (element.kategori!=_currentkategori));
  57. setState(() {
  58. insertAsset = result.reversed.toList();
  59. });
  60. }
  61. if(lokasi.length==0){
  62. var results = await DBHelper.database.getAllLocation();
  63. if(results!=null){
  64. lokasi.clear();
  65. lokasi = new List<String>.from(results.map((item)=>item.lantai));
  66. lokasi.add('Appended');
  67. lokasi.add('All');
  68. }
  69. }
  70. if(kategori.length==0){
  71. var results = await DBHelper.database.getAllKategori();
  72. if(results!=null){
  73. kategori.clear();
  74. kategori = new List<String>.from(results.map((item)=>item.kategori));
  75. kategori.add('All');
  76. }
  77. }
  78. ruangan.clear();
  79. var results = (_currentloc=='All')?await DBHelper.database.getAllRuangan():await DBHelper.database.getLantaiRuangan(_currentloc);
  80. setState(() {
  81. if(results!=null){
  82. ruangan = new List<String>.from(results.map((item)=>item.ruangan));
  83. ruangan.add('All');
  84. }
  85. });
  86. if(loading) {
  87. setState(() {
  88. isLoading = false;
  89. });
  90. }
  91. }
  92. @override
  93. void initState() {
  94. // TODO: implement initState
  95. super.initState();
  96. _tabController = new TabController(length: 2, vsync: this);
  97. loadAsset(loading: true);
  98. }
  99. @override
  100. Widget build(BuildContext context) {
  101. return Scaffold(
  102. resizeToAvoidBottomInset: false,
  103. body: Stack(
  104. children: <Widget>[
  105. Container(
  106. padding: EdgeInsets.only(top: 10),
  107. color: Colors.grey.withOpacity(0.3),
  108. child: Column(
  109. children: <Widget>[
  110. Expanded(
  111. flex: 2,
  112. child: Container(
  113. alignment: Alignment.bottomCenter,
  114. padding: const EdgeInsets.all(8.0),
  115. child: Container(
  116. decoration: BoxDecoration(
  117. color: Colors.white,
  118. borderRadius: BorderRadius.circular(20),
  119. ),
  120. // padding: EdgeInsets.all(8),
  121. child: TextField(
  122. controller: searchCon,
  123. onSubmitted: (value)async{
  124. setState(() {
  125. search = value;
  126. // searchCon.text = value;
  127. });
  128. await loadAsset(loading: true);
  129. },
  130. decoration: InputDecoration(
  131. border: InputBorder.none,
  132. focusedBorder: InputBorder.none,
  133. enabledBorder: InputBorder.none,
  134. errorBorder: InputBorder.none,
  135. disabledBorder: InputBorder.none,
  136. suffixIcon: InkWell(
  137. onTap: ()async{
  138. var result = await util.scan();
  139. if(result['STATUS']==1){
  140. searchCon.text = result['DATA'];
  141. search = searchCon.text;
  142. await loadAsset();
  143. setState(() {
  144. });
  145. }
  146. },
  147. child: Icon(Icons.center_focus_strong,color: Colors.blueGrey,)),
  148. contentPadding: EdgeInsets.only(left: 10,right: 10,top: 15,bottom: 15),
  149. hintText: "Search Tag Number"
  150. ),
  151. ),
  152. ),
  153. ),
  154. ),
  155. Expanded(
  156. flex: 1,
  157. child: Container(
  158. alignment: Alignment.bottomCenter,
  159. padding: const EdgeInsets.all(8.0),
  160. child: Container(
  161. // padding: EdgeInsets.all(8),
  162. child: Row(
  163. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  164. children: [
  165. Flexible(
  166. flex:1,
  167. child: Text("Lantai:",style: TextStyle(fontSize: 14),),
  168. ),
  169. Flexible(
  170. flex: 3,
  171. child: DropdownButtonFormField(
  172. decoration: InputDecoration.collapsed(hintText: null),
  173. value: _currentloc,
  174. items: new List<DropdownMenuItem<String>>.from(lokasi.reversed.map((value){
  175. return DropdownMenuItem(
  176. child: Text(value==''||value==null?"-":(value.length>15)? value.substring(0,15):value,style: TextStyle(fontSize: 12),),
  177. value: value,
  178. );
  179. })),
  180. onChanged: (value){
  181. if(_currentloc!= value){
  182. setState(() {
  183. _currentruang = 'All';
  184. _currentloc=value;
  185. });
  186. loadAsset(loading: true);
  187. }
  188. },
  189. ),
  190. ),
  191. Flexible(
  192. flex:1,
  193. child: Text("Ruang:",style: TextStyle(fontSize: 14)),
  194. ),
  195. Flexible(
  196. flex: 3,
  197. child: DropdownButtonFormField(
  198. decoration: InputDecoration.collapsed(hintText: null),
  199. value: _currentruang,
  200. items: new List<DropdownMenuItem<String>>.from(ruangan.reversed.map((value){
  201. String _string = value;
  202. if(_string.length>15) _string = _string.substring(0,15);
  203. return DropdownMenuItem(
  204. child: Text(_string==''?"-":_string??'-',style: TextStyle(fontSize: 12),),
  205. value: value,
  206. );
  207. })),
  208. onChanged: (value){
  209. setState(() {
  210. _currentruang=value;
  211. });
  212. loadAsset(loading: true);
  213. },
  214. ),
  215. ),
  216. ],
  217. ),
  218. ),
  219. ),
  220. ),
  221. Expanded(
  222. flex: 1,
  223. child: Container(
  224. alignment: Alignment.bottomCenter,
  225. padding: const EdgeInsets.all(8.0),
  226. child: Container(
  227. // padding: EdgeInsets.all(8),
  228. child: Row(
  229. children: [
  230. Container(
  231. child: Text("Kategori : ",style: TextStyle(fontSize: 14),),
  232. ),
  233. Expanded(
  234. // width: 100,
  235. child: DropdownButtonFormField(
  236. decoration: InputDecoration.collapsed(hintText: null),
  237. value: _currentkategori,
  238. items: new List<DropdownMenuItem<String>>.from(kategori.reversed.map((value){
  239. return DropdownMenuItem(
  240. child: Text(value==''||value==null?"-":(value.length>15)? value.substring(0,15):value,style: TextStyle(fontSize: 12),),
  241. value: value,
  242. );
  243. })),
  244. onChanged: (value){
  245. if(_currentkategori!= value){
  246. setState(() {
  247. _currentkategori=value;
  248. });
  249. loadAsset(loading: true);
  250. }
  251. },
  252. ),
  253. ),
  254. ],
  255. ),
  256. ),
  257. ),
  258. ),
  259. Expanded(
  260. flex:16,
  261. child: Column(
  262. children: <Widget>[
  263. Flexible(
  264. flex: 1,
  265. child: Stack(
  266. children: <Widget>[
  267. Positioned.fill(child: Row(
  268. children: <Widget>[
  269. Expanded(
  270. flex:1,
  271. child: Container(
  272. alignment: Alignment.center,
  273. child:(insertAsset.length==0)?null:Row(
  274. mainAxisSize: MainAxisSize.min,
  275. children: <Widget>[
  276. Padding(
  277. padding: const EdgeInsets.all(10.0),
  278. child: Text('Completed ',style: TextStyle(fontSize: 18,color: Colors.transparent),),
  279. ),
  280. Container(padding: EdgeInsets.all(8),
  281. decoration: BoxDecoration(
  282. shape: BoxShape.circle,
  283. color: Colors.green,
  284. ),
  285. child: Text('${insertAsset.length}',style: TextStyle(color: Colors.white,fontSize: 14/(insertAsset.length.toString().length/10+1)),)),
  286. ],
  287. )
  288. ),
  289. ),
  290. Expanded(
  291. flex:1,
  292. child: Container(
  293. alignment: Alignment.center,
  294. child:(refAsset.length==0)?null:Row(
  295. mainAxisSize: MainAxisSize.min,
  296. children: <Widget>[
  297. Padding(
  298. padding: const EdgeInsets.all(10.0),
  299. child: Text('InProgress ',style: TextStyle(fontSize: 18,color: Colors.transparent),),
  300. ),
  301. Container(padding: EdgeInsets.all(8),
  302. decoration: BoxDecoration(
  303. shape: BoxShape.circle,
  304. color: Colors.red,
  305. ),
  306. child: Text('${refAsset.length-insertAsset.where((element) => (element.asset_desc!='')).length}',style: TextStyle(color: Colors.white,fontSize: 14/((refAsset.length-insertAsset.length).toString().length/10+1)),)),
  307. ],
  308. )
  309. ),
  310. ),
  311. ],
  312. ),),
  313. TabBar(
  314. labelColor: Colors.blueGrey,
  315. labelStyle: TextStyle(fontSize: 16,fontWeight: FontWeight.bold),
  316. unselectedLabelStyle: TextStyle(fontSize: 15),
  317. controller: _tabController,
  318. tabs: <Widget>[
  319. Tab(
  320. text: 'Completed',
  321. ),
  322. Tab(
  323. text: 'inProgress',
  324. ),
  325. ],
  326. ),
  327. ],
  328. ),
  329. ),
  330. Expanded(
  331. flex: 12,
  332. child: TabBarView(
  333. controller: _tabController,
  334. children: <Widget>[
  335. (insertAsset.length==0)?Center(child: Text('No Asset Data',style: TextStyle(color: Colors.grey,fontSize: 16,fontWeight: FontWeight.bold),),):
  336. Scrollbar(
  337. isAlwaysShown: false,
  338. child: ListView.builder(
  339. padding: EdgeInsets.all(0),
  340. itemCount: insertAsset.length,
  341. itemBuilder: (context,index){
  342. return InkWell(
  343. onTap: ()async{
  344. await Navigator.push(context, MaterialPageRoute(builder: (context) => new AssetDetails(no:insertAsset[index].no,lokasi: lokasi,)));
  345. // await Navigator.pushNamed(context, "/details");
  346. await loadAsset();
  347. },
  348. child: Padding(
  349. padding: const EdgeInsets.only(bottom: 8,left: 8,right: 8),
  350. child: Container(
  351. decoration: BoxDecoration(
  352. color: Colors.white,
  353. borderRadius: BorderRadius.circular(5)
  354. ),
  355. height: 100,
  356. child: Row(
  357. children: <Widget>[
  358. Container(height: 100,width: 100,decoration:BoxDecoration(
  359. image:insertAsset[index].blob==null?null: DecorationImage(
  360. image: MemoryImage(insertAsset[index].blob,),
  361. fit: BoxFit.cover
  362. ),
  363. color:Colors.grey,
  364. borderRadius: BorderRadius.only(topLeft: Radius.circular(5),bottomLeft: Radius.circular(5))
  365. ),child:insertAsset[index].blob==null?Icon(Icons.image):null,),
  366. Expanded(
  367. flex: 7,
  368. child: Container(padding: EdgeInsets.all(5),
  369. height: 180,
  370. child: Column(
  371. mainAxisAlignment: MainAxisAlignment.spaceAround,
  372. children: <Widget>[
  373. Row(
  374. children: <Widget>[
  375. Expanded(flex:3,child: Text("Tag Number",style: TextStyle(fontSize: 14,),)),
  376. Expanded(flex:1,child: Text(":",style: TextStyle(fontSize: 16,))),
  377. Expanded(flex: 6,child: Text(insertAsset[index].tag_number,style: TextStyle(color: (insertAsset[index].asset_desc!='')?Colors.black:Colors.red,fontSize: 16,fontWeight: FontWeight.bold))),
  378. Expanded(flex: 1,child: InkWell(onTap: ()async{
  379. await showDialog(context: context,
  380. barrierDismissible: true,
  381. builder: (context)=>AlertDialog(
  382. title: Text('Delete Asset?'),
  383. content: Text("Delete this asset (${insertAsset[index].tag_number})?"),
  384. actions: [
  385. TextButton(
  386. child: Text('Delete'),
  387. onPressed: ()async{
  388. var res = await DBHelper.database.deleteInsertAsset(insertAsset[index].no);
  389. if(res!=null){
  390. setState(() {
  391. insertAsset.removeAt(index);
  392. });
  393. util.showToast('SUCCESS', 'Deleted');
  394. }
  395. else{
  396. util.showToast('ERROR', 'Delete failed');
  397. }
  398. Navigator.pop(context);
  399. },
  400. )
  401. ],
  402. ));
  403. },child: Container(alignment: Alignment.centerRight,child: Icon(Icons.cancel,color: Colors.red,),)),),
  404. ],
  405. ),
  406. Row(
  407. children: <Widget>[
  408. Expanded(flex:3,child: Container(height: 16,child: Text("Asset Desc",style: TextStyle(fontSize: 14,),))),
  409. Expanded(flex:1,child: Container(height: 16,child: Text(":",style: TextStyle(fontSize: 16,)))),
  410. Expanded(flex: 7,child: SingleChildScrollView(scrollDirection: Axis.horizontal,child: Container(height: 16,child: Text(insertAsset[index].asset_desc,style: TextStyle(fontSize: 16,fontWeight: FontWeight.bold)))))
  411. ],
  412. ),
  413. Row(
  414. children: <Widget>[
  415. Expanded(flex:3,child: Container(height: 16,child: Text("Lokasi",style: TextStyle(fontSize: 14,),))),
  416. Expanded(flex:1,child: Container(height: 16,child: Text(":",style: TextStyle(fontSize: 16,)))),
  417. Expanded(flex: 7,child: SingleChildScrollView(scrollDirection: Axis.horizontal,child: Container(height: 16,child: Text(insertAsset[index].lantai,style: TextStyle(fontSize: 16,fontWeight: FontWeight.bold)))))
  418. ],
  419. ),
  420. Row(
  421. children: <Widget>[
  422. Expanded(flex:3,child: Container(height: 16,child: Text("Ruang",style: TextStyle(fontSize: 14,),))),
  423. Expanded(flex:1,child: Container(height: 16,child: Text(":",style: TextStyle(fontSize: 16,)))),
  424. Expanded(flex: 7,child: SingleChildScrollView(scrollDirection: Axis.horizontal,child: Container(height: 16,child: Text(insertAsset[index].ruangan,style: TextStyle(fontSize: 16,fontWeight: FontWeight.bold)))))
  425. ],
  426. ),
  427. Row(
  428. children: <Widget>[
  429. Expanded(flex:3,child: Container(height: 16,child: Text("Keterangan",style: TextStyle(fontSize: 14,),))),
  430. Expanded(flex:1,child: Container(height: 16,child: Text(":",style: TextStyle(fontSize: 16,)))),
  431. Expanded(flex: 7,child: SingleChildScrollView(scrollDirection: Axis.horizontal,child: Container(height: 16,child: Text(insertAsset[index].keterangan,style: TextStyle(fontSize: 16,fontWeight: FontWeight.bold)))))
  432. ],
  433. ),
  434. ],
  435. ),),
  436. )
  437. ],
  438. ),
  439. ),
  440. ),
  441. );
  442. // String keyString = insertAsset[index].tag_number+insertAsset[index].asset_desc+insertAsset[index].ruangan+insertAsset[index].lantai+insertAsset[index].ruangan;
  443. // if(search=='') return InkWell(
  444. // onTap: ()async{
  445. // await Navigator.push(context, MaterialPageRoute(builder: (context) => new AssetDetails(tagNumber: insertAsset[index].tag_number,)));
  446. //// await Navigator.pushNamed(context, "/details");
  447. // await loadAsset();
  448. // },
  449. // child: Padding(
  450. // padding: const EdgeInsets.only(bottom: 8,left: 8,right: 8),
  451. // child: Container(
  452. // decoration: BoxDecoration(
  453. // color: Colors.white,
  454. // borderRadius: BorderRadius.circular(5)
  455. // ),
  456. // height: 100,
  457. // child: Row(
  458. // children: <Widget>[
  459. // Container(height: 100,width: 100,decoration:BoxDecoration(
  460. // image:insertAsset[index].blob==null?null: DecorationImage(
  461. // image: MemoryImage(insertAsset[index].blob,),
  462. // fit: BoxFit.cover
  463. // ),
  464. // color:Colors.grey,
  465. // borderRadius: BorderRadius.only(topLeft: Radius.circular(5),bottomLeft: Radius.circular(5))
  466. // ),child:insertAsset[index].blob==null?Icon(Icons.image):null,),
  467. // Expanded(
  468. // flex: 7,
  469. // child: Container(padding: EdgeInsets.all(5),
  470. // height: 180,
  471. // child: Column(
  472. // mainAxisAlignment: MainAxisAlignment.spaceAround,
  473. // children: <Widget>[
  474. // Row(
  475. // children: <Widget>[
  476. // Expanded(flex:3,child: Text("Tag Number",style: TextStyle(fontSize: 14,),)),
  477. // Expanded(flex:1,child: Text(":",style: TextStyle(fontSize: 16,))),
  478. // Expanded(flex: 7,child: Text(insertAsset[index].tag_number,style: TextStyle(fontSize: 16,fontWeight: FontWeight.bold)))
  479. // ],
  480. // ),
  481. // Row(
  482. // children: <Widget>[
  483. // Expanded(flex:3,child: Container(height: 16,child: Text("Asset Desc",style: TextStyle(fontSize: 14,),))),
  484. // Expanded(flex:1,child: Container(height: 16,child: Text(":",style: TextStyle(fontSize: 16,)))),
  485. // Expanded(flex: 7,child: SingleChildScrollView(scrollDirection: Axis.horizontal,child: Container(height: 16,child: Text(insertAsset[index].asset_desc,style: TextStyle(fontSize: 16,fontWeight: FontWeight.bold)))))
  486. // ],
  487. // ),
  488. // Row(
  489. // children: <Widget>[
  490. // Expanded(flex:3,child: Container(height: 16,child: Text("Ruang",style: TextStyle(fontSize: 14,),))),
  491. // Expanded(flex:1,child: Container(height: 16,child: Text(":",style: TextStyle(fontSize: 16,)))),
  492. // Expanded(flex: 7,child: SingleChildScrollView(scrollDirection: Axis.horizontal,child: Container(height: 16,child: Text(insertAsset[index].ruangan+' '+insertAsset[index].lantai,style: TextStyle(fontSize: 16,fontWeight: FontWeight.bold)))))
  493. // ],
  494. // ),
  495. // Row(
  496. // children: <Widget>[
  497. // Expanded(flex:3,child: Container(height: 16,child: Text("Gedung",style: TextStyle(fontSize: 14,),))),
  498. // Expanded(flex:1,child: Container(height: 16,child: Text(":",style: TextStyle(fontSize: 16,)))),
  499. // Expanded(flex: 7,child: SingleChildScrollView(scrollDirection: Axis.horizontal,child: Container(height: 16,child: Text(insertAsset[index].gedung,style: TextStyle(fontSize: 16,fontWeight: FontWeight.bold)))))
  500. // ],
  501. // ),
  502. // ],
  503. // ),),
  504. // )
  505. // ],
  506. // ),
  507. // ),
  508. // ),
  509. // );
  510. // else{
  511. // if(keyString.toUpperCase().contains(search.toUpperCase())) return InkWell(
  512. // onTap: ()async{
  513. // await Navigator.push(context, MaterialPageRoute(builder: (context) => new AssetDetails(tagNumber: insertAsset[index].tag_number,)));
  514. //// await Navigator.pushNamed(context, "/details");
  515. // await loadAsset();
  516. // },
  517. // child: Padding(
  518. // padding: const EdgeInsets.only(bottom: 8,left: 8,right: 8),
  519. // child: Container(
  520. // decoration: BoxDecoration(
  521. // color: Colors.white,
  522. // borderRadius: BorderRadius.circular(5)
  523. // ),
  524. // height: 100,
  525. // child: Row(
  526. // children: <Widget>[
  527. // Container(height: 100,width: 100,decoration:BoxDecoration(
  528. // image:insertAsset[index].blob==null?null: DecorationImage(
  529. // image: MemoryImage(insertAsset[index].blob,),
  530. // fit: BoxFit.cover
  531. // ),
  532. // color:Colors.grey,
  533. // borderRadius: BorderRadius.only(topLeft: Radius.circular(5),bottomLeft: Radius.circular(5))
  534. // ),child:insertAsset[index].blob==null?Icon(Icons.image):null,),
  535. // Expanded(
  536. // flex: 7,
  537. // child: Container(padding: EdgeInsets.all(5),
  538. // height: 180,
  539. // child: Column(
  540. // mainAxisAlignment: MainAxisAlignment.spaceAround,
  541. // children: <Widget>[
  542. // Row(
  543. // children: <Widget>[
  544. // Expanded(flex:3,child: Text("Tag Number",style: TextStyle(fontSize: 14,),)),
  545. // Expanded(flex:1,child: Text(":",style: TextStyle(fontSize: 16,))),
  546. // Expanded(flex: 7,child: Text(insertAsset[index].tag_number,style: TextStyle(fontSize: 16,fontWeight: FontWeight.bold)))
  547. // ],
  548. // ),
  549. // Row(
  550. // children: <Widget>[
  551. // Expanded(flex:3,child: Container(height: 16,child: Text("Asset Desc",style: TextStyle(fontSize: 14,),))),
  552. // Expanded(flex:1,child: Container(height: 16,child: Text(":",style: TextStyle(fontSize: 16,)))),
  553. // Expanded(flex: 7,child: SingleChildScrollView(scrollDirection: Axis.horizontal,child: Container(height: 16,child: Text(insertAsset[index].asset_desc,style: TextStyle(fontSize: 16,fontWeight: FontWeight.bold)))))
  554. // ],
  555. // ),
  556. // Row(
  557. // children: <Widget>[
  558. // Expanded(flex:3,child: Container(height: 16,child: Text("Ruang",style: TextStyle(fontSize: 14,),))),
  559. // Expanded(flex:1,child: Container(height: 16,child: Text(":",style: TextStyle(fontSize: 16,)))),
  560. // Expanded(flex: 7,child: SingleChildScrollView(scrollDirection: Axis.horizontal,child: Container(height: 16,child: Text(insertAsset[index].ruangan+' '+insertAsset[index].lantai,style: TextStyle(fontSize: 16,fontWeight: FontWeight.bold)))))
  561. // ],
  562. // ),
  563. // Row(
  564. // children: <Widget>[
  565. // Expanded(flex:3,child: Container(height: 16,child: Text("Gedung",style: TextStyle(fontSize: 14,),))),
  566. // Expanded(flex:1,child: Container(height: 16,child: Text(":",style: TextStyle(fontSize: 16,)))),
  567. // Expanded(flex: 7,child: SingleChildScrollView(scrollDirection: Axis.horizontal,child: Container(height: 16,child: Text(insertAsset[index].gedung,style: TextStyle(fontSize: 16,fontWeight: FontWeight.bold)))))
  568. // ],
  569. // ),
  570. // ],
  571. // ),),
  572. // )
  573. // ],
  574. // ),
  575. // ),
  576. // ),
  577. // );
  578. // else return Container();
  579. // }
  580. }
  581. ),
  582. ),
  583. Scrollbar(
  584. isAlwaysShown: false,
  585. child: ListView.builder(
  586. padding: EdgeInsets.all(0),
  587. itemCount: refAsset.length,
  588. itemBuilder: (context,index){
  589. return Opacity(
  590. opacity: (refAsset[index].flag=='TRUE')?0.5:1,
  591. child: Padding(
  592. padding: const EdgeInsets.only(bottom: 8,left: 8,right: 8),
  593. child: Container(
  594. decoration: BoxDecoration(
  595. color: Colors.white,
  596. borderRadius: BorderRadius.circular(5)
  597. ),
  598. height: 100,
  599. child: Row(
  600. children: <Widget>[
  601. // Container(height: 100,width: 100,decoration:BoxDecoration(
  602. // image:refAsset[index].blob==null?null: DecorationImage(
  603. // image: MemoryImage(refAsset[index].blob,),
  604. // fit: BoxFit.cover
  605. // ),
  606. // color:Colors.grey,
  607. // borderRadius: BorderRadius.only(topLeft: Radius.circular(5),bottomLeft: Radius.circular(5))
  608. // ),child:Icon(Icons.image,color: (refAsset[index].blob==null)?Colors.black:Colors.transparent,),),
  609. Expanded(
  610. flex: 7,
  611. child: Container(padding: EdgeInsets.all(5),
  612. height: 180,
  613. child: Column(
  614. mainAxisAlignment: MainAxisAlignment.spaceAround,
  615. children: <Widget>[
  616. Row(
  617. children: <Widget>[
  618. Expanded(flex:3,child: Text("Tag Number",style: TextStyle(fontSize: 14,),)),
  619. Expanded(flex:1,child: Text(":",style: TextStyle(fontSize: 16,))),
  620. Expanded(flex: 7,child: Text(refAsset[index].tag_number,style: TextStyle(fontSize: 16,fontWeight: FontWeight.bold,color: Colors.black)))
  621. ],
  622. ),
  623. Row(
  624. children: <Widget>[
  625. Expanded(flex:3,child: Container(height: 16,child: Text("Asset Desc",style: TextStyle(fontSize: 14,),))),
  626. Expanded(flex:1,child: Container(height: 16,child: Text(":",style: TextStyle(fontSize: 16,)))),
  627. Expanded(flex: 7,child: SingleChildScrollView(scrollDirection: Axis.horizontal,child: Container(height: 16,child: Text(refAsset[index].asset_desc,style: TextStyle(fontSize: 16,color: Colors.black,fontWeight: FontWeight.bold)))))
  628. ],
  629. ),
  630. Row(
  631. children: <Widget>[
  632. Expanded(flex:3,child: Container(height: 16,child: Text("Ruang",style: TextStyle(fontSize: 14,),))),
  633. Expanded(flex:1,child: Container(height: 16,child: Text(":",style: TextStyle(fontSize: 16,)))),
  634. Expanded(flex: 7,child: SingleChildScrollView(scrollDirection: Axis.horizontal,child: Container(height: 16,child: Text(refAsset[index].ruangan,style: TextStyle(fontSize: 16,color: Colors.black,fontWeight: FontWeight.bold)))))
  635. ],
  636. ),
  637. Row(
  638. children: <Widget>[
  639. Expanded(flex:3,child: Container(height: 16,child: Text("Lantai",style: TextStyle(fontSize: 14,),))),
  640. Expanded(flex:1,child: Container(height: 16,child: Text(":",style: TextStyle(fontSize: 16,)))),
  641. Expanded(flex: 7,child: SingleChildScrollView(scrollDirection: Axis.horizontal,child: Container(height: 16,child: Text(refAsset[index].lantai,style: TextStyle(fontSize: 16,color: Colors.black,fontWeight: FontWeight.bold)))))
  642. ],
  643. ),
  644. ],
  645. ),),
  646. )
  647. ],
  648. ),
  649. ),
  650. ),
  651. );
  652. // String keyString = refAsset[index].tag_number+refAsset[index].asset_desc+refAsset[index].ruangan+refAsset[index].lantai+refAsset[index].ruangan;
  653. // if(search=='') return Opacity(
  654. // opacity: (refAsset[index].flag=='TRUE')?0.5:1,
  655. // child: Padding(
  656. // padding: const EdgeInsets.only(bottom: 8,left: 8,right: 8),
  657. // child: Container(
  658. // decoration: BoxDecoration(
  659. // color: Colors.white,
  660. // borderRadius: BorderRadius.circular(5)
  661. // ),
  662. // height: 100,
  663. // child: Row(
  664. // children: <Widget>[
  665. // Container(height: 100,width: 100,decoration:BoxDecoration(
  666. // image:refAsset[index].blob==null?null: DecorationImage(
  667. // image: MemoryImage(refAsset[index].blob,),
  668. // fit: BoxFit.cover
  669. // ),
  670. // color:Colors.grey,
  671. // borderRadius: BorderRadius.only(topLeft: Radius.circular(5),bottomLeft: Radius.circular(5))
  672. // ),child:Icon(Icons.image),),
  673. // Expanded(
  674. // flex: 7,
  675. // child: Container(padding: EdgeInsets.all(5),
  676. // height: 180,
  677. // child: Column(
  678. // mainAxisAlignment: MainAxisAlignment.spaceAround,
  679. // children: <Widget>[
  680. // Row(
  681. // children: <Widget>[
  682. // Expanded(flex:3,child: Text("Tag Number",style: TextStyle(fontSize: 14,),)),
  683. // Expanded(flex:1,child: Text(":",style: TextStyle(fontSize: 16,))),
  684. // Expanded(flex: 7,child: Text(refAsset[index].tag_number,style: TextStyle(fontSize: 16,fontWeight: FontWeight.bold,color: Colors.black)))
  685. // ],
  686. // ),
  687. // Row(
  688. // children: <Widget>[
  689. // Expanded(flex:3,child: Container(height: 16,child: Text("Asset Desc",style: TextStyle(fontSize: 14,),))),
  690. // Expanded(flex:1,child: Container(height: 16,child: Text(":",style: TextStyle(fontSize: 16,)))),
  691. // Expanded(flex: 7,child: SingleChildScrollView(scrollDirection: Axis.horizontal,child: Container(height: 16,child: Text(refAsset[index].asset_desc,style: TextStyle(fontSize: 16,color: Colors.black,fontWeight: FontWeight.bold)))))
  692. // ],
  693. // ),
  694. // Row(
  695. // children: <Widget>[
  696. // Expanded(flex:3,child: Container(height: 16,child: Text("Ruang",style: TextStyle(fontSize: 14,),))),
  697. // Expanded(flex:1,child: Container(height: 16,child: Text(":",style: TextStyle(fontSize: 16,)))),
  698. // Expanded(flex: 7,child: SingleChildScrollView(scrollDirection: Axis.horizontal,child: Container(height: 16,child: Text(refAsset[index].ruangan+' '+refAsset[index].lantai,style: TextStyle(fontSize: 16,color: Colors.black,fontWeight: FontWeight.bold)))))
  699. // ],
  700. // ),
  701. // Row(
  702. // children: <Widget>[
  703. // Expanded(flex:3,child: Container(height: 16,child: Text("Gedung",style: TextStyle(fontSize: 14,),))),
  704. // Expanded(flex:1,child: Container(height: 16,child: Text(":",style: TextStyle(fontSize: 16,)))),
  705. // Expanded(flex: 7,child: SingleChildScrollView(scrollDirection: Axis.horizontal,child: Container(height: 16,child: Text(refAsset[index].gedung,style: TextStyle(fontSize: 16,color: Colors.black,fontWeight: FontWeight.bold)))))
  706. // ],
  707. // ),
  708. // ],
  709. // ),),
  710. // )
  711. // ],
  712. // ),
  713. // ),
  714. // ),
  715. // );
  716. // else{
  717. // if(keyString.toUpperCase().contains(search.toUpperCase())) return Opacity(
  718. // opacity: (refAsset[index].flag=='TRUE')?0.5:1,
  719. // child: Padding(
  720. // padding: const EdgeInsets.only(bottom: 8,left: 8,right: 8),
  721. // child: Container(
  722. // decoration: BoxDecoration(
  723. // color: Colors.white,
  724. // borderRadius: BorderRadius.circular(5)
  725. // ),
  726. // height: 100,
  727. // child: Row(
  728. // children: <Widget>[
  729. // Container(height: 100,width: 100,decoration:BoxDecoration(
  730. // image:refAsset[index].blob==null?null: DecorationImage(
  731. // image: MemoryImage(refAsset[index].blob,),
  732. // fit: BoxFit.cover
  733. // ),
  734. // color:Colors.grey,
  735. // borderRadius: BorderRadius.only(topLeft: Radius.circular(5),bottomLeft: Radius.circular(5))
  736. // ),child:Icon(Icons.image),),
  737. // Expanded(
  738. // flex: 7,
  739. // child: Container(padding: EdgeInsets.all(5),
  740. // height: 180,
  741. // child: Column(
  742. // mainAxisAlignment: MainAxisAlignment.spaceAround,
  743. // children: <Widget>[
  744. // Row(
  745. // children: <Widget>[
  746. // Expanded(flex:3,child: Text("Tag Number",style: TextStyle(fontSize: 14,),)),
  747. // Expanded(flex:1,child: Text(":",style: TextStyle(fontSize: 16,))),
  748. // Expanded(flex: 7,child: Text(refAsset[index].tag_number,style: TextStyle(fontSize: 16,fontWeight: FontWeight.bold,color: Colors.black)))
  749. // ],
  750. // ),
  751. // Row(
  752. // children: <Widget>[
  753. // Expanded(flex:3,child: Container(height: 16,child: Text("Asset Desc",style: TextStyle(fontSize: 14,),))),
  754. // Expanded(flex:1,child: Container(height: 16,child: Text(":",style: TextStyle(fontSize: 16,)))),
  755. // Expanded(flex: 7,child: SingleChildScrollView(scrollDirection: Axis.horizontal,child: Container(height: 16,child: Text(refAsset[index].asset_desc,style: TextStyle(fontSize: 16,color: Colors.black,fontWeight: FontWeight.bold)))))
  756. // ],
  757. // ),
  758. // Row(
  759. // children: <Widget>[
  760. // Expanded(flex:3,child: Container(height: 16,child: Text("Ruang",style: TextStyle(fontSize: 14,),))),
  761. // Expanded(flex:1,child: Container(height: 16,child: Text(":",style: TextStyle(fontSize: 16,)))),
  762. // Expanded(flex: 7,child: SingleChildScrollView(scrollDirection: Axis.horizontal,child: Container(height: 16,child: Text(refAsset[index].ruangan+' '+refAsset[index].lantai,style: TextStyle(fontSize: 16,color: Colors.black,fontWeight: FontWeight.bold)))))
  763. // ],
  764. // ),
  765. // Row(
  766. // children: <Widget>[
  767. // Expanded(flex:3,child: Container(height: 16,child: Text("Gedung",style: TextStyle(fontSize: 14,),))),
  768. // Expanded(flex:1,child: Container(height: 16,child: Text(":",style: TextStyle(fontSize: 16,)))),
  769. // Expanded(flex: 7,child: SingleChildScrollView(scrollDirection: Axis.horizontal,child: Container(height: 16,child: Text(refAsset[index].gedung,style: TextStyle(fontSize: 16,color: Colors.black,fontWeight: FontWeight.bold)))))
  770. // ],
  771. // ),
  772. // ],
  773. // ),),
  774. // )
  775. // ],
  776. // ),
  777. // ),
  778. // ),
  779. // );
  780. // else return Container();
  781. // }
  782. }
  783. ),
  784. ),
  785. // ListView(
  786. // padding: EdgeInsets.all(0),
  787. // children: <Widget>[
  788. // Padding(
  789. // padding: const EdgeInsets.only(bottom: 8,left: 8,right: 8),
  790. // child: Container(
  791. // decoration: BoxDecoration(
  792. // color: Colors.white,
  793. // borderRadius: BorderRadius.circular(5)
  794. // ),
  795. // height: 100,
  796. // child: Row(
  797. // children: <Widget>[
  798. // Container(height: 100,width: 100,decoration:BoxDecoration(
  799. // color:Colors.red,
  800. // borderRadius: BorderRadius.only(topLeft: Radius.circular(5),bottomLeft: Radius.circular(5))
  801. // ),child:Icon(Icons.image),),
  802. // Expanded(
  803. // flex: 7,
  804. // child: Container(padding: EdgeInsets.all(5),
  805. // child: Column(
  806. // mainAxisAlignment: MainAxisAlignment.spaceAround,
  807. // children: <Widget>[
  808. // Row(
  809. // children: <Widget>[
  810. // Expanded(flex:2,child: Text("Kode",style: TextStyle(fontSize: 14,),)),
  811. // Expanded(flex:1,child: Text(":",style: TextStyle(fontSize: 16,))),
  812. // Expanded(flex: 7,child: Text("aaaa",style: TextStyle(fontSize: 16,fontWeight: FontWeight.bold)))
  813. // ],
  814. // ),
  815. // Row(
  816. // children: <Widget>[
  817. // Expanded(flex:2,child: Text("Nama",style: TextStyle(fontSize: 14,),)),
  818. // Expanded(flex:1,child: Text(":",style: TextStyle(fontSize: 16,))),
  819. // Expanded(flex: 7,child: Text("aaaa",style: TextStyle(fontSize: 16,fontWeight: FontWeight.bold)))
  820. // ],
  821. // ),
  822. // Row(
  823. // children: <Widget>[
  824. // Expanded(flex:2,child: Text("Ruang",style: TextStyle(fontSize: 14,),)),
  825. // Expanded(flex:1,child: Text(":",style: TextStyle(fontSize: 16,))),
  826. // Expanded(flex: 7,child: Text("aaaa",style: TextStyle(fontSize: 16,fontWeight: FontWeight.bold)))
  827. // ],
  828. // ),
  829. // ],
  830. // ),),
  831. // )
  832. // ],
  833. // ),
  834. // ),
  835. // ),
  836. // Padding(
  837. // padding: const EdgeInsets.only(bottom: 8,left: 8,right: 8),
  838. // child: Container(
  839. // decoration: BoxDecoration(
  840. // color: Colors.white,
  841. // borderRadius: BorderRadius.circular(5)
  842. // ),
  843. // height: 100,
  844. // child: Row(
  845. // children: <Widget>[
  846. // Container(height: 100,width: 100,decoration:BoxDecoration(
  847. // color:Colors.red,
  848. // borderRadius: BorderRadius.only(topLeft: Radius.circular(5),bottomLeft: Radius.circular(5))
  849. // ),child:Icon(Icons.image),),
  850. // Expanded(
  851. // flex: 7,
  852. // child: Container(padding: EdgeInsets.all(5),
  853. // child: Column(
  854. // mainAxisAlignment: MainAxisAlignment.spaceAround,
  855. // children: <Widget>[
  856. // Row(
  857. // children: <Widget>[
  858. // Expanded(flex:2,child: Text("Kode",style: TextStyle(fontSize: 14,),)),
  859. // Expanded(flex:1,child: Text(":",style: TextStyle(fontSize: 16,))),
  860. // Expanded(flex: 7,child: Text("aaaa",style: TextStyle(fontSize: 16,fontWeight: FontWeight.bold)))
  861. // ],
  862. // ),
  863. // Row(
  864. // children: <Widget>[
  865. // Expanded(flex:2,child: Text("Nama",style: TextStyle(fontSize: 14,),)),
  866. // Expanded(flex:1,child: Text(":",style: TextStyle(fontSize: 16,))),
  867. // Expanded(flex: 7,child: Text("aaaa",style: TextStyle(fontSize: 16,fontWeight: FontWeight.bold)))
  868. // ],
  869. // ),
  870. // Row(
  871. // children: <Widget>[
  872. // Expanded(flex:2,child: Text("Ruang",style: TextStyle(fontSize: 14,),)),
  873. // Expanded(flex:1,child: Text(":",style: TextStyle(fontSize: 16,))),
  874. // Expanded(flex: 7,child: Text("aaaa",style: TextStyle(fontSize: 16,fontWeight: FontWeight.bold)))
  875. // ],
  876. // ),
  877. // ],
  878. // ),),
  879. // )
  880. // ],
  881. // ),
  882. // ),
  883. // ),
  884. // Padding(
  885. // padding: const EdgeInsets.only(bottom: 8,left: 8,right: 8),
  886. // child: Container(
  887. // decoration: BoxDecoration(
  888. // color: Colors.white,
  889. // borderRadius: BorderRadius.circular(5)
  890. // ),
  891. // height: 100,
  892. // child: Row(
  893. // children: <Widget>[
  894. // Container(height: 100,width: 100,decoration:BoxDecoration(
  895. // color:Colors.red,
  896. // borderRadius: BorderRadius.only(topLeft: Radius.circular(5),bottomLeft: Radius.circular(5))
  897. // ),child:Icon(Icons.image),),
  898. // Expanded(
  899. // flex: 7,
  900. // child: Container(padding: EdgeInsets.all(5),
  901. // child: Column(
  902. // mainAxisAlignment: MainAxisAlignment.spaceAround,
  903. // children: <Widget>[
  904. // Row(
  905. // children: <Widget>[
  906. // Expanded(flex:2,child: Text("Kode",style: TextStyle(fontSize: 14,),)),
  907. // Expanded(flex:1,child: Text(":",style: TextStyle(fontSize: 16,))),
  908. // Expanded(flex: 7,child: Text("aaaa",style: TextStyle(fontSize: 16,fontWeight: FontWeight.bold)))
  909. // ],
  910. // ),
  911. // Row(
  912. // children: <Widget>[
  913. // Expanded(flex:2,child: Text("Nama",style: TextStyle(fontSize: 14,),)),
  914. // Expanded(flex:1,child: Text(":",style: TextStyle(fontSize: 16,))),
  915. // Expanded(flex: 7,child: Text("aaaa",style: TextStyle(fontSize: 16,fontWeight: FontWeight.bold)))
  916. // ],
  917. // ),
  918. // Row(
  919. // children: <Widget>[
  920. // Expanded(flex:2,child: Text("Ruang",style: TextStyle(fontSize: 14,),)),
  921. // Expanded(flex:1,child: Text(":",style: TextStyle(fontSize: 16,))),
  922. // Expanded(flex: 7,child: Text("aaaa",style: TextStyle(fontSize: 16,fontWeight: FontWeight.bold)))
  923. // ],
  924. // ),
  925. // ],
  926. // ),),
  927. // )
  928. // ],
  929. // ),
  930. // ),
  931. // ),
  932. // Padding(
  933. // padding: const EdgeInsets.only(bottom: 8,left: 8,right: 8),
  934. // child: Container(
  935. // decoration: BoxDecoration(
  936. // color: Colors.white,
  937. // borderRadius: BorderRadius.circular(5)
  938. // ),
  939. // height: 100,
  940. // child: Row(
  941. // children: <Widget>[
  942. // Container(height: 100,width: 100,decoration:BoxDecoration(
  943. // color:Colors.red,
  944. // borderRadius: BorderRadius.only(topLeft: Radius.circular(5),bottomLeft: Radius.circular(5))
  945. // ),child:Icon(Icons.image),),
  946. // Expanded(
  947. // flex: 7,
  948. // child: Container(padding: EdgeInsets.all(5),
  949. // child: Column(
  950. // mainAxisAlignment: MainAxisAlignment.spaceAround,
  951. // children: <Widget>[
  952. // Row(
  953. // children: <Widget>[
  954. // Expanded(flex:2,child: Text("Kode",style: TextStyle(fontSize: 14,),)),
  955. // Expanded(flex:1,child: Text(":",style: TextStyle(fontSize: 16,))),
  956. // Expanded(flex: 7,child: Text("aaaa",style: TextStyle(fontSize: 16,fontWeight: FontWeight.bold)))
  957. // ],
  958. // ),
  959. // Row(
  960. // children: <Widget>[
  961. // Expanded(flex:2,child: Text("Nama",style: TextStyle(fontSize: 14,),)),
  962. // Expanded(flex:1,child: Text(":",style: TextStyle(fontSize: 16,))),
  963. // Expanded(flex: 7,child: Text("aaaa",style: TextStyle(fontSize: 16,fontWeight: FontWeight.bold)))
  964. // ],
  965. // ),
  966. // Row(
  967. // children: <Widget>[
  968. // Expanded(flex:2,child: Text("Ruang",style: TextStyle(fontSize: 14,),)),
  969. // Expanded(flex:1,child: Text(":",style: TextStyle(fontSize: 16,))),
  970. // Expanded(flex: 7,child: Text("aaaa",style: TextStyle(fontSize: 16,fontWeight: FontWeight.bold)))
  971. // ],
  972. // ),
  973. // ],
  974. // ),),
  975. // )
  976. // ],
  977. // ),
  978. // ),
  979. // ),
  980. // ],
  981. // ),
  982. ],
  983. ),
  984. ),
  985. ],
  986. ),
  987. ),
  988. ],
  989. ),
  990. ),
  991. Container(
  992. alignment: Alignment.center,
  993. child: (isLoading)?CircularProgressIndicator():null,
  994. )
  995. ],
  996. ),
  997. floatingActionButton: FloatingActionButton(
  998. onPressed: ()async{
  999. await Navigator.push(context, MaterialPageRoute(builder: (context) => new AssetDetails(lokasi: lokasi,)));
  1000. await loadAsset();
  1001. },
  1002. backgroundColor: Colors.blueGrey,
  1003. child: Icon(Icons.add),
  1004. ),
  1005. );
  1006. }
  1007. }