The code below is my button part code.
When this button is clicked, I want to display the color of the border of the bookmarked buttons on the "Page Selection Page (code below)" to change color.
Actually the most important part is using shared_preferences: ^2.0.7 to make it stored locally.
I've seen and tried several examples, but I'm struggling on the 4th day.
bool recognizing = false;
...
actions: <Widget>[
IconButton(
onPressed: recognizing ?
Function for Remove from Favorites : function to add to favorites,
icon: recognizing
? Icon(Icons.bookmark_rounded, color: Colors.yellow[800], size: 30) //그대로일때
: Icon(Icons.bookmark_add_outlined, color: Colors.yellow[800],size: 30),
),
],
Below is the button code. In the previous "Page Selection Page", call and use the code below as child:LearnLevelButton().
class LearnLevelButton extends StatelessWidget {
LearnLevelButton({
Key ?key,
this.text = '',
this.width = 80.0,
this.height = 80.0,
this.borderRadius = 50.0,
required this.onTap,
}) : super(key: key);
final String text;
final VoidCallback onTap;
final double width;
final double height;
final double borderRadius;
@override
Widget build(BuildContext context) {
var gradient = LinearGradient(
begin: Alignment.topCenter, // new
end: Alignment.bottomCenter, // new
colors: [
//Color(0xff9cbbf6),
//Color(0xff9cbbf6),linkwell
Color(0xff7ba6f9),
Color(0xff7ba6f9),
],
);
return InkWell(
onTap: onTap,
child: Center(
child: Padding(
padding: const EdgeInsets.only(
top: 20.0,
bottom: 20.0,
left: 22.0,
right: 22.0,
),
child: Container(
padding: const EdgeInsets.all(3.0),
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(borderRadius),
border: Border.all(
width: 0.3,
color: Colors.black38,
),
boxShadow: [
BoxShadow(
blurRadius: 10.0,
offset: Offset(5.0, 5.0),
color: Color.fromRGBO(0, 0, 0, 0.3),
),
],
gradient: gradient,
),
width: width,
height: height,
child: Container(
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(borderRadius),
border: Border.all(
width: 0.3,
color: Colors.black26,
),
boxShadow: [
BoxShadow(
blurRadius: 1.0,
offset: Offset(1.0, 1.5),
color: Color.fromRGBO(0, 0, 0, 0.3),
),
],
gradient: gradient,
),
child: Center(
child: Text(
text,
style: TextStyle(
color: Colors.white,
fontSize: 20.0, fontWeight: FontWeight.bold,
),
),
),
),
),
),
),
);
}
}