You are getting the error due to the Expanded widget.
Typically, Expanded widgets are placed directly inside Flex widgets.
Either remove the Expanded Widget or Wrap the Expanded Widget with a Column or Row like the following code :
class _AppBarButton extends StatelessWidget {
final String title;
final Function onTap;
const _AppBarButton({
Key key,
this.title,
this.onTap,
}) : super(key: key);
@override
Widget build(BuildContext context) {
return GestureDetector(
onTap: onTap,
child: Column(
children: [
Expanded(
child: Text(
title,
style: const TextStyle(
color: Colors.black,
fontSize: 16.0,
fontWeight: FontWeight.w600,
),
),
),
],
),
);
}
}
CLICK HERE to find out more related problems solutions.