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