我正在尝试制作一个 Flutter 应用程序,它可以使用GestureDetector
. 这是我的代码:
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),
),
);
}
}
但是,当我运行该应用程序时,模拟器底部会出现一个错误,提示BOTTOM OVERFLOWED BY Infinity PIXELS
. 该应用程序似乎正在运行,但底部的错误令人眼花缭乱。我该如何解决?