I have been trying to create an Onboarding view with the next and previous Text Button() where when the user is in the first index of the Onboarding the previous button should be unclickable.
I already did it by making onPressed: function return Null when the onboarding current index = 0 but the problem is the previous's text doesn't appear when I use dark mode. I hope someone can help me.
Previou's TextButton code:
TextButton(
onPressed: cubit.currentIndex != 0
? () {
cubit.decrement();
boardController.previousPage(
duration:
const Duration(milliseconds: 300),
curve: Curves.fastLinearToSlowEaseIn,
);
}
: null,
child: const Text(
'Previous',
style: TextStyle(
fontSize: 18,
)),
Here in the light mode everything is okay I wanna show this in dark mode
CodePudding user response:
use Brigthness for color
style: TextStyle(
fontSize: 18,
color: Theme.of(context).brightness == Brightness.dark
? Colors.green
: null,
)),
CodePudding user response:
if you don't want to use Previous text on first onboarding screen then use following structure :
child: FlatButton(
child: Text(
currentIndex == slides.length - 1 ? "": "Previous"),)
Or if you don't want to use Previous Button on first onboarding screen then use following structure :
child:
currentIndex == slides.length - 1 ? null :
FlatButton(
child: Text(
"Previous"),)
