Skip to content

Commit 4988fce

Browse files
committed
[CORE] Improve list view height calculation
1 parent cb4d479 commit 4988fce

File tree

1 file changed

+25
-22
lines changed

1 file changed

+25
-22
lines changed

lib/ui/home/receipt_form.dart

Lines changed: 25 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -376,6 +376,7 @@ class ReceiptInputController extends State<ReceiptForm> {
376376
],
377377
),
378378
getItems(),
379+
getItemListButton()
379380
],
380381
),
381382
))),
@@ -550,7 +551,7 @@ class ReceiptInputController extends State<ReceiptForm> {
550551
)),
551552
Container(
552553
color: Colors.white,
553-
height: (75 * itemList.length).toDouble() - 20,
554+
height: (50 * itemList.length).toDouble(),
554555
child: ListView.builder(
555556
padding: const EdgeInsets.all(8.0),
556557
itemCount: itemList.length,
@@ -559,27 +560,6 @@ class ReceiptInputController extends State<ReceiptForm> {
559560
final receipt = itemList[index];
560561
return _item(receipt);
561562
})),
562-
PaddingFactory.create(Align(
563-
alignment: Alignment.topRight,
564-
child: RaisedButton(
565-
onPressed: () {
566-
log("Add itemlist");
567-
setState(() {
568-
List<dynamic> item = ["Receipt item", "0.00"];
569-
this.itemList.add(item);
570-
});
571-
},
572-
shape: RoundedRectangleBorder(
573-
borderRadius: BorderRadius.circular(18.0),
574-
side: BorderSide(color: Colors.black)),
575-
child: Column(children: [Icon(Icons.add, color: Colors.white)]),
576-
color: Colors.black,
577-
textColor: Colors.black,
578-
elevation: 5,
579-
))),
580-
Container(
581-
height: 50,
582-
)
583563
]);
584564
;
585565
}
@@ -678,4 +658,27 @@ class ReceiptInputController extends State<ReceiptForm> {
678658
storeNameController.clear();
679659
dateController.clear();
680660
}
661+
662+
Widget getItemListButton() {
663+
if (itemList == null) return Container();
664+
665+
return PaddingFactory.create(Align(
666+
alignment: Alignment.topRight,
667+
child: RaisedButton(
668+
onPressed: () {
669+
log("Add itemlist");
670+
setState(() {
671+
List<dynamic> item = ["Receipt item", "0.00"];
672+
this.itemList.add(item);
673+
});
674+
},
675+
shape: RoundedRectangleBorder(
676+
borderRadius: BorderRadius.circular(18.0),
677+
side: BorderSide(color: Colors.black)),
678+
child: Column(children: [Icon(Icons.add, color: Colors.white)]),
679+
color: Colors.black,
680+
textColor: Colors.black,
681+
elevation: 5,
682+
)));
683+
}
681684
}

0 commit comments

Comments
 (0)