notification fixed

This commit is contained in:
Rajshinde046
2024-04-16 19:39:01 +05:30
parent f9d4532884
commit 0b908dc6c6
6 changed files with 50 additions and 42 deletions

View File

@@ -17,6 +17,24 @@ class NotificationScreen extends StatefulWidget {
class _NotificationScreenState extends State<NotificationScreen> {
StreamController<GetNotification> NotificationController = StreamController();
late Timer timer;
@override
void initState() {
// timer = Timer.periodic(Duration(seconds: 2), (timer) {
NotificationsAPI().notificationList(streamControl: NotificationController);
// });
super.initState();
}
@override
void dispose() {
// TODO: implement dispose
NotificationController.close();
timer.cancel();
super.dispose();
}
@override
Widget build(BuildContext context) {
return Scaffold(
@@ -26,7 +44,9 @@ class _NotificationScreenState extends State<NotificationScreen> {
stream: NotificationController.stream,
builder: (ctx, snapshot) {
if (snapshot.data == null) {
return Text("data");
return Center(
child: text25W600("No Notification!"),
);
}
if (snapshot.connectionState == ConnectionState.done) {
if (snapshot.hasError) {
@@ -78,7 +98,7 @@ class _NotificationScreenState extends State<NotificationScreen> {
Row(
children: [
CircleAvatar(
backgroundImage: AssetImage(profileimg),
backgroundImage: NetworkImage(profileimg),
radius: 26.5.r,
),
sizedBoxWidth(12.w),
@@ -107,51 +127,28 @@ class _NotificationScreenState extends State<NotificationScreen> {
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,
itemCount: notificationobj!.data!.list!.length,
itemBuilder: (context, index) {
return Column(
children: [
notificationCard(
profileimg: CardList[index]['profileimg']!,
title: CardList[index]['title']!,
subtitle: CardList[index]['subtitle']!,
time: CardList[index]['time']!),
profileimg: notificationobj!.data!.list!
.elementAt(index)
.notificationImage!,
title: notificationobj!.data!.list!
.elementAt(index)
.notificationMessage!,
subtitle: notificationobj!.data!.list!
.elementAt(index)
.messageName ??
"",
time: notificationobj!.data!.list!
.elementAt(index)
.deliverySchedule ??
""),
if (index != CardList.length - 1)
Container(
height: 1,