Advertisement
AbiMulya

Post content notif without pull refresh

Nov 24th, 2021
1,201
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Dart 1.45 KB | None | 0 0
  1. part of 'notification_page.dart';
  2.  
  3. class PostsContentView extends StatelessWidget {
  4.   const PostsContentView({
  5.     Key? key,
  6.     this.notif,
  7.   }) : super(key: key);
  8.  
  9.   final Notif? notif;
  10.  
  11.   @override
  12.   Widget build(BuildContext context) {
  13.     debugPrint('Build: $runtimeType');
  14.     final _refreshController = RefreshController(initialRefresh: false);
  15.  
  16.     if (notif != null && notif!.data.isEmpty) {
  17.       return PullRefreshWidget(
  18.           controller: _refreshController,
  19.           onRefresh: () {
  20.             context.read<UserNotificationCubit>().fetchUserNotification();
  21.             _refreshController.refreshCompleted();
  22.           },
  23.           child: const InfoWidgetNoData());
  24.     } else {
  25.       if (notif != null) {
  26.         return PullRefreshWidget(
  27.           controller: _refreshController,
  28.           onRefresh: () {
  29.             context.read<UserNotificationCubit>().fetchUserNotification();
  30.             _refreshController.refreshCompleted();
  31.           },
  32.           child: ListView.builder(
  33.             itemBuilder: (BuildContext context, int index) {
  34.               return ContentWidgetNotif(
  35.                 title: notif!.data[index].title ?? '-',
  36.                 message: notif!.data[index].message ?? '-',
  37.                 datetime: notif!.data[index].createdDatetime!,
  38.               );
  39.             },
  40.             itemCount: notif!.data.length,
  41.           ),
  42.         );
  43.       }
  44.  
  45.       return const SizedBox();
  46.     }
  47.   }
  48. }
  49.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement