Calculate delivery price quotes in Flutter.
flasho.pricing
flasho.pricing
calculate()
Returns a PriceQuote. Use it to show the delivery fee to customers before they confirm.
On-demand quote
final quote = await flasho.pricing.calculate(
CalculatePriceRequest(
fromLatitude: 29.3764,
fromLongitude: 47.9785,
toLatitude: 29.3117,
toLongitude: 48.0034,
),
);
print(quote.price); // "1.250"
print(quote.currency); // "KWD"
print(quote.distance); // 4.2
print(quote.distanceUnit); // "km"
print(quote.estimatedDuration); // 12 (minutes)
print(quote.tierLabel); // "Up to 10 km"Scheduled quote
final quote = await flasho.pricing.calculate(
CalculatePriceRequest(
fromLatitude: 29.3764,
fromLongitude: 47.9785,
toLatitude: 29.3117,
toLongitude: 48.0034,
isScheduled: true,
),
);
print(quote.price); // "2.000"
print(quote.pricingMode); // "scheduled"
print(quote.tierLabel); // "Scheduled delivery (flat rate)"With area hints
final quote = await flasho.pricing.calculate(
CalculatePriceRequest(
fromLatitude: 29.3764,
fromLongitude: 47.9785,
toLatitude: 29.3117,
toLongitude: 48.0034,
deliveryArea: 'Salmiya, Block 3',
deliveryPaciArea: 'Salmiya',
),
);Flutter checkout widget pattern
class CheckoutScreen extends StatefulWidget {
const CheckoutScreen({super.key});
@override
State<CheckoutScreen> createState() => _CheckoutScreenState();
}
class _CheckoutScreenState extends State<CheckoutScreen> {
PriceQuote? _quote;
bool _loading = true;
@override
void initState() {
super.initState();
_loadQuote();
}
Future<void> _loadQuote() async {
final flasho = context.read<FlashoClient>();
final quote = await flasho.pricing.calculate(
CalculatePriceRequest(
fromLatitude: 29.3764,
fromLongitude: 47.9785,
toLatitude: 29.3117,
toLongitude: 48.0034,
),
);
setState(() {
_quote = quote;
_loading = false;
});
}
@override
Widget build(BuildContext context) {
if (_loading) return const CircularProgressIndicator();
return Text('Delivery fee: ${_quote!.price} ${_quote!.currency}');
}
}CalculatePriceRequest fields
| Field | Required | Description |
|---|---|---|
fromLatitude | ✓ | Pickup latitude |
fromLongitude | ✓ | Pickup longitude |
toLatitude | ✓ | Drop-off latitude |
toLongitude | ✓ | Drop-off longitude |
deliveryArea | — | Area string — improves zone detection |
deliveryPaciArea | — | PACI area name |
isScheduled | — | true for scheduled flat rate |