I am implementing a custom app bar and I want to add optional widget to action: [] property in AppBar Widget. But when I insert the widget inside the action widget list I am getting an error which says

I am implementing a custom app bar and I want to add optional widget to action: [] property in AppBar Widget. But when I insert the widget inside the action widget list I am getting an error which says