Home > Enterprise >  The named parameter 'textStyle' isn't defined
The named parameter 'textStyle' isn't defined

Time:03-22

How to fix this error. Someone can help me? enter image description here

@override
  Widget build(BuildContext context) {    
    return Column(
      children: <Widget>[         
        AspectRatio(
          aspectRatio: 1.70,
          child: Container(     
            height: 250,
            padding: EdgeInsets.all(20),
            child: LineChart(
              mainData(),
            ),
          ),
        ),  
      ],
    );
  }

  LineChartData mainData() {
    return LineChartData(
      gridData: FlGridData(
        show: true,
        drawVerticalLine: true,
        getDrawingHorizontalLine: (value) {
          return FlLine(
            color: Color.fromRGBO(0, 0, 0, 0.3),
            strokeWidth: 1,
          );
        },
        getDrawingVerticalLine: (value) {
          return FlLine(
            color: Color.fromRGBO(0, 0, 0, 0.3),
            strokeWidth: 1,
          );
        },
      ),
      titlesData: FlTitlesData(
        show: true,        
        bottomTitles: SideTitles(
          showTitles: true,          
          reservedSize: 10,      
          rotateAngle: -90,    
          textStyle: const TextStyle(color: Color(0xff68737d), 
 fontWeight: FontWeight.bold, fontSize: 10),
          getTitles: (value) { //ERROR textStyle

CodePudding user response:

SideTitle's textStyle property changed to getTextStyles getter (it gives you the axis value, and you must return a TextStyle based on it), It helps you to have a different style for specific text, check it in 0.12.0. Therefore, try:

 getTextStyles: (BuildContext context, double v) {
   return TextStyle(color: Color(0xff68737d), fontWeight: FontWeight.bold, fontSize: 10);
},

CodePudding user response:

After flutter update the textStyle is changed to getTextStyles. Try below code, hope its help to you. Refer SideTitles

SideTitles(
 showTitles: true,          
 reservedSize: 10,      
 rotateAngle: -90,  
  getTextStyles: (BuildContext context, double v) {
   return TextStyle(color: Color.red,
          fontWeight: FontWeight.bold,
          fontSize: 15,
        );
    },
),
  • Related