import 'package:flutter_riverpod/flutter_riverpod.dart'; import '../core/api/api_client.dart'; import '../core/auth/auth_state.dart'; import '../models/license.dart'; import '../repositories/license_repository.dart'; export '../models/license.dart'; final licenseRepositoryProvider = Provider( (ref) => LicenseRepository(ref.read(apiClientProvider)), ); final licenseProvider = AsyncNotifierProvider(LicenseNotifier.new); class LicenseNotifier extends AsyncNotifier { @override Future build() async { ref.watch(authStateProvider.select((s) => s.user?.shopId)); return _fetch(); } Future _fetch() async { try { return await ref.read(licenseRepositoryProvider).getInfo(); } catch (_) { return null; } } Future reload() async { state = const AsyncValue.loading(); state = AsyncValue.data(await _fetch()); } }