Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

The named parameter ' ' isnt defined

I’m getting errors in my flutter app after an upgrade to flutter 3.3.6. The named parameters which throws errors as ‘aren’t defined’ : elevation, color, shape

The snippet where i get the errors is listed below :

return ButtonTheme(
  minWidth: 110,
  child: RaisedButton(
      elevation: 0,
      child: isLoading
          ? _buildLoadingIndicatorWithColor(textColor)
          : Text(
              text,
              style: TextStyle(
                  color: textColor,
                  fontWeight: FontWeight.bold,
                  fontSize: 16),
            ),
      color: communityColor,
      onPressed: onPressed,
      shape: new RoundedRectangleBorder(
          borderRadius: BorderRadius.circular(borderRadius))),
);

}

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

Here is another snippet where a similar error appears and the textColor parameter throws the same error :

return ButtonTheme(
  minWidth: minWidth,
  height: height,
  child: FlatButton(
    textColor: Colors.black87,
    child: this.child,
    onPressed: this.onPressed,
  ),
);

As per the following documentation I read https://docs.flutter.dev/release/breaking-changes/buttons, there are changes that are needed to make it work. Help appreciated as I’m very new to flutter and a beginner to programming

>Solution :

RaisedButton is deprecated. You can use ElevatedButton(). Please check below code.

ButtonTheme(
      minWidth: 110,
      child: ElevatedButton(
        style: ElevatedButton.styleFrom(
          elevation: 0,
          backgroundColor: communityColor,
          shape: new RoundedRectangleBorder(),
        ),
        child: isLoading
            ? _buildLoadingIndicatorWithColor(textColor)
            : Text(
                text,
                style: TextStyle(color: textColor, fontWeight: FontWeight.bold, fontSize: 16),
              ),
        onPressed: onPressed,
      ),
    );
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading