Cleanup code
This commit is contained in:
parent
3a589d5837
commit
09eabb91eb
4 changed files with 56 additions and 68 deletions
|
@ -5,7 +5,7 @@ import 'package:nekoya_flutter/api/api.dart';
|
||||||
import 'package:nekoya_flutter/data/cart.dart';
|
import 'package:nekoya_flutter/data/cart.dart';
|
||||||
|
|
||||||
class CheckoutForm extends StatefulWidget {
|
class CheckoutForm extends StatefulWidget {
|
||||||
CheckoutForm({Key? key}) : super(key: key);
|
const CheckoutForm({Key? key}) : super(key: key);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
State<CheckoutForm> createState() => _CheckoutFormState();
|
State<CheckoutForm> createState() => _CheckoutFormState();
|
||||||
|
@ -233,13 +233,8 @@ class _CheckoutFormState extends State<CheckoutForm> {
|
||||||
.fields["Shipping Method"]!.value,
|
.fields["Shipping Method"]!.value,
|
||||||
"data": cartData,
|
"data": cartData,
|
||||||
};
|
};
|
||||||
var statusCode = await checkoutPost(data);
|
|
||||||
|
|
||||||
if (statusCode == 201) {
|
await checkoutPost(data);
|
||||||
print("StatusCode" + statusCode.toString());
|
|
||||||
} else {
|
|
||||||
print("StatusCode" + statusCode.toString());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
color: const Color(0xff8B0000),
|
color: const Color(0xff8B0000),
|
||||||
|
|
|
@ -4,14 +4,13 @@ import 'package:nekoya_flutter/data/cart.dart';
|
||||||
import 'package:nekoya_flutter/components/cart_box.dart';
|
import 'package:nekoya_flutter/components/cart_box.dart';
|
||||||
|
|
||||||
class CheckoutItems extends StatefulWidget {
|
class CheckoutItems extends StatefulWidget {
|
||||||
CheckoutItems({Key? key}) : super(key: key);
|
const CheckoutItems({Key? key}) : super(key: key);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
State<CheckoutItems> createState() => _CheckoutItemsState();
|
State<CheckoutItems> createState() => _CheckoutItemsState();
|
||||||
}
|
}
|
||||||
|
|
||||||
class _CheckoutItemsState extends State<CheckoutItems> {
|
class _CheckoutItemsState extends State<CheckoutItems> {
|
||||||
Future<dynamic> _viewCart = viewCart();
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Container(
|
return Container(
|
||||||
|
@ -36,7 +35,7 @@ class _CheckoutItemsState extends State<CheckoutItems> {
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
FutureBuilder<dynamic>(
|
FutureBuilder<dynamic>(
|
||||||
future: _viewCart,
|
future: viewCart(),
|
||||||
builder: (context, snapshot) {
|
builder: (context, snapshot) {
|
||||||
if (snapshot.hasData) {
|
if (snapshot.hasData) {
|
||||||
var data = snapshot.data;
|
var data = snapshot.data;
|
||||||
|
|
|
@ -41,10 +41,9 @@ class _PaymentBodyState extends State<PaymentBody> {
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
Container(
|
Container(
|
||||||
padding: EdgeInsets.only(bottom: 20),
|
padding: const EdgeInsets.only(bottom: 20),
|
||||||
child: ClipRRect(
|
child: ClipRRect(
|
||||||
borderRadius: BorderRadius.circular(18),
|
borderRadius: BorderRadius.circular(18),
|
||||||
child: Container(
|
|
||||||
child: ExpansionTile(
|
child: ExpansionTile(
|
||||||
backgroundColor: Colors.blue,
|
backgroundColor: Colors.blue,
|
||||||
collapsedBackgroundColor: Colors.blue.shade800,
|
collapsedBackgroundColor: Colors.blue.shade800,
|
||||||
|
@ -61,9 +60,8 @@ class _PaymentBodyState extends State<PaymentBody> {
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
|
||||||
Container(
|
Container(
|
||||||
padding: EdgeInsets.only(bottom: 20),
|
padding: const EdgeInsets.only(bottom: 20),
|
||||||
child: ClipRRect(
|
child: ClipRRect(
|
||||||
borderRadius: BorderRadius.circular(18),
|
borderRadius: BorderRadius.circular(18),
|
||||||
child: ExpansionTile(
|
child: ExpansionTile(
|
||||||
|
@ -82,8 +80,7 @@ class _PaymentBodyState extends State<PaymentBody> {
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
Container(
|
ClipRRect(
|
||||||
child: ClipRRect(
|
|
||||||
borderRadius: BorderRadius.circular(18),
|
borderRadius: BorderRadius.circular(18),
|
||||||
child: ExpansionTile(
|
child: ExpansionTile(
|
||||||
backgroundColor: Colors.blue,
|
backgroundColor: Colors.blue,
|
||||||
|
@ -100,13 +97,12 @@ class _PaymentBodyState extends State<PaymentBody> {
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
|
||||||
Container(
|
Container(
|
||||||
padding: EdgeInsets.only(top: 40),
|
padding: const EdgeInsets.only(top: 40),
|
||||||
color: Colors.transparent,
|
color: Colors.transparent,
|
||||||
),
|
),
|
||||||
Container(
|
Container(
|
||||||
child: Text(
|
child: const Text(
|
||||||
'13000000',
|
'13000000',
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
fontSize: 30,
|
fontSize: 30,
|
||||||
|
@ -120,11 +116,10 @@ class _PaymentBodyState extends State<PaymentBody> {
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
Container(
|
Container(
|
||||||
padding: EdgeInsets.only(top: 40),
|
padding: const EdgeInsets.only(top: 40),
|
||||||
color: Colors.transparent,
|
color: Colors.transparent,
|
||||||
),
|
),
|
||||||
Container(
|
ElevatedButton(
|
||||||
child: ElevatedButton(
|
|
||||||
style: ButtonStyle(
|
style: ButtonStyle(
|
||||||
foregroundColor:
|
foregroundColor:
|
||||||
MaterialStateProperty.all(Colors.red.shade800),
|
MaterialStateProperty.all(Colors.red.shade800),
|
||||||
|
@ -133,17 +128,16 @@ class _PaymentBodyState extends State<PaymentBody> {
|
||||||
shape: MaterialStateProperty.all<RoundedRectangleBorder>(
|
shape: MaterialStateProperty.all<RoundedRectangleBorder>(
|
||||||
RoundedRectangleBorder(
|
RoundedRectangleBorder(
|
||||||
borderRadius: BorderRadius.circular(18.0),
|
borderRadius: BorderRadius.circular(18.0),
|
||||||
side: BorderSide(color: Colors.red)))),
|
side: const BorderSide(color: Colors.red)))),
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
Navigator.push(context,
|
Navigator.push(context,
|
||||||
MaterialPageRoute(builder: (context) => Transactions()));
|
MaterialPageRoute(builder: (context) => const Transactions()));
|
||||||
},
|
},
|
||||||
child: Text(
|
child: const Text(
|
||||||
'Transaction',
|
'Transaction',
|
||||||
style: TextStyle(color: Colors.white, fontSize: 25),
|
style: TextStyle(color: Colors.white, fontSize: 25),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
|
@ -22,7 +22,7 @@ class _CheckoutState extends State<Checkout> {
|
||||||
body: SafeArea(
|
body: SafeArea(
|
||||||
child: SingleChildScrollView(
|
child: SingleChildScrollView(
|
||||||
child: Column(
|
child: Column(
|
||||||
children: [
|
children: const [
|
||||||
CheckoutItems(),
|
CheckoutItems(),
|
||||||
CheckoutForm(),
|
CheckoutForm(),
|
||||||
],
|
],
|
||||||
|
|
Loading…
Add table
Reference in a new issue