{"id":372505,"date":"2024-05-21T05:14:07","date_gmt":"2024-05-21T05:14:07","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=372505"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=372505","title":{"rendered":"<span>\u0420\u0430\u0441\u043f\u043e\u0437\u043d\u0430\u0432\u0430\u043d\u0438\u0435 \u0432\u0438\u0434\u0436\u0435\u0442\u043e\u0432 \u043d\u0430 \u044d\u043a\u0440\u0430\u043d\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f Flutter<\/span>"},"content":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>Hola, Amigos! \u041d\u0430 \u0441\u0432\u044f\u0437\u0438 \u0421\u0430\u0448\u0430 \u0427\u0430\u043f\u043b\u044b\u0433\u0438\u043d, Flutter-dev \u0430\u0433\u0435\u043d\u0442\u0441\u0442\u0432\u0430 \u043f\u0440\u043e\u0434\u0443\u043a\u0442\u043e\u0432\u043e\u0439 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438 Amiga \u0438 \u0441\u043e\u0430\u0432\u0442\u043e\u0440 \u0442\u0435\u043b\u0435\u0433\u0440\u0430\u043c-\u043a\u0430\u043d\u0430\u043b\u0430 <a href=\"https:\/\/t.me\/+YDX3yq4hGLY2NGMy\" rel=\"noopener noreferrer nofollow\"><u>Flutter. \u041c\u043d\u043e\u0433\u043e<\/u><\/a>. \u0421\u0435\u0433\u043e\u0434\u043d\u044f \u043c\u044b \u0432\u043d\u043e\u0432\u044c \u0437\u0430\u0439\u043c\u0435\u043c\u0441\u044f \u043f\u0440\u0430\u043a\u0442\u0438\u043a\u043e\u0439! \u0420\u0430\u0441\u0441\u043a\u0430\u0436\u0443 \u043e\u0431 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e\u0439 \u0442\u0435\u043c\u0435 \u2014 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u043f\u043e\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u043d\u0430 \u044d\u043a\u0440\u0430\u043d\u0435. \u042d\u0442\u043e \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043f\u043e\u043b\u0435\u0437\u043d\u043e, \u043a\u043e\u0433\u0434\u0430 \u043c\u044b \u0445\u043e\u0442\u0438\u043c \u043f\u043e\u043d\u044f\u0442\u044c, \u0432\u0438\u0434\u0435\u043d \u0442\u043e\u0442 \u0438\u043b\u0438 \u0438\u043d\u043e\u0439 \u0432\u0438\u0434\u0436\u0435\u0442 \u043d\u0430 \u044d\u043a\u0440\u0430\u043d\u0435 \u0432 \u0434\u0430\u043d\u043d\u044b\u0439 \u043c\u043e\u043c\u0435\u043d\u0442 \u0438\u043b\u0438 \u043d\u0435\u0442.<\/p>\n<p>\u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u044b\u0439 \u043f\u0440\u0438\u043c\u0435\u0440: \u0432 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0438 \u0435\u0441\u0442\u044c \u0431\u043b\u043e\u043a \u0441 \u0443\u0432\u0435\u0434\u043e\u043c\u043b\u0435\u043d\u0438\u044f\u043c\u0438, \u0438 \u0441\u043e\u0433\u043b\u0430\u0441\u043d\u043e \u0442\u0435\u0445\u043d\u0438\u0447\u0435\u0441\u043a\u043e\u043c\u0443 \u0437\u0430\u0434\u0430\u043d\u0438\u044e, \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043e\u0442\u043f\u0440\u0430\u0432\u0438\u0442\u044c \u0437\u0430\u043f\u0440\u043e\u0441 \u043d\u0430 \u0441\u0435\u0440\u0432\u0435\u0440, \u043a\u043e\u0433\u0434\u0430 \u043f\u043b\u0438\u0442\u043a\u0430 \u0432 \u0441\u043f\u0438\u0441\u043a\u0435 \u0443\u0432\u0435\u0434\u043e\u043c\u043b\u0435\u043d\u0438\u0439 \u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0441\u044f \u0432\u0438\u0434\u0438\u043c\u043e\u0439 \u043d\u0430 \u044d\u043a\u0440\u0430\u043d\u0435, \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u043c\u0435\u0442\u0438\u0442\u044c \u0443\u0432\u0435\u0434\u043e\u043c\u043b\u0435\u043d\u0438\u0435 \u043a\u0430\u043a \u043f\u0440\u043e\u0447\u0438\u0442\u0430\u043d\u043d\u043e\u0435.<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/ad3\/8a9\/56f\/ad38a956f034459f4946ba7cb1faf54e.gif\" width=\"1192\" height=\"666\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/ad3\/8a9\/56f\/ad38a956f034459f4946ba7cb1faf54e.gif\"\/><\/figure>\n<h3>\u041a\u0430\u043a \u0436\u0435 \u044d\u0442\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c?<\/h3>\n<p>\u0414\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u043a\u0430\u0441\u0442\u043e\u043c\u043d\u044b\u0439 \u0432\u0438\u0434\u0436\u0435\u0442 \u0443\u0432\u0435\u0434\u043e\u043c\u043b\u0435\u043d\u0438\u044f. \u0414\u043b\u044f \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u043d\u0430 \u044d\u043a\u0440\u0430\u043d\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u043f\u0430\u043a\u0435\u0442 <a href=\"https:\/\/pub.dev\/packages\/visibility_detector\" rel=\"noopener noreferrer nofollow\"><u>visibility_detector<\/u><\/a>. \u041f\u0440\u0438 \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u0438 \u0434\u0430\u043d\u043d\u043e\u0433\u043e \u043f\u0430\u043a\u0435\u0442\u0430\u00a0 \u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0439\u0442\u0435 UniqueKey, \u0442\u0430\u043a \u043a\u0430\u043a \u0434\u0430\u043d\u043d\u044b\u0439 \u043f\u0430\u043a\u0435\u0442 \u0432\u043a\u043b\u044e\u0447\u0430\u0435\u0442 \u0432 \u0441\u0435\u0431\u044f RenderObject.<\/p>\n<pre><code>import 'package:flutter\/material.dart'; import 'package:hmelbakery\/core\/style\/colors.dart'; import 'package:visibility_detector\/visibility_detector.dart';   class NotificationChip extends StatefulWidget {  NotificationChip({    required this.index,    required this.visibleIndex,    super.key,    this.title = '',    this.text = '',    this.subtitle = '',    this.status = true,  });    final String title;  final int index;  final ValueChanged&lt;int> visibleIndex;  final String text;  final String subtitle;  final bool status;    @override  State&lt;NotificationChip> createState() => _NotificationChipState(); }   class _NotificationChipState extends State&lt;NotificationChip> {  final UniqueKey key = UniqueKey();  late bool _visible;    @override  void initState() {    _visible = widget.status;    super.initState();  }    @override  Widget build(BuildContext context) {    return VisibilityDetector(      onVisibilityChanged: !_visible          ? (visibilityInfo) {              \/\/ \u0417\u0434\u0435\u0441\u044c \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u0442\u0441\u044f \u043d\u0430 \u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0432\u0438\u0434\u0435\u043d \u043e\u0431\u044a\u0435\u043a\u0442 \u0432 \u043f\u0440\u043e\u0446\u0435\u043d\u0442\u0430\u0445              var visiblePercentage = visibilityInfo.visibleFraction * 100;              if (visiblePercentage == 100.0) {                setState(() {                  _visible = true;                });                widget.visibleIndex.call(widget.index); \/\/ \u043f\u0440\u043e\u0447\u0438\u0442\u0430\u043b\u0438              }            }          : null,      key: key,      child: Container(        decoration: BoxDecoration(color: AppColors.grey, borderRadius: BorderRadius.circular(16)),        child: Padding(          padding: const EdgeInsets.all(16),          child: Column(            mainAxisAlignment: MainAxisAlignment.start,            crossAxisAlignment: CrossAxisAlignment.start,            children: [              Row(                mainAxisAlignment: MainAxisAlignment.spaceBetween,                children: [                  Text(                    widget.title,                    style: Theme.of(context).textTheme.titleLarge,                  ),                  if (!_visible)                    Container(                      width: 16,                      height: 16,                      decoration: const BoxDecoration(                        color: AppColors.yellow,                        shape: BoxShape.circle,                      ),                    ),                ],              ),              const SizedBox(height: 8),              Text(widget.text, style: Theme.of(context).textTheme.bodyMedium),              const SizedBox(height: 16),              Text(                widget.subtitle,                style: Theme.of(context).textTheme.bodyMedium?.copyWith(color: AppColors.black400),              ),            ],          ),        ),      ),    );  } }<\/code><\/pre>\n<p>\u041e\u0442\u043e\u0431\u0440\u0430\u0436\u0430\u0435\u043c \u0441\u043f\u0438\u0441\u043e\u043a \u0443\u0432\u0435\u0434\u043e\u043c\u043b\u0435\u043d\u0438\u0439 \u043d\u0430 \u044d\u043a\u0440\u0430\u043d\u0435.<\/p>\n<pre><code>ListView.builder(    padding: const EdgeInsets.symmetric(horizontal: 16),    itemBuilder: (BuildContext context, int index) {      if (index == state.pageState.data.length - 1 &amp;&amp; !state.pageState.loadNewPage) {        context.read&lt;ProfileNotificationsBloc>().add(ProfileNotificationsFetchDataEvent());      }      return Column(        children: [          NotificationChip(            title: state.pageState.data[index].title,            text: state.pageState.data[index].text,            subtitle: DateConverter.formattingDateWTime(state.pageState.data[index].datetime),            status: !(state.pageState.data[index].statusCode == 'unread'),            index: index,            visibleIndex: (int value) {              context                  .read&lt;ProfileNotificationsBloc>()                  .add(ProfileNotificationsMarkReadEvent(index: value)); \/\/ \u043f\u0435\u0440\u0435\u0434\u0430\u0435\u043c \u0432 \u0431\u043b\u043e\u043a \u0438\u043d\u0434\u0435\u043a\u0441 \u043f\u0440\u043e\u0447\u0438\u0442\u0430\u043d\u043e\u0433\u043e             },          ),          const SizedBox(height: 8),          if (index == state.pageState.data.length - 1 &amp;&amp; state.pageState.loadNewPage) ...[            const Center(child: CircularProgressIndicator(color: AppColors.black)),            const SizedBox(height: 20),          ],        ],      );    },    itemCount: state.pageState.data.length,  ),<\/code><\/pre>\n<p>\u0412 \u0431\u043b\u043e\u043a\u0435 \u0441\u043e\u0437\u0434\u0430\u0435\u043c \u0441\u043f\u0438\u0441\u043e\u043a \u043f\u0440\u043e\u0447\u0438\u0442\u0430\u043d\u043d\u044b\u0445 \u0438\u043d\u0434\u0435\u043a\u0441\u043e\u0432 \u0438 \u0442\u0443\u0442 \u0436\u0435 \u043c\u0435\u043d\u044f\u0435\u043c \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u0442\u0435\u0445, \u0447\u0442\u043e \u0443\u0436\u0435 \u043f\u0440\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u043b\u0438, \u0434\u043b\u044f \u0441\u043d\u044f\u0442\u0438\u044f \u0437\u043d\u0430\u0447\u043a\u0430 \u00ab\u043f\u0440\u043e\u0447\u0438\u0442\u0430\u043d\u043d\u043e\u0441\u0442\u0438\u00bb.\u00a0<\/p>\n<pre><code>markRead(ProfileNotificationsMarkReadEvent event, emit) async {  if (!state.pageState.readIndexes.contains(event.index)) {    emit(ProfileNotificationsUp(state.pageState.copyWith(      readIndexes: [...state.pageState.readIndexes, event.index],      data: state.pageState.data..[event.index] = state.pageState.data[event.index].copyWith(statusCode: 'read'),    )));  } }<\/code><\/pre>\n<p>\u0414\u0430\u043b\u0435\u0435 \u043d\u0443\u0436\u043d\u043e \u0440\u0435\u0448\u0438\u0442\u044c \u0437\u0430\u0434\u0430\u0447\u0443, \u043a\u0430\u043a \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e \u043e\u0442\u043f\u0440\u0430\u0432\u0438\u0442\u044c \u043d\u0430 \u0441\u0435\u0440\u0432\u0435\u0440 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e? \u041d\u0435 \u0431\u0443\u0434\u0435\u043c \u0436\u0435 \u043c\u044b \u043a\u0430\u0436\u0434\u044b\u0439 \u043f\u0440\u043e\u0447\u0438\u0442\u0430\u043d\u043d\u044b\u0439 \u0438\u043d\u0434\u0435\u043a\u0441 \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0442\u044c, \u0432\u0435\u0440\u043d\u043e?<\/p>\n<pre><code>Timer? _timer; List&lt;int> _tempList = [];   _timerFunc() { \/\/ \u0441\u0442\u0430\u0440\u0442 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0432 \u0431\u043b\u043e\u043a\u0435  _timer = Timer.periodic(    const Duration(seconds: 1),    (timer) {      if (_tempList.length &lt; state.pageState.readIndexes.length) {        _tempList = state.pageState.readIndexes;        notificationsRepository.markRead(          request: MarkReadNotificationRequest(            notifications: state.pageState.data                .sublist(_tempList.first, _tempList.length > 1 ? _tempList.last : _tempList.first + 1)                .map((e) => e.id)                .toList(),          ),        );      }    },  ); }<\/code><\/pre>\n<p>\u0421\u043e\u0437\u0434\u0430\u0435\u043c \u0442\u0430\u0439\u043c\u0435\u0440, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043a\u0430\u0436\u0434\u0443\u044e \u0441\u0435\u043a\u0443\u043d\u0434\u0443 \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u0442 \u0438\u0437\u043c\u0435\u043d\u0438\u043b\u0441\u044f \u043b\u0438 \u0441\u043f\u0438\u0441\u043e\u043a \u043f\u0440\u043e\u0447\u0438\u0442\u0430\u043d\u043d\u044b\u0445 \u0443\u0432\u0435\u0434\u043e\u043c\u043b\u0435\u043d\u0438\u0439, \u0438 \u0442\u043e\u0433\u0434\u0430 \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u043c \u043d\u0430 \u0441\u0435\u0440\u0432\u0435\u0440. \u041a\u043e\u043d\u0435\u0447\u043d\u043e \u0436\u0435 \u043c\u044b \u043d\u0435 \u0431\u0443\u0434\u0435\u043c \u0437\u0430\u0441\u0442\u0430\u0432\u043b\u044f\u0442\u044c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u0436\u0434\u0430\u0442\u044c \u043e\u0442\u0432\u0435\u0442\u0430 \u0438 \u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u044d\u043a\u0440\u0430\u043d \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u043e\u0439, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043d\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c async\/await.\u00a0<\/p>\n<p>\u0412\u0441\u0451 \u0433\u043e\u0442\u043e\u0432\u043e! \u041d\u0430\u0434\u0435\u044e\u0441\u044c, \u0432\u0430\u043c \u0431\u0443\u0434\u0435\u0442 \u043f\u043e\u043b\u0435\u0437\u043d\u043e. \u0414\u0435\u043b\u0438\u0442\u0435\u0441\u044c <a href=\"https:\/\/t.me\/+SEzLbBTiBkthOTZi\" rel=\"noopener noreferrer nofollow\"><u>\u0432 \u043d\u0430\u0448\u0435\u043c \u0447\u0430\u0442\u0435<\/u><\/a> \u043c\u043e\u0431\u0438\u043b\u044c\u043d\u044b\u0445 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u043e\u0432 \u043e \u0441\u0432\u043e\u0435\u043c \u043e\u043f\u044b\u0442\u0435 \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u043f\u0430\u043a\u0435\u0442\u0430 visibility_detector.\u00a0<\/p>\n<p>\u0410 \u0442\u0430\u043a\u0436\u0435 \u0432\u0441\u0435\u0433\u0434\u0430 \u0436\u0434\u0435\u043c \u0432\u0430\u0441 \u0432 \u043d\u0430\u0448\u0435\u043c \u0442\u0435\u043b\u0435\u0433\u0440\u0430\u043c-\u043a\u0430\u043d\u0430\u043b\u0435 <a href=\"https:\/\/t.me\/+YDX3yq4hGLY2NGMy\" rel=\"noopener noreferrer nofollow\"><u>Flutter. \u041c\u043d\u043e\u0433\u043e<\/u><\/a>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u044b \u0432\u0435\u0434\u0435\u043c \u043a\u043e\u043c\u0430\u043d\u0434\u043e\u0439 \u043c\u043e\u0431\u0438\u043b\u044c\u043d\u044b\u0445 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u043e\u0432. \u0420\u0430\u0441\u0441\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u043c \u043f\u0440\u043e \u0441\u0432\u043e\u0439 \u043b\u0438\u0447\u043d\u044b\u0439 \u043e\u043f\u044b\u0442 \u0438 \u0434\u0435\u043b\u0438\u043c\u0441\u044f \u0441\u043e\u0432\u0435\u0442\u0430\u043c\u0438 \u043e\u0442 \u0441\u043e\u0444\u0442-\u0441\u043a\u0438\u043b\u043b\u043e\u0432 \u0434\u043e \u0442\u0435\u0445\u043d\u0438\u0447\u0435\u0441\u043a\u0438\u0445 \u0437\u043d\u0430\u043d\u0438\u0439. \u041f\u0440\u0438\u0441\u043e\u0435\u0434\u0438\u043d\u044f\u0439\u0442\u0435\u0441\u044c!<\/p>\n<\/div>\n<\/div>\n<\/div>\n<p><!----><!----><\/div>\n<p><!----><!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/articles\/804729\/\"> https:\/\/habr.com\/ru\/articles\/804729\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>Hola, Amigos! \u041d\u0430 \u0441\u0432\u044f\u0437\u0438 \u0421\u0430\u0448\u0430 \u0427\u0430\u043f\u043b\u044b\u0433\u0438\u043d, Flutter-dev \u0430\u0433\u0435\u043d\u0442\u0441\u0442\u0432\u0430 \u043f\u0440\u043e\u0434\u0443\u043a\u0442\u043e\u0432\u043e\u0439 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438 Amiga \u0438 \u0441\u043e\u0430\u0432\u0442\u043e\u0440 \u0442\u0435\u043b\u0435\u0433\u0440\u0430\u043c-\u043a\u0430\u043d\u0430\u043b\u0430 <a href=\"https:\/\/t.me\/+YDX3yq4hGLY2NGMy\" rel=\"noopener noreferrer nofollow\"><u>Flutter. \u041c\u043d\u043e\u0433\u043e<\/u><\/a>. \u0421\u0435\u0433\u043e\u0434\u043d\u044f \u043c\u044b \u0432\u043d\u043e\u0432\u044c \u0437\u0430\u0439\u043c\u0435\u043c\u0441\u044f \u043f\u0440\u0430\u043a\u0442\u0438\u043a\u043e\u0439! \u0420\u0430\u0441\u0441\u043a\u0430\u0436\u0443 \u043e\u0431 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e\u0439 \u0442\u0435\u043c\u0435 \u2014 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u043f\u043e\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u043d\u0430 \u044d\u043a\u0440\u0430\u043d\u0435. \u042d\u0442\u043e \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043f\u043e\u043b\u0435\u0437\u043d\u043e, \u043a\u043e\u0433\u0434\u0430 \u043c\u044b \u0445\u043e\u0442\u0438\u043c \u043f\u043e\u043d\u044f\u0442\u044c, \u0432\u0438\u0434\u0435\u043d \u0442\u043e\u0442 \u0438\u043b\u0438 \u0438\u043d\u043e\u0439 \u0432\u0438\u0434\u0436\u0435\u0442 \u043d\u0430 \u044d\u043a\u0440\u0430\u043d\u0435 \u0432 \u0434\u0430\u043d\u043d\u044b\u0439 \u043c\u043e\u043c\u0435\u043d\u0442 \u0438\u043b\u0438 \u043d\u0435\u0442.<\/p>\n<p>\u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u044b\u0439 \u043f\u0440\u0438\u043c\u0435\u0440: \u0432 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0438 \u0435\u0441\u0442\u044c \u0431\u043b\u043e\u043a \u0441 \u0443\u0432\u0435\u0434\u043e\u043c\u043b\u0435\u043d\u0438\u044f\u043c\u0438, \u0438 \u0441\u043e\u0433\u043b\u0430\u0441\u043d\u043e \u0442\u0435\u0445\u043d\u0438\u0447\u0435\u0441\u043a\u043e\u043c\u0443 \u0437\u0430\u0434\u0430\u043d\u0438\u044e, \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043e\u0442\u043f\u0440\u0430\u0432\u0438\u0442\u044c \u0437\u0430\u043f\u0440\u043e\u0441 \u043d\u0430 \u0441\u0435\u0440\u0432\u0435\u0440, \u043a\u043e\u0433\u0434\u0430 \u043f\u043b\u0438\u0442\u043a\u0430 \u0432 \u0441\u043f\u0438\u0441\u043a\u0435 \u0443\u0432\u0435\u0434\u043e\u043c\u043b\u0435\u043d\u0438\u0439 \u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0441\u044f \u0432\u0438\u0434\u0438\u043c\u043e\u0439 \u043d\u0430 \u044d\u043a\u0440\u0430\u043d\u0435, \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u043c\u0435\u0442\u0438\u0442\u044c \u0443\u0432\u0435\u0434\u043e\u043c\u043b\u0435\u043d\u0438\u0435 \u043a\u0430\u043a \u043f\u0440\u043e\u0447\u0438\u0442\u0430\u043d\u043d\u043e\u0435.<\/p>\n<figure class=\"full-width\"><\/figure>\n<h3>\u041a\u0430\u043a \u0436\u0435 \u044d\u0442\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c?<\/h3>\n<p>\u0414\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u043a\u0430\u0441\u0442\u043e\u043c\u043d\u044b\u0439 \u0432\u0438\u0434\u0436\u0435\u0442 \u0443\u0432\u0435\u0434\u043e\u043c\u043b\u0435\u043d\u0438\u044f. \u0414\u043b\u044f \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u043d\u0430 \u044d\u043a\u0440\u0430\u043d\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u043f\u0430\u043a\u0435\u0442 <a href=\"https:\/\/pub.dev\/packages\/visibility_detector\" rel=\"noopener noreferrer nofollow\"><u>visibility_detector<\/u><\/a>. \u041f\u0440\u0438 \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u0438 \u0434\u0430\u043d\u043d\u043e\u0433\u043e \u043f\u0430\u043a\u0435\u0442\u0430\u00a0 \u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0439\u0442\u0435 UniqueKey, \u0442\u0430\u043a \u043a\u0430\u043a \u0434\u0430\u043d\u043d\u044b\u0439 \u043f\u0430\u043a\u0435\u0442 \u0432\u043a\u043b\u044e\u0447\u0430\u0435\u0442 \u0432 \u0441\u0435\u0431\u044f RenderObject.<\/p>\n<pre><code>import 'package:flutter\/material.dart'; import 'package:hmelbakery\/core\/style\/colors.dart'; import 'package:visibility_detector\/visibility_detector.dart';   class NotificationChip extends StatefulWidget {  NotificationChip({    required this.index,    required this.visibleIndex,    super.key,    this.title = '',    this.text = '',    this.subtitle = '',    this.status = true,  });    final String title;  final int index;  final ValueChanged&lt;int> visibleIndex;  final String text;  final String subtitle;  final bool status;    @override  State&lt;NotificationChip> createState() => _NotificationChipState(); }   class _NotificationChipState extends State&lt;NotificationChip> {  final UniqueKey key = UniqueKey();  late bool _visible;    @override  void initState() {    _visible = widget.status;    super.initState();  }    @override  Widget build(BuildContext context) {    return VisibilityDetector(      onVisibilityChanged: !_visible          ? (visibilityInfo) {              \/\/ \u0417\u0434\u0435\u0441\u044c \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u0442\u0441\u044f \u043d\u0430 \u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0432\u0438\u0434\u0435\u043d \u043e\u0431\u044a\u0435\u043a\u0442 \u0432 \u043f\u0440\u043e\u0446\u0435\u043d\u0442\u0430\u0445              var visiblePercentage = visibilityInfo.visibleFraction * 100;              if (visiblePercentage == 100.0) {                setState(() {                  _visible = true;                });                widget.visibleIndex.call(widget.index); \/\/ \u043f\u0440\u043e\u0447\u0438\u0442\u0430\u043b\u0438              }            }          : null,      key: key,      child: Container(        decoration: BoxDecoration(color: AppColors.grey, borderRadius: BorderRadius.circular(16)),        child: Padding(          padding: const EdgeInsets.all(16),          child: Column(            mainAxisAlignment: MainAxisAlignment.start,            crossAxisAlignment: CrossAxisAlignment.start,            children: [              Row(                mainAxisAlignment: MainAxisAlignment.spaceBetween,                children: [                  Text(                    widget.title,                    style: Theme.of(context).textTheme.titleLarge,                  ),                  if (!_visible)                    Container(                      width: 16,                      height: 16,                      decoration: const BoxDecoration(                        color: AppColors.yellow,                        shape: BoxShape.circle,                      ),                    ),                ],              ),              const SizedBox(height: 8),              Text(widget.text, style: Theme.of(context).textTheme.bodyMedium),              const SizedBox(height: 16),              Text(                widget.subtitle,                style: Theme.of(context).textTheme.bodyMedium?.copyWith(color: AppColors.black400),              ),            ],          ),        ),      ),    );  } }<\/code><\/pre>\n<p>\u041e\u0442\u043e\u0431\u0440\u0430\u0436\u0430\u0435\u043c \u0441\u043f\u0438\u0441\u043e\u043a \u0443\u0432\u0435\u0434\u043e\u043c\u043b\u0435\u043d\u0438\u0439 \u043d\u0430 \u044d\u043a\u0440\u0430\u043d\u0435.<\/p>\n<pre><code>ListView.builder(    padding: const EdgeInsets.symmetric(horizontal: 16),    itemBuilder: (BuildContext context, int index) {      if (index == state.pageState.data.length - 1 &amp;&amp; !state.pageState.loadNewPage) {        context.read&lt;ProfileNotificationsBloc>().add(ProfileNotificationsFetchDataEvent());      }      return Column(        children: [          NotificationChip(            title: state.pageState.data[index].title,            text: state.pageState.data[index].text,            subtitle: DateConverter.formattingDateWTime(state.pageState.data[index].datetime),            status: !(state.pageState.data[index].statusCode == 'unread'),            index: index,            visibleIndex: (int value) {              context                  .read&lt;ProfileNotificationsBloc>()                  .add(ProfileNotificationsMarkReadEvent(index: value)); \/\/ \u043f\u0435\u0440\u0435\u0434\u0430\u0435\u043c \u0432 \u0431\u043b\u043e\u043a \u0438\u043d\u0434\u0435\u043a\u0441 \u043f\u0440\u043e\u0447\u0438\u0442\u0430\u043d\u043e\u0433\u043e             },          ),          const SizedBox(height: 8),          if (index == state.pageState.data.length - 1 &amp;&amp; state.pageState.loadNewPage) ...[            const Center(child: CircularProgressIndicator(color: AppColors.black)),            const SizedBox(height: 20),          ],        ],      );    },    itemCount: state.pageState.data.length,  ),<\/code><\/pre>\n<p>\u0412 \u0431\u043b\u043e\u043a\u0435 \u0441\u043e\u0437\u0434\u0430\u0435\u043c \u0441\u043f\u0438\u0441\u043e\u043a \u043f\u0440\u043e\u0447\u0438\u0442\u0430\u043d\u043d\u044b\u0445 \u0438\u043d\u0434\u0435\u043a\u0441\u043e\u0432 \u0438 \u0442\u0443\u0442 \u0436\u0435 \u043c\u0435\u043d\u044f\u0435\u043c \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u0442\u0435\u0445, \u0447\u0442\u043e \u0443\u0436\u0435 \u043f\u0440\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u043b\u0438, \u0434\u043b\u044f \u0441\u043d\u044f\u0442\u0438\u044f \u0437\u043d\u0430\u0447\u043a\u0430 \u00ab\u043f\u0440\u043e\u0447\u0438\u0442\u0430\u043d\u043d\u043e\u0441\u0442\u0438\u00bb.\u00a0<\/p>\n<pre><code>markRead(ProfileNotificationsMarkReadEvent event, emit) async {  if (!state.pageState.readIndexes.contains(event.index)) {    emit(ProfileNotificationsUp(state.pageState.copyWith(      readIndexes: [...state.pageState.readIndexes, event.index],      data: state.pageState.data..[event.index] = state.pageState.data[event.index].copyWith(statusCode: 'read'),    )));  } }<\/code><\/pre>\n<p>\u0414\u0430\u043b\u0435\u0435 \u043d\u0443\u0436\u043d\u043e \u0440\u0435\u0448\u0438\u0442\u044c \u0437\u0430\u0434\u0430\u0447\u0443, \u043a\u0430\u043a \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e \u043e\u0442\u043f\u0440\u0430\u0432\u0438\u0442\u044c \u043d\u0430 \u0441\u0435\u0440\u0432\u0435\u0440 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e? \u041d\u0435 \u0431\u0443\u0434\u0435\u043c \u0436\u0435 \u043c\u044b \u043a\u0430\u0436\u0434\u044b\u0439 \u043f\u0440\u043e\u0447\u0438\u0442\u0430\u043d\u043d\u044b\u0439 \u0438\u043d\u0434\u0435\u043a\u0441 \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0442\u044c, \u0432\u0435\u0440\u043d\u043e?<\/p>\n<pre><code>Timer? _timer; List&lt;int> _tempList = [];   _timerFunc() { \/\/ \u0441\u0442\u0430\u0440\u0442 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0432 \u0431\u043b\u043e\u043a\u0435  _timer = Timer.periodic(    const Duration(seconds: 1),    (timer) {      if (_tempList.length &lt; state.pageState.readIndexes.length) {        _tempList = state.pageState.readIndexes;        notificationsRepository.markRead(          request: MarkReadNotificationRequest(            notifications: state.pageState.data                .sublist(_tempList.first, _tempList.length > 1 ? _tempList.last : _tempList.first + 1)                .map((e) => e.id)                .toList(),          ),        );      }    },  ); }<\/code><\/pre>\n<p>\u0421\u043e\u0437\u0434\u0430\u0435\u043c \u0442\u0430\u0439\u043c\u0435\u0440, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043a\u0430\u0436\u0434\u0443\u044e \u0441\u0435\u043a\u0443\u043d\u0434\u0443 \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u0442 \u0438\u0437\u043c\u0435\u043d\u0438\u043b\u0441\u044f \u043b\u0438 \u0441\u043f\u0438\u0441\u043e\u043a \u043f\u0440\u043e\u0447\u0438\u0442\u0430\u043d\u043d\u044b\u0445 \u0443\u0432\u0435\u0434\u043e\u043c\u043b\u0435\u043d\u0438\u0439, \u0438 \u0442\u043e\u0433\u0434\u0430 \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u043c \u043d\u0430 \u0441\u0435\u0440\u0432\u0435\u0440. \u041a\u043e\u043d\u0435\u0447\u043d\u043e \u0436\u0435 \u043c\u044b \u043d\u0435 \u0431\u0443\u0434\u0435\u043c \u0437\u0430\u0441\u0442\u0430\u0432\u043b\u044f\u0442\u044c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u0436\u0434\u0430\u0442\u044c \u043e\u0442\u0432\u0435\u0442\u0430 \u0438 \u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u044d\u043a\u0440\u0430\u043d \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u043e\u0439, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043d\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c async\/await.\u00a0<\/p>\n<p>\u0412\u0441\u0451 \u0433\u043e\u0442\u043e\u0432\u043e! \u041d\u0430\u0434\u0435\u044e\u0441\u044c, \u0432\u0430\u043c \u0431\u0443\u0434\u0435\u0442 \u043f\u043e\u043b\u0435\u0437\u043d\u043e. \u0414\u0435\u043b\u0438\u0442\u0435\u0441\u044c <a href=\"https:\/\/t.me\/+SEzLbBTiBkthOTZi\" rel=\"noopener noreferrer nofollow\"><u>\u0432 \u043d\u0430\u0448\u0435\u043c \u0447\u0430\u0442\u0435<\/u><\/a> \u043c\u043e\u0431\u0438\u043b\u044c\u043d\u044b\u0445 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u043e\u0432 \u043e \u0441\u0432\u043e\u0435\u043c \u043e\u043f\u044b\u0442\u0435 \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u043f\u0430\u043a\u0435\u0442\u0430 visibility_detector.\u00a0<\/p>\n<p>\u0410 \u0442\u0430\u043a\u0436\u0435 \u0432\u0441\u0435\u0433\u0434\u0430 \u0436\u0434\u0435\u043c \u0432\u0430\u0441 \u0432 \u043d\u0430\u0448\u0435\u043c \u0442\u0435\u043b\u0435\u0433\u0440\u0430\u043c-\u043a\u0430\u043d\u0430\u043b\u0435 <a href=\"https:\/\/t.me\/+YDX3yq4hGLY2NGMy\" rel=\"noopener noreferrer nofollow\"><u>Flutter. \u041c\u043d\u043e\u0433\u043e<\/u><\/a>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u044b \u0432\u0435\u0434\u0435\u043c \u043a\u043e\u043c\u0430\u043d\u0434\u043e\u0439 \u043c\u043e\u0431\u0438\u043b\u044c\u043d\u044b\u0445 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u043e\u0432. \u0420\u0430\u0441\u0441\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u043c \u043f\u0440\u043e \u0441\u0432\u043e\u0439 \u043b\u0438\u0447\u043d\u044b\u0439 \u043e\u043f\u044b\u0442 \u0438 \u0434\u0435\u043b\u0438\u043c\u0441\u044f \u0441\u043e\u0432\u0435\u0442\u0430\u043c\u0438 \u043e\u0442 \u0441\u043e\u0444\u0442-\u0441\u043a\u0438\u043b\u043b\u043e\u0432 \u0434\u043e \u0442\u0435\u0445\u043d\u0438\u0447\u0435\u0441\u043a\u0438\u0445 \u0437\u043d\u0430\u043d\u0438\u0439. \u041f\u0440\u0438\u0441\u043e\u0435\u0434\u0438\u043d\u044f\u0439\u0442\u0435\u0441\u044c!<\/p>\n<\/div>\n<\/div>\n<\/div>\n<p><!----><!----><\/div>\n<p><!----><!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/articles\/804729\/\"> https:\/\/habr.com\/ru\/articles\/804729\/<\/a><br \/><\/br><\/br><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-372505","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/372505","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=372505"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/372505\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=372505"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=372505"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=372505"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}