I'm trying to make a Flutter app that can respond to a tap anywhere on the screen, using a GestureDetector
. Here's my code:
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: "App",
home: MyScreen(),
);
}
}
class MyScreen extends StatefulWidget {
@override
State createState() => MyScreenState();
}
class MyScreenState extends State<MyScreen> {
String _text = "Hello";
@override
Widget build(BuildContext context) {
_onTapUp(TapUpDetails details) {
var x = details.globalPosition.dx;
var y = details.globalPosition.dy;
print("tap up " + x.toString() + ", " + y.toString());
setState(() {
_text = "Hello world";
});
}
return GestureDetector(
onTapUp: _onTapUp,
child: Scaffold(
appBar: AppBar(
title: Text("App")
),
body: Text(_text),
),
);
}
}
However, when I run the app an error appears on the bottom of the simulator saying BOTTOM OVERFLOWED BY Infinity PIXELS
. The app appears to be functioning, but the error at the bottom is an eyesore. How can I resolve it?