feat: implement grid layout for recipes with column selection and improve pantry product picker
Co-authored-by: Copilot <copilot@github.com>
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
|
||||
const _prefsKey = 'recipes_grid_columns';
|
||||
|
||||
class RecipesGridNotifier extends AsyncNotifier<int> {
|
||||
@override
|
||||
Future<int> build() async {
|
||||
final prefs = await SharedPreferences.getInstance();
|
||||
return prefs.getInt(_prefsKey) ?? 2;
|
||||
}
|
||||
|
||||
Future<void> setColumns(int columns) async {
|
||||
final prefs = await SharedPreferences.getInstance();
|
||||
await prefs.setInt(_prefsKey, columns);
|
||||
state = AsyncData(columns);
|
||||
}
|
||||
}
|
||||
|
||||
final recipesGridProvider =
|
||||
AsyncNotifierProvider<RecipesGridNotifier, int>(RecipesGridNotifier.new);
|
||||
Reference in New Issue
Block a user