Home > Mobile >  "The named parameter 'child' isn't defined." in TextButton Widget
"The named parameter 'child' isn't defined." in TextButton Widget

Time:10-25

I want to add a TextButton to my code... But my IDE is showing me, that the parameter child in die TextButton Widget isn't definded... But in the official Flutter-Documents you add Text to a TextButton by the child parameter. This is my code:

Column(
          crossAxisAlignment: CrossAxisAlignment.end,
          children: actions
              .map((action) => TextButton(
                    
                    style: TextButton.styleFrom(
                      foregroundColor: action.textColor ?? Theme.of(context).primaryColor,
                    ),
                    onPressed: () => Navigator.pop(context, action.popResult),
                    child: Text(action.title.toUpperCase()),
                  ))
              .toList(),
        )

Hope that somebody can help me with this issue.

CodePudding user response:

I think the problem is not in the child property but in the foregroundColor of the TextButton#styleFrom function because foregroundColor is a property that calculates the value based on the onSurface or primary arguments and you cannot set it directly

  • Related