@@ -44,6 +44,7 @@ class _CheckoutDetailsPageState extends State<CheckoutDetailsPage> {
4444 _txtBillingCity = TextEditingController (),
4545 _txtBillingPostalCode = TextEditingController (),
4646 _txtBillingEmailAddress = TextEditingController (),
47+ _txtBillingPhoneNumber = TextEditingController (),
4748 // shipping
4849 _txtShippingFirstName = TextEditingController (),
4950 _txtShippingLastName = TextEditingController (),
@@ -74,6 +75,7 @@ class _CheckoutDetailsPageState extends State<CheckoutDetailsPage> {
7475 txtControllerCity: _txtBillingCity,
7576 txtControllerPostalCode: _txtBillingPostalCode,
7677 txtControllerEmailAddress: _txtBillingEmailAddress,
78+ txtControllerPhoneNumber: _txtBillingPhoneNumber,
7779 customerCountry: _billingCountry,
7880 onTapCountry: () => _navigateToSelectCountry (type: "billing" ),
7981 );
@@ -107,6 +109,9 @@ class _CheckoutDetailsPageState extends State<CheckoutDetailsPage> {
107109 CustomerAddress sfCustomerShippingAddress =
108110 await CheckoutSession .getInstance.getShippingAddress ();
109111 _setFieldsFromCustomerAddress (sfCustomerShippingAddress, type: "shipping" );
112+ setState (() {
113+
114+ });
110115 }
111116
112117 _setFieldsFromCustomerAddress (CustomerAddress customerAddress,
@@ -122,6 +127,7 @@ class _CheckoutDetailsPageState extends State<CheckoutDetailsPage> {
122127 city: customerAddress.city,
123128 postalCode: customerAddress.postalCode,
124129 emailAddress: customerAddress.emailAddress,
130+ phoneNumber: customerAddress.phoneNumber,
125131 customerCountry: customerAddress.customerCountry,
126132 type: type,
127133 );
@@ -134,6 +140,7 @@ class _CheckoutDetailsPageState extends State<CheckoutDetailsPage> {
134140 @required String city,
135141 @required String postalCode,
136142 @required String emailAddress,
143+ @required String phoneNumber,
137144 @required CustomerCountry customerCountry,
138145 String type}) {
139146 if (type == "billing" ) {
@@ -142,6 +149,7 @@ class _CheckoutDetailsPageState extends State<CheckoutDetailsPage> {
142149 _txtBillingAddressLine.text = addressLine;
143150 _txtBillingCity.text = city;
144151 _txtBillingPostalCode.text = postalCode;
152+ _txtBillingPhoneNumber.text = phoneNumber;
145153 _txtBillingEmailAddress.text = emailAddress;
146154 _billingCountry = customerCountry;
147155 } else if (type == "shipping" ) {
@@ -172,20 +180,19 @@ class _CheckoutDetailsPageState extends State<CheckoutDetailsPage> {
172180 crossAxisAlignment: CrossAxisAlignment .center,
173181 mainAxisAlignment: MainAxisAlignment .spaceBetween,
174182 children: < Widget > [
175- Flexible (
176- fit: FlexFit .tight,
183+ Expanded (
177184 child: Column (
178185 crossAxisAlignment: CrossAxisAlignment .center,
179186 mainAxisAlignment: MainAxisAlignment .start,
180187 children: [
188+ if (_hasDifferentShippingAddress)
181189 Container (
182190 margin: EdgeInsets .symmetric (vertical: 0 ),
183191 child: Column (
184192 crossAxisAlignment: CrossAxisAlignment .start,
185193 mainAxisAlignment: MainAxisAlignment .spaceAround,
186194 children: < Widget > [
187- (_hasDifferentShippingAddress
188- ? Padding (
195+ Padding (
189196 child: Row (
190197 crossAxisAlignment:
191198 CrossAxisAlignment .center,
@@ -212,14 +219,12 @@ class _CheckoutDetailsPageState extends State<CheckoutDetailsPage> {
212219 ].where ((e) => e != null ).toList (),
213220 ),
214221 padding: EdgeInsets .symmetric (vertical: 4 ),
215- )
216- : null ),
222+ ),
217223 ].where ((e) => e != null ).toList (),
218224 ),
219225 height: 60 ,
220226 ),
221- Flexible (
222- fit: FlexFit .tight,
227+ Expanded (
223228 child: Container (
224229 decoration: BoxDecoration (
225230 color: ThemeColor .get (context).backgroundContainer,
@@ -230,7 +235,8 @@ class _CheckoutDetailsPageState extends State<CheckoutDetailsPage> {
230235 : null ,
231236 ),
232237 padding: EdgeInsets .only (left: 8 , right: 8 , top: 8 ),
233- child: (activeTab ?? tabBillingDetails ()),
238+ margin: EdgeInsets .only (top: 8 ),
239+ child: (activeTab ?? tabBillingDetails ())
234240 ),
235241 ),
236242 ],
@@ -274,7 +280,7 @@ class _CheckoutDetailsPageState extends State<CheckoutDetailsPage> {
274280 ),
275281 PrimaryButton (
276282 title: trans ("USE DETAILS" ),
277- action: () => _useDetailsTapped () ,
283+ action: _useDetailsTapped,
278284 ),
279285 ],
280286 ),
@@ -286,15 +292,17 @@ class _CheckoutDetailsPageState extends State<CheckoutDetailsPage> {
286292 );
287293 }
288294
289- _useDetailsTapped () {
295+ _useDetailsTapped () async {
290296 CustomerAddress customerBillingAddress = _setCustomerAddress (
291297 firstName: _txtBillingFirstName.text,
292298 lastName: _txtBillingLastName.text,
293299 addressLine: _txtBillingAddressLine.text,
294300 city: _txtBillingCity.text,
295301 postalCode: _txtBillingPostalCode.text,
302+ phoneNumber: _txtBillingPhoneNumber.text,
296303 emailAddress: _txtBillingEmailAddress.text,
297- customerCountry: _billingCountry);
304+ customerCountry: _billingCountry,
305+ );
298306
299307 CheckoutSession .getInstance.billingDetails.shippingAddress =
300308 customerBillingAddress;
@@ -350,11 +358,11 @@ class _CheckoutDetailsPageState extends State<CheckoutDetailsPage> {
350358 }
351359
352360 if (valRememberDetails == true ) {
353- CheckoutSession .getInstance.saveBillingAddress ();
354- CheckoutSession .getInstance.saveShippingAddress ();
361+ await CheckoutSession .getInstance.saveBillingAddress ();
362+ await CheckoutSession .getInstance.saveShippingAddress ();
355363 } else {
356- CheckoutSession .getInstance.clearBillingAddress ();
357- CheckoutSession .getInstance.clearShippingAddress ();
364+ await CheckoutSession .getInstance.clearBillingAddress ();
365+ await CheckoutSession .getInstance.clearShippingAddress ();
358366 }
359367
360368 CheckoutSession .getInstance.billingDetails.rememberDetails =
@@ -380,6 +388,7 @@ class _CheckoutDetailsPageState extends State<CheckoutDetailsPage> {
380388 addressLine: "" ,
381389 city: "" ,
382390 postalCode: "" ,
391+ phoneNumber: "" ,
383392 emailAddress: "" ,
384393 customerCountry: CustomerCountry ());
385394 }
@@ -393,13 +402,17 @@ class _CheckoutDetailsPageState extends State<CheckoutDetailsPage> {
393402 @required String city,
394403 @required String postalCode,
395404 @required String emailAddress,
405+ String phoneNumber,
396406 @required CustomerCountry customerCountry}) {
397407 CustomerAddress customerShippingAddress = CustomerAddress ();
398408 customerShippingAddress.firstName = firstName;
399409 customerShippingAddress.lastName = lastName;
400410 customerShippingAddress.addressLine = addressLine;
401411 customerShippingAddress.city = city;
402412 customerShippingAddress.postalCode = postalCode;
413+ if (phoneNumber != null && phoneNumber != "" ) {
414+ customerShippingAddress.phoneNumber = phoneNumber;
415+ }
403416 customerShippingAddress.customerCountry = customerCountry;
404417 customerShippingAddress.emailAddress = emailAddress;
405418 return customerShippingAddress;
0 commit comments