Created
January 9, 2023 02:23
-
-
Save tushar4303/496dd6fcbcbda888baea143eba6697ff to your computer and use it in GitHub Desktop.
Snippet from my code from the filter section
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//For filterchip row and i am clearing filtered list in init state | |
onSelected: ((value) { | |
setState(() { | |
if (value) { | |
_filters.add(filterType); | |
} else { | |
_filters.removeWhere((name) { | |
return name == filterType; | |
}); | |
} | |
_filteredNotifications.clear(); | |
if (_filters | |
.contains("Academics")) { | |
setState(() { | |
showFrom = true; | |
}); | |
} else { | |
setState(() { | |
showFrom = false; | |
}); | |
} | |
if (_filters.isEmpty) { | |
_filteredNotifications.addAll( | |
NotificationModel | |
.notifications!); | |
} else { | |
_filteredNotifications.addAll( | |
NotificationModel | |
.notifications! | |
.where((notification) => | |
_filters.contains( | |
notification | |
.notificationLabel))); | |
} | |
}); | |
}))); | |
}).toList()), | |
), | |
], | |
), | |
), | |
) | |
: const Center( | |
child: CircularProgressIndicator( | |
color: Colors.white, | |
)), | |
], | |
), | |
), | |
), | |
body: Column( | |
children: [ | |
Container( | |
child: errmsg("No Internet Connection Available", isoffline), | |
//to show internet connection message on isoffline = true. | |
), | |
Expanded( | |
child: Padding( | |
padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 8), | |
child: FutureBuilder( | |
future: myfuture, | |
builder: ((context, snapshot) { | |
if (snapshot.connectionState == ConnectionState.done) { | |
if (snapshot.hasData) { | |
return RefreshIndicator( | |
onRefresh: () async { | |
loadNotifications(); | |
}, | |
child: Padding( | |
padding: const EdgeInsets.only(bottom: 54), | |
child: ListView.builder( | |
itemCount: _filteredNotifications.length, | |
itemBuilder: (context, index) { | |
return NotificationWidget( | |
notification: | |
_filteredNotifications[index], | |
); | |
}), | |
), | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment