final
This commit is contained in:
@@ -20,9 +20,8 @@ import '../../utils/utils.dart';
|
||||
import '../../widgets/general/payment_verification_code_dialog.dart';
|
||||
|
||||
class MobilePayNow extends StatefulWidget {
|
||||
final Key key;
|
||||
final int orderId;
|
||||
const MobilePayNow(this.orderId, {this.key});
|
||||
const MobilePayNow(this.orderId, {Key? key});
|
||||
|
||||
@override
|
||||
State<StatefulWidget> createState() {
|
||||
@@ -32,11 +31,11 @@ class MobilePayNow extends StatefulWidget {
|
||||
}
|
||||
|
||||
class MobilePayNowState extends State<MobilePayNow> {
|
||||
Order order;
|
||||
List<PaymentPlatform> paymentPlatforms;
|
||||
User _user;
|
||||
Order? order;
|
||||
List<PaymentPlatform>? paymentPlatforms;
|
||||
User? _user;
|
||||
|
||||
bool nativePay;
|
||||
bool nativePay = false;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
@@ -56,7 +55,7 @@ class MobilePayNowState extends State<MobilePayNow> {
|
||||
BuildContext mainContext = context;
|
||||
|
||||
ListView listView = ListView.builder(
|
||||
itemCount: nativePay ? paymentPlatforms.length + 3 : paymentPlatforms.length + 2,
|
||||
itemCount: nativePay ? paymentPlatforms!.length + 3 : paymentPlatforms!.length + 2,
|
||||
itemBuilder: (BuildContext context, int position) {
|
||||
if (position == 0) {
|
||||
return Column(
|
||||
@@ -77,7 +76,7 @@ class MobilePayNowState extends State<MobilePayNow> {
|
||||
),
|
||||
),
|
||||
Text(
|
||||
'\$${order.totalPrice.toStringAsFixed(2)}',
|
||||
'\$${order!.totalPrice.toStringAsFixed(2)}',
|
||||
style: TextStyle(
|
||||
fontSize: 24.0,
|
||||
fontWeight: FontWeight.bold,
|
||||
@@ -94,7 +93,7 @@ class MobilePayNowState extends State<MobilePayNow> {
|
||||
)
|
||||
),
|
||||
),
|
||||
store.state.deviceId != null && store.state.deviceId.isNotEmpty || store.state.tableNumber != null && store.state.tableNumber.isNotEmpty ?
|
||||
store.state.deviceId != null && store.state.deviceId!.isNotEmpty || store.state.tableNumber != null && store.state.tableNumber!.isNotEmpty ?
|
||||
GestureDetector(
|
||||
child: Container(
|
||||
padding: EdgeInsets.only(top: 20.0, bottom: 20.0, left: 16.0, right: 16.0),
|
||||
@@ -157,8 +156,8 @@ class MobilePayNowState extends State<MobilePayNow> {
|
||||
}
|
||||
PaymentPlatform paymentPlatform;
|
||||
if (position == 1) {
|
||||
if (_user.stripePaymentMethods.length > 0) {
|
||||
paymentPlatform = paymentPlatforms[position - 1];
|
||||
if (_user!.stripePaymentMethods.length > 0) {
|
||||
paymentPlatform = paymentPlatforms![position - 1];
|
||||
Column column = Column(
|
||||
children: <Widget>[],
|
||||
);
|
||||
@@ -180,7 +179,7 @@ class MobilePayNowState extends State<MobilePayNow> {
|
||||
),
|
||||
),
|
||||
);
|
||||
for (StripePaymentMethod stripePaymentMethod in _user.stripePaymentMethods) {
|
||||
for (StripePaymentMethod stripePaymentMethod in _user!.stripePaymentMethods) {
|
||||
column.children.add(
|
||||
GestureDetector(
|
||||
child: Container(
|
||||
@@ -249,8 +248,8 @@ class MobilePayNowState extends State<MobilePayNow> {
|
||||
showDialog(
|
||||
context: mainContext,
|
||||
builder: (BuildContext context) {
|
||||
return PaymentVerificationCodeDialog(_user, () {
|
||||
Util.goPayment(context, order, paymentPlatform,
|
||||
return PaymentVerificationCodeDialog(_user!, () {
|
||||
Util.goPayment(context, order!, paymentPlatform,
|
||||
stripePaymentMethod: stripePaymentMethod);
|
||||
}, () {
|
||||
|
||||
@@ -281,10 +280,10 @@ class MobilePayNowState extends State<MobilePayNow> {
|
||||
}
|
||||
}
|
||||
if (position == 2 && nativePay) {
|
||||
paymentPlatform = paymentPlatforms[position - 2];
|
||||
return Util().getNativePay(mainContext, order, paymentPlatform);
|
||||
paymentPlatform = paymentPlatforms![position - 2];
|
||||
return Util().getNativePay(mainContext, order!, paymentPlatform);
|
||||
}
|
||||
paymentPlatform = nativePay ? paymentPlatforms[position - 3] : paymentPlatforms[position - 2];
|
||||
paymentPlatform = nativePay ? paymentPlatforms![position - 3] : paymentPlatforms![position - 2];
|
||||
return GestureDetector(
|
||||
child: Container(
|
||||
padding: EdgeInsets.only(top: 16.0, left: 16.0, right: 16.0, bottom: 16.0),
|
||||
@@ -293,7 +292,7 @@ class MobilePayNowState extends State<MobilePayNow> {
|
||||
children: <Widget>[
|
||||
Container(
|
||||
padding: EdgeInsets.only(right: 10.0),
|
||||
child: Util.showImage(paymentPlatform.icon,
|
||||
child: Util.showImage(paymentPlatform.icon ?? '',
|
||||
errorWidget: (context, url, error) => Icon(Icons.broken_image, size: 50.0, color: Colors.transparent,),
|
||||
fit: BoxFit.cover,
|
||||
width: 50.0,
|
||||
@@ -302,7 +301,7 @@ class MobilePayNowState extends State<MobilePayNow> {
|
||||
),
|
||||
Expanded(
|
||||
child: Text(
|
||||
S.of(context).pay_with_token(PaymentPlatform.getPaymentPlatformName(context, paymentPlatform.code)),
|
||||
S.of(context).pay_with_token(PaymentPlatform.getPaymentPlatformName(context, paymentPlatform.code ?? '')),
|
||||
style: TextStyle(
|
||||
fontSize: 18.0,
|
||||
fontWeight: FontWeight.bold,
|
||||
@@ -325,7 +324,7 @@ class MobilePayNowState extends State<MobilePayNow> {
|
||||
),
|
||||
),
|
||||
onTap: () {
|
||||
Util.goPayment(context, order, paymentPlatform);
|
||||
Util.goPayment(context, order!, paymentPlatform);
|
||||
},
|
||||
);
|
||||
}
|
||||
@@ -354,10 +353,10 @@ class MobilePayNowState extends State<MobilePayNow> {
|
||||
).then((data) {
|
||||
paymentPlatforms = (data['payment_platforms'] as List).map((e) =>
|
||||
PaymentPlatform.fromJson(e)).toList();
|
||||
PaymentPlatform pp = paymentPlatforms[0];
|
||||
PaymentPlatform pp = paymentPlatforms![0];
|
||||
if (Constants.ENABLE_NATIVE_PAY && pp.publishableKey != null
|
||||
&& pp.publishableKey.isNotEmpty && pp.merchantId != null
|
||||
&& pp.merchantId.isNotEmpty) {
|
||||
&& pp.publishableKey!.isNotEmpty && pp.merchantId != null
|
||||
&& pp.merchantId!.isNotEmpty) {
|
||||
nativePay = true;
|
||||
} else {
|
||||
nativePay = false;
|
||||
|
||||
Reference in New Issue
Block a user