Place Picker Full Address to Street Address Solution

Resolved

I ran into this issue and figured it's probably a pretty common one as a lot of people will break up a location's full address into it's parts (street, city, state, zip) when it goes into the database.

I created a custom function called streetAddressFunction. Make sure the return value is string and add an argument (from the place picker widget) called fullAddress that will also be a string. I made both nullable based on my use case.


String? streetAddressFunction(String? fullAddress) { /// MODIFY CODE ONLY BELOW THIS LINE // output the street address from the argument that has a full address if (fullAddress == null) { return null; } final addressList = fullAddress.split(','); for (final address in addressList) { if (address.trim().startsWith(RegExp(r'\d'))) { return address.trim(); } } return null; /// MODIFY CODE ONLY ABOVE THIS LINE }

1
1 reply