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)
This commit is contained in:
@@ -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<SearchResult> results) = _Done;
|
||||
const factory RecyclingSearchState.idle() = Idle;
|
||||
const factory RecyclingSearchState.loading() = Loading;
|
||||
const factory RecyclingSearchState.done(List<SearchResult> 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<SearchResult> results;
|
||||
const _Done(this.results);
|
||||
const Done(this.results);
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user