build method
- BuildContext context
override
Builds the UI for the farmer sales analytics screen.
Displays cards for total revenue, top-selling products, and a line chart for order trends, based on completed orders for the farmer.
Parameters:
- context: The BuildContext for building the widget and accessing providers.
Returns: A Widget representing the sales analytics screen UI.
Implementation
@override
Widget build(BuildContext context) {
final authService = Provider.of<AuthService>(context);
final farmerId = authService.currentUser!.uid;
return Scaffold(
appBar: AppBar(title: const Text('Sales Analytics')),
body: SingleChildScrollView(
padding: const EdgeInsets.symmetric(horizontal: 16.0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
const SizedBox(height: 16),
_buildTotalRevenueCard(farmerId),
const SizedBox(height: 16),
_buildTopProductsCard(farmerId),
const SizedBox(height: 16),
_buildOrderTrendsChart(farmerId),
],
),
),
);
}