Skip to content

Commit

Permalink
#5 presentation : UI
Browse files Browse the repository at this point in the history
  • Loading branch information
surajadkhari committed Aug 20, 2022
1 parent 3ddc906 commit b686548
Showing 1 changed file with 23 additions and 3 deletions.
26 changes: 23 additions & 3 deletions lib/features/presentation/widgets/home.dart
Original file line number Diff line number Diff line change
@@ -1,10 +1,30 @@
import 'package:fetch_api_with_proper_architecure/features/presentation/controllers/post_controller.dart';
import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';

class HomePage extends StatelessWidget {
class HomePage extends ConsumerWidget {
const HomePage({Key? key}) : super(key: key);

@override
Widget build(BuildContext context) {
return const Scaffold();
Widget build(BuildContext context, WidgetRef ref) {
final data = ref.watch(postControllerProvider);
return Scaffold(
body: data.when(
data: (data) {
return ListView(
children: [
...data.map((e) => ListTile(
contentPadding: const EdgeInsets.all(20),
title: Text(
"${e.firstName} ${e.lastName}",
),
trailing: Image.network(e.avatar),
))
],
);
},
error: (error, stackTrace) => Text(error.toString()),
loading: () => const CircularProgressIndicator()),
);
}
}

0 comments on commit b686548

Please sign in to comment.