update cart/favorite
This commit is contained in:
@@ -3,7 +3,7 @@
|
||||
/// Shopping cart screen with selection and checkout.
|
||||
/// Features expanded item list with total price at bottom.
|
||||
library;
|
||||
|
||||
import 'package:worker/core/utils/extensions.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
|
||||
@@ -35,14 +35,8 @@ class CartPage extends ConsumerStatefulWidget {
|
||||
class _CartPageState extends ConsumerState<CartPage> {
|
||||
bool _isSyncing = false;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
// Initialize cart from API on mount
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
ref.read(cartProvider.notifier).initialize();
|
||||
});
|
||||
}
|
||||
// Cart is initialized once in home_page.dart at app startup
|
||||
// Provider has keepAlive: true, so no need to reload here
|
||||
|
||||
// Note: Sync is handled in PopScope.onPopInvokedWithResult for back navigation
|
||||
// and in checkout button handler for checkout flow.
|
||||
@@ -53,11 +47,7 @@ class _CartPageState extends ConsumerState<CartPage> {
|
||||
final colorScheme = Theme.of(context).colorScheme;
|
||||
final cartState = ref.watch(cartProvider);
|
||||
|
||||
final currencyFormatter = NumberFormat.currency(
|
||||
locale: 'vi_VN',
|
||||
symbol: 'đ',
|
||||
decimalDigits: 0,
|
||||
);
|
||||
|
||||
|
||||
final itemCount = cartState.itemCount;
|
||||
final hasSelection = cartState.selectedCount > 0;
|
||||
@@ -144,7 +134,11 @@ class _CartPageState extends ConsumerState<CartPage> {
|
||||
context,
|
||||
cartState,
|
||||
ref,
|
||||
currencyFormatter,
|
||||
NumberFormat.currency(
|
||||
locale: 'vi_VN',
|
||||
symbol: 'đ',
|
||||
decimalDigits: 0,
|
||||
),
|
||||
hasSelection,
|
||||
),
|
||||
],
|
||||
|
||||
Reference in New Issue
Block a user