I was developing a GYM Management System using Andriod studio and VS code. So I was having this problem in my coding. Both 'color' and 'shape' named parameter isn't defined.
can anyone help me out?
import 'package:flutter/material.dart';
import 'package:my_gym_manager/config/palette.dart';
class CustomCardRE extends StatelessWidget {
final String imagePath;
final String type;
final Function add;
final Function view;
CustomCardRE({this.imagePath, this.type, this.add, this.view});
@override
Widget build(BuildContext context) {
return Card(
elevation: 5,
margin: EdgeInsets.all(8.0),
color: Colors.grey[350],
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(10.0),
),
child: Column(
children: [
Image.asset(
imagePath,
width: 84.0,
),
Text(
type,
style: TextStyle(
color: Colors.black,
fontWeight: FontWeight.bold,
fontSize: 20.0),
),
TextButton(
color: Palette.secondaryColor,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(18.0),
),
onPressed: view,
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Icon(
Icons.list_alt,
color: Colors.white,
size: 40.0,
),
Text(
'View $type',
style: TextStyle(
fontSize: 20,
fontWeight: FontWeight.w700,
color: Colors.white,
),
),
],
),
),
TextButton(
color: Palette.secondaryColor,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(18.0),
),
onPressed: add,
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Icon(
Icons.add_circle_outline,
color: Colors.white,
size: 40.0,
),
Text(
'Add New $type',
style: TextStyle(
fontSize: 20,
fontWeight: FontWeight.w700,
color: Colors.white,
),
),
],
),
),
],
),
);
}
}
The part where I was having trouble are here:
TextButton(
color: Palette.secondaryColor,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(18.0),
),
onPressed: view,
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Icon(
Icons.list_alt,
color: Colors.white,
size: 40.0,
),
TextButton(
color: Palette.secondaryColor,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(18.0),
),
onPressed: add,
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Icon(
Icons.add_circle_outline,
color: Colors.white,
size: 40.0,
),
This is the screenshot of the problem:
CodePudding user response:
in TextButton you can provide the color and shape in the style
property, like this:
TextButton(
onPressed: () {},
child: Text(""),
style: ButtonStyle(
backgroundColor:
MaterialStatePropertyAll(Colors.white),
shape: MaterialStatePropertyAll(
RoundedRectangleBorder(
borderRadius: BorderRadius.circular(18.0),
),
),
),
),