You do not have a Flex
ancestor.
An Expanded widget must be a descendant of a Row, Column, or Flex, and the path from the Expanded widget to its enclosing Row, Column, or Flex must contain only StatelessWidgets or StatefulWidgets (not other kinds of widgets, like RenderObjectWidgets).
I am not sure about the need for Expanded
in your case. But removing it or wrapping it in a Column
should fix the problem.