Files
cherrypick/examples/postly/lib/presentation/pages/posts_page.dart
Sergey Penkovsky efed72cc39 refactor(core,logger)migrate to CherryPickObserver API and drop CherryPickLogger
BREAKING CHANGE:
- Removed the deprecated CherryPickLogger interface from cherrypick
- Logger/adapters (e.g., talker_cherrypick_logger) must now implement CherryPickObserver
- talker_cherrypick_logger: replace TalkerCherryPickLogger with TalkerCherryPickObserver
- All usages, docs, tests migrated to observer API
- Improved test mocks and integration tests for observer pattern
- Removed obsolete files: cherrypick/src/logger.dart, talker_cherrypick_logger/src/talker_cherrypick_logger.dart
- Updated README and example usages for new CherryPickObserver model

This refactor introduces a unified observer pattern (CherryPickObserver) to handle all DI lifecycle events, replacing the limited info/warn/error logger pattern.
All external logging adapters and integrations must migrate to use CherryPickObserver.
2025-08-12 00:29:41 +03:00

54 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')),
);
},
),
),
);
}
}