Closed MrPresidentWhite closed 3 years ago
this is seems to be happening with your onTap event. and it has nothing to do with flushbar. maybe if you can provide a few lines of code i can help
because of NDA reasons i cant provide no more code
GridView.builder(
physics: NeverScrollableScrollPhysics(),
scrollDirection: Axis.vertical,
shrinkWrap: true,
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: 5,
crossAxisSpacing: 12,
mainAxisSpacing: 12,
childAspectRatio: (itemWidth / itemHeight),
),
itemCount: letters.length,
itemBuilder: (context, index,) {
return TextButton(
onPressed: () => activeNotification ? setLetterGridState(index) : Flushbar(
message: 'settings.section_notifications.deactivated_notification_snackbar_warning',
messageText: Text(
'settings.section_notifications.deactivated_notification_snackbar_warning',
style: TextStyle(
color: Colors.white,
),
).tr(),
margin: EdgeInsets.all(8),
borderRadius: BorderRadius.circular(8),
duration: Duration(seconds: 3),
)..show(context),
style: ButtonStyle(
backgroundColor: activeNotification ? _isSelectedLetterButtonGrid[index] ? MaterialStateProperty.all(Color.fromRGBO(19, 255, 128, 1)) : MaterialStateProperty.all(Colors.white) : MaterialStateProperty.all(Color.fromRGBO(126, 126, 126, 0.2)),
shape: MaterialStateProperty.all<RoundedRectangleBorder>(
RoundedRectangleBorder(
borderRadius: BorderRadius.circular(8),
side: BorderSide(
color: activeNotification ? _isSelectedLetterButtonGrid[index] ? Color.fromRGBO(19, 255, 128, 1) : Color.fromRGBO(151, 151, 151, 1) : Color.fromRGBO(126, 126, 126, 0.2),
),
),
),
),
child: Text(
letters[index],
style: TextStyle(
color: activeNotification ? _isSelectedLetterButtonGrid[index] ? Colors.white : Color.fromRGBO(72, 69, 86, 1) : Color.fromRGBO(126, 126, 126, 0.4),
fontSize: 16,
fontWeight: FontWeight.w500,
letterSpacing: -0.3,
),
),
);
},
),
can you add this:
_showFlush(){
if(activeNotification){
setLetterGridState(index);
} else {
Flushbar(
message: 'settings.section_notifications.deactivated_notification_snackbar_warning',
messageText: Text(
'settings.section_notifications.deactivated_notification_snackbar_warning',
style: TextStyle(
color: Colors.white,
),
).tr(),
margin: EdgeInsets.all(8),
borderRadius: BorderRadius.circular(8),
duration: Duration(seconds: 3),
)..show(context);
}
}
then replace your onPressed: () => with onPressed: (){ _showFlush(); }
it looks like it is working now. At least I don't get this error anymore. many thanks for the help
Hello I have the following problem, in my code I call the flushbar as follows:
onPressed: () => activeNotification ? setLetterGridState(index) : Flushbar(
and if the condition with
setLetterGridState(index)
is active, then the following error is displayed:
Despite the error, everything works as it should. How can I solve this so that this error doesn't come back?