From 057e063c0baabac05646742f4dbfef6a0efafba2 Mon Sep 17 00:00:00 2001 From: Alan Alonso Date: Fri, 22 May 2026 19:30:41 -0600 Subject: [PATCH] fix: resolve compilation errors - Add flutter_riverpod dependency to pubspec.yaml - Rename sealed class subtypes (Idle, Loading, Done) as public - Update RecyclingGuideScreen to use type checks instead of pattern matching - Fix CardThemeData type in app_theme.dart - Keep withOpacity (warnings only, not errors) --- .claude/settings.local.json | 8 +++++- .../providers/recycling_provider.dart | 18 ++++++------ .../screens/recycling_guide_screen.dart | 28 +++++++++++-------- lib/theme/app_theme.dart | 2 +- pubspec.lock | 24 ++++++++++++++++ pubspec.yaml | 1 + 6 files changed, 58 insertions(+), 23 deletions(-) diff --git a/.claude/settings.local.json b/.claude/settings.local.json index 36c9de5..7335e8e 100644 --- a/.claude/settings.local.json +++ b/.claude/settings.local.json @@ -9,7 +9,13 @@ "Bash(rm -rf lib/src)", "Bash(cp -r basura_app/lib/* lib/)", "Bash(git checkout *)", - "Bash(git add *)" + "Bash(git add *)", + "Bash(git commit *)", + "Bash(git push *)", + "mcp__ide__getDiagnostics", + "Read(//mnt/c/Users/Wallt/StudioProjects/**)", + "Bash(flutter pub *)", + "Bash(flutter analyze *)" ] } } diff --git a/lib/features/recycling_guide/presentation/providers/recycling_provider.dart b/lib/features/recycling_guide/presentation/providers/recycling_provider.dart index 4fb2d54..1979376 100644 --- a/lib/features/recycling_guide/presentation/providers/recycling_provider.dart +++ b/lib/features/recycling_guide/presentation/providers/recycling_provider.dart @@ -45,20 +45,20 @@ final recyclingSearchProvider = sealed class RecyclingSearchState { const RecyclingSearchState(); - const factory RecyclingSearchState.idle() = _Idle; - const factory RecyclingSearchState.loading() = _Loading; - const factory RecyclingSearchState.done(List results) = _Done; + const factory RecyclingSearchState.idle() = Idle; + const factory RecyclingSearchState.loading() = Loading; + const factory RecyclingSearchState.done(List results) = Done; } -class _Idle extends RecyclingSearchState { - const _Idle(); +class Idle extends RecyclingSearchState { + const Idle(); } -class _Loading extends RecyclingSearchState { - const _Loading(); +class Loading extends RecyclingSearchState { + const Loading(); } -class _Done extends RecyclingSearchState { +class Done extends RecyclingSearchState { final List results; - const _Done(this.results); + const Done(this.results); } diff --git a/lib/features/recycling_guide/presentation/screens/recycling_guide_screen.dart b/lib/features/recycling_guide/presentation/screens/recycling_guide_screen.dart index 10948d9..07a44f9 100644 --- a/lib/features/recycling_guide/presentation/screens/recycling_guide_screen.dart +++ b/lib/features/recycling_guide/presentation/screens/recycling_guide_screen.dart @@ -137,10 +137,13 @@ class _SearchResults extends ConsumerWidget { Widget build(BuildContext context, WidgetRef ref) { final estado = ref.watch(recyclingSearchProvider); - return switch (estado) { - _Idle() => const SizedBox.shrink(), - _Loading() => const Center(child: CircularProgressIndicator()), - _Done(results: final r) when r.isEmpty => Center( + if (estado is Idle) { + return const SizedBox.shrink(); + } else if (estado is Loading) { + return const Center(child: CircularProgressIndicator()); + } else if (estado is Done) { + if (estado.results.isEmpty) { + return Center( child: Column( mainAxisSize: MainAxisSize.min, children: [ @@ -152,13 +155,14 @@ class _SearchResults extends ConsumerWidget { ), ], ), - ), - _Done(results: final r) => ListView.builder( - padding: const EdgeInsets.symmetric(vertical: 8), - itemCount: r.length, - itemBuilder: (_, i) => SearchResultTile(resultado: r[i]), - ), - _ => const SizedBox.shrink(), - }; + ); + } + return ListView.builder( + padding: const EdgeInsets.symmetric(vertical: 8), + itemCount: estado.results.length, + itemBuilder: (_, i) => SearchResultTile(resultado: estado.results[i]), + ); + } + return const SizedBox.shrink(); } } diff --git a/lib/theme/app_theme.dart b/lib/theme/app_theme.dart index 508f429..71bc3a9 100644 --- a/lib/theme/app_theme.dart +++ b/lib/theme/app_theme.dart @@ -39,7 +39,7 @@ class AppTheme { color: Colors.white, ), ), - cardTheme: CardTheme( + cardTheme: CardThemeData( color: surfaceColor, elevation: 2, shape: RoundedRectangleBorder( diff --git a/pubspec.lock b/pubspec.lock index fa61e04..c197c99 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -70,6 +70,14 @@ packages: url: "https://pub.dev" source: hosted version: "6.0.0" + flutter_riverpod: + dependency: "direct main" + description: + name: flutter_riverpod + sha256: "9532ee6db4a943a1ed8383072a2e3eeda041db5657cdf6d2acecf3c21ecbe7e1" + url: "https://pub.dev" + source: hosted + version: "2.6.1" flutter_test: dependency: "direct dev" description: flutter @@ -139,6 +147,14 @@ packages: url: "https://pub.dev" source: hosted version: "1.9.1" + riverpod: + dependency: transitive + description: + name: riverpod + sha256: "59062512288d3056b2321804332a13ffdd1bf16df70dcc8e506e411280a72959" + url: "https://pub.dev" + source: hosted + version: "2.6.1" sky_engine: dependency: transitive description: flutter @@ -160,6 +176,14 @@ packages: url: "https://pub.dev" source: hosted version: "1.12.1" + state_notifier: + dependency: transitive + description: + name: state_notifier + sha256: b8677376aa54f2d7c58280d5a007f9e8774f1968d1fb1c096adcb4792fba29bb + url: "https://pub.dev" + source: hosted + version: "1.0.0" stream_channel: dependency: transitive description: diff --git a/pubspec.yaml b/pubspec.yaml index 356e262..d97f77f 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -34,6 +34,7 @@ dependencies: # The following adds the Cupertino Icons font to your application. # Use with the CupertinoIcons class for iOS style icons. cupertino_icons: ^1.0.8 + flutter_riverpod: ^2.4.0 dev_dependencies: flutter_test: