update payment total price
This commit is contained in:
parent
362438f97b
commit
b974f458bc
1 changed files with 49 additions and 8 deletions
|
@ -1,4 +1,7 @@
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:nekoya_flutter/api/api.dart';
|
||||||
|
import 'package:nekoya_flutter/data/cart.dart';
|
||||||
|
import 'package:intl/intl.dart';
|
||||||
|
|
||||||
import 'package:nekoya_flutter/components/menu.dart';
|
import 'package:nekoya_flutter/components/menu.dart';
|
||||||
|
|
||||||
|
@ -12,6 +15,19 @@ class PaymentBody extends StatefulWidget {
|
||||||
class _PaymentBodyState extends State<PaymentBody> {
|
class _PaymentBodyState extends State<PaymentBody> {
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
|
Future<dynamic> getTotal() async {
|
||||||
|
dynamic totalPrice = 0;
|
||||||
|
var orderData = await viewCart();
|
||||||
|
await orderData.forEach((x) async {
|
||||||
|
var product = await getProduct(x['product_id']);
|
||||||
|
totalPrice += product[0]['PRICE'] * x['quantity'];
|
||||||
|
});
|
||||||
|
|
||||||
|
return Future.delayed(const Duration(seconds: 2), () {
|
||||||
|
return totalPrice;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
return Container(
|
return Container(
|
||||||
decoration: const BoxDecoration(color: Colors.transparent),
|
decoration: const BoxDecoration(color: Colors.transparent),
|
||||||
child: ListView(
|
child: ListView(
|
||||||
|
@ -104,16 +120,41 @@ class _PaymentBodyState extends State<PaymentBody> {
|
||||||
),
|
),
|
||||||
Container(
|
Container(
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
borderRadius: BorderRadius.circular(0),
|
borderRadius: BorderRadius.circular(18),
|
||||||
color: const Color(0xff8B0000),
|
color: const Color(0xff8B0000),
|
||||||
),
|
),
|
||||||
child: const Text(
|
child: FutureBuilder<dynamic>(
|
||||||
'13000000',
|
future: getTotal(),
|
||||||
style: TextStyle(
|
builder: (context, snapshot) {
|
||||||
fontSize: 30,
|
if (snapshot.hasData) {
|
||||||
color: Colors.white,
|
var price = snapshot.data;
|
||||||
),
|
return Row(
|
||||||
textAlign: TextAlign.center,
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
|
children: [
|
||||||
|
Text(
|
||||||
|
"Rp ${NumberFormat('#,##0.00', 'ID').format(price)}",
|
||||||
|
style: const TextStyle(
|
||||||
|
color: Colors.white,
|
||||||
|
fontSize: 25,
|
||||||
|
fontWeight: FontWeight.w600),
|
||||||
|
)
|
||||||
|
],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
|
children: const [
|
||||||
|
Text(
|
||||||
|
"Count total price on process!",
|
||||||
|
style: TextStyle(
|
||||||
|
color: Colors.white,
|
||||||
|
fontSize: 25,
|
||||||
|
fontWeight: FontWeight.w600),
|
||||||
|
)
|
||||||
|
],
|
||||||
|
);
|
||||||
|
},
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
Container(
|
Container(
|
||||||
|
|
Loading…
Reference in a new issue