31 lines
661 B
Dart
31 lines
661 B
Dart
/// Provider: Current Page Index Provider
|
|
///
|
|
/// Manages the state of the current bottom navigation page index.
|
|
library;
|
|
|
|
import 'package:riverpod_annotation/riverpod_annotation.dart';
|
|
|
|
part 'current_page_provider.g.dart';
|
|
|
|
/// Current Page Index Notifier
|
|
///
|
|
/// Manages which page is currently displayed in the bottom navigation.
|
|
/// Pages:
|
|
/// - 0: Home
|
|
/// - 1: Loyalty
|
|
/// - 2: Promotions
|
|
/// - 3: Notifications
|
|
/// - 4: Account
|
|
@riverpod
|
|
class CurrentPageIndex extends _$CurrentPageIndex {
|
|
@override
|
|
int build() => 0;
|
|
|
|
/// Set the current page index
|
|
void setIndex(int index) {
|
|
if (index >= 0 && index <= 4) {
|
|
state = index;
|
|
}
|
|
}
|
|
}
|