import 'dart:async'; import 'package:flutter/material.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:traderscircuit/Utils/Common/CommonAppbar.dart'; import 'package:traderscircuit/Utils/Common/sized_box.dart'; import 'package:traderscircuit/Utils/text.dart'; import 'package:traderscircuit/model/Notification/notification_model.dart'; import 'package:traderscircuit/view_model/Notification/notification_api.dart'; class NotificationScreen extends StatefulWidget { const NotificationScreen({super.key}); @override State createState() => _NotificationScreenState(); } class _NotificationScreenState extends State { StreamController NotificationController = StreamController(); @override Widget build(BuildContext context) { return Scaffold( backgroundColor: Colors.black, appBar: CommonAppbar(titleTxt: ''), body: StreamBuilder( stream: NotificationController.stream, builder: (ctx, snapshot) { if (snapshot.data == null) { return Text("data"); } if (snapshot.connectionState == ConnectionState.done) { if (snapshot.hasError) { return Center( child: Text( '${snapshot.error} occured', style: TextStyle(fontSize: 18.spMin), ), ); } } return notificationobj!.data!.list!.isEmpty ? Center(child: _buildNodataBody()) : _buildBody(context); }, ), ); } Widget _buildNodataBody() { return // Scaffold( // body: Column( crossAxisAlignment: CrossAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.center, children: [ // Lottie.asset('assets/logos/NoDataFoundLottie.json'), text25W600( "No Data Available", // textAlign: TextAlign.center, ), ], ); } // 'assets/images/png/Ellipse 1494.png' Widget notificationCard({ required String profileimg, required String title, required String subtitle, required String time, }) { return Padding( padding: EdgeInsets.symmetric(horizontal: 12.w), child: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Row( children: [ CircleAvatar( backgroundImage: AssetImage(profileimg), radius: 26.5.r, ), sizedBoxWidth(12.w), Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ text14W400(title), text12W500_B4B4B4(subtitle), ], ), ], ), text12W500(time), ], ), ); } Widget _buildBody(context) { return SingleChildScrollView( child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Padding( padding: EdgeInsets.only(left: 16.w), child: text25W600('Notifications'), ), sizedBoxHeight(40.h), Padding( padding: EdgeInsets.only(left: 16.w), child: text16W400('Today'), ), sizedBoxHeight(25.h), notificationCard( profileimg: 'assets/images/png/Ellipse 591.png', title: 'Mokshada Kesarkar', subtitle: 'Lorem ipsum dolor sit amet cons......', time: '30 mins ago'), Container( height: 1, margin: EdgeInsets.symmetric(vertical: 20.h), decoration: BoxDecoration( border: Border( bottom: BorderSide( color: Color.fromRGBO(176, 176, 176, 0.5), width: 1, ), ), ), ), notificationCard( profileimg: 'assets/images/png/Ellipse 588.png', title: 'Mokshada Kesarkar', subtitle: 'Lorem ipsum dolor sit amet cons......', time: '1 Hour ago'), sizedBoxHeight(30.h), Padding( padding: EdgeInsets.only(left: 16.w), child: text16W400('Yesterday'), ), sizedBoxHeight(30.h), ListView.builder( physics: NeverScrollableScrollPhysics(), shrinkWrap: true, itemCount: CardList.length, itemBuilder: (context, index) { return Column( children: [ notificationCard( profileimg: CardList[index]['profileimg']!, title: CardList[index]['title']!, subtitle: CardList[index]['subtitle']!, time: CardList[index]['time']!), if (index != CardList.length - 1) Container( height: 1, margin: EdgeInsets.symmetric(vertical: 20.h), decoration: BoxDecoration( border: Border( bottom: BorderSide( color: Color.fromRGBO(176, 176, 176, 0.5), width: 1, ), ), ), ), ], ); }, ), sizedBoxHeight(40.h), ], ), ); } List> CardList = [ { 'profileimg': 'assets/images/png/Ellipse 588.png', 'title': 'Mokshada Kesarkar', 'subtitle': 'Lorem ipsum dolor sit amet cons......', 'time': '1 day ago' }, { 'profileimg': 'assets/images/png/Ellipse 591.png', 'title': 'Afrid Mulla', 'subtitle': 'Lorem ipsum dolor sit amet cons......', 'time': '1 day ago' }, { 'profileimg': 'assets/images/png/Ellipse 588.png', 'title': 'Mokshada Kesarkar', 'subtitle': 'Lorem ipsum dolor sit amet cons......', 'time': '2 days ago' }, { 'profileimg': 'assets/images/png/Ellipse 591.png', 'title': 'Afrid Mulla', 'subtitle': 'Lorem ipsum dolor sit amet cons......', 'time': '3 days ago' }, ]; }