mirror of
https://github.com/pese-git/cherrypick.git
synced 2026-01-24 05:25:19 +00:00
- Refactored and updated pages, router, DI modules, and feature implementations in both example projects: - client_app: main.dart and my_home_page.dart updated for improved navigation and structure. - postly: updated DI wiring, presentation pages, repository implementation, and routing logic. - Applied small improvements and code consistency changes in the examples. docs: add new documentation assets and benchmarking script BREAKING CHANGE: Examples now reflect the latest changes in the DI framework and are ready for Dart 3.8+ and cherrypick_generator element2 API compatibility.
55 lines
1.6 KiB
Dart
55 lines
1.6 KiB
Dart
import 'package:auto_route/auto_route.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
|
|
|
import '../../router/app_router.gr.dart';
|
|
import '../bloc/post_bloc.dart';
|
|
|
|
@RoutePage()
|
|
class PostsPage extends StatelessWidget {
|
|
const PostsPage({super.key});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return BlocProvider(
|
|
create: (context) =>
|
|
context.read<PostBloc>()..add(const PostEvent.fetchAll()),
|
|
child: Scaffold(
|
|
appBar: AppBar(
|
|
title: const Text('Posts'),
|
|
actions: [
|
|
IconButton(
|
|
icon: const Icon(Icons.bug_report),
|
|
tooltip: 'Open logs',
|
|
onPressed: () {
|
|
AutoRouter.of(context).push(const LogsRoute());
|
|
},
|
|
),
|
|
],
|
|
),
|
|
body: BlocBuilder<PostBloc, PostState>(
|
|
builder: (context, state) {
|
|
return state.when(
|
|
initial: () => const SizedBox.shrink(),
|
|
loading: () => const Center(child: CircularProgressIndicator()),
|
|
loaded: (posts) => ListView.builder(
|
|
itemCount: posts.length,
|
|
itemBuilder: (ctx, i) => ListTile(
|
|
title: Text(posts[i].title),
|
|
subtitle: Text(posts[i].body),
|
|
onTap: () {
|
|
AutoRouter.of(
|
|
context,
|
|
).push(PostDetailsRoute(post: posts[i]));
|
|
},
|
|
),
|
|
),
|
|
failure: (msg) => Center(child: Text('Error: $msg')),
|
|
);
|
|
},
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|