So I am currently trying to figure out a way to give a color to a certain card depending on which subject the user has selected. I am usifier a notifier. Previously in my code, I was able to refer to look for a precise image that would be related to the topic that the user choose and it worked using this code here:
@override
Widget build(BuildContext context) {
return Consumer<FlashcardsNotifier>(
builder: (_, notifier,__)=> Scaffold(
appBar: AppBar(
actions: <Widget>[
Padding(padding: const EdgeInsets.all(8.0),
child: Hero(
tag: notifier.topic,
child: Image.asset("images/${notifier.topic}.png"))),
],
title: Text(notifier.topic, style: TextStyle(color: Color.fromARGB(248, 70, 65, 65)),)
,
),
body: IgnorePointer(
ignoring: notifier.ingnoreTouches,
child:
Stack(
children: [
Card2(),
Card1(),
],
),
),
),
//),
);
}
}
However if I try to do the same thing with the Color Widget it is not working because I think it is not able to use a String.
child: Container(
width: size.width *0.80,
height: size.height*0.60,
decoration: BoxDecoration(
color: Colors.white,
border: Border.all(
color: {notifier.topic};
),
boxShadow: [
BoxShadow(
color: Market.withOpacity(0.3),
spreadRadius: 5,
blurRadius: 7,
offset: Offset(0, 3), // changes position of shadow
),
],
),
),
I created constants of colors with the same name as the topics but my notifier.topic.
const Color Market = Color.fromARGB(255, 215, 165, 30);
const Color School = Color.fromARGB(255, 215, 117, 11);
const Color Farm = Color.fromARGB(255, 65, 106, 208);`your text`
const Color Garden = Color.fromARGB(255, 29, 136, 38);
const Color House = Color.fromARGB(255, 197, 53, 53);
const Color Temple = Color.fromARGB(255, 103, 32, 91);
Can anyone help it would be really appreciated.
I am hoping that someone can help me solve this issue.
This is how you define colors