[英]Flutter `1 positional argument(s) expected, but 0 found.`
I've downloaded project from github and this is the error, 1 positional argument(s) expected, but 0 found.我从 github 下载了项目,这是错误,预期 1 个位置参数,但找到了 0 个。
This is my main.dart这是我的主要。dart
class GameWrapper extends StatelessWidget {
final FlutterBirdGame flutterBirdGame;
GameWrapper(this.flutterBirdGame);
@override
Widget build(BuildContext context) {
return flutterBirdGame.widget;
}
}
class Singleton {
Size screenSize;
Singleton._privateConstructor();
static final Singleton instance = Singleton._privateConstructor();
}
void main() async {
// initial settings
WidgetsFlutterBinding.ensureInitialized();
Flame.audio.disableLog();
SystemChrome.setPreferredOrientations([DeviceOrientation.portraitUp]);
SystemChrome.setEnabledSystemUIOverlays([]);
var sprite = await Flame.images.loadAll(["sprite.png"]);
var screenSize = await Flame.util.initialDimensions();
Singleton.instance.screenSize = screenSize;
var flutterBirdGame = FlutterBirdGame(sprite[0], screenSize);
runApp(MaterialApp(
title: 'myfirstgame',
home: GestureDetector(
onTapDown: (TapDownDetails evt) => flutterBirdGame.onTap(),
child: Scaffold(
body: GameWrapper(flutterBirdGame),
),
),
));
}
widget_test.dart i am getting error from this line, its say Try adding the missing arguments.dart(not_enough_positional_arguments) but i dont know how to pass argument. widget_test.dart 我从这行得到错误,它说尝试添加缺少的 arguments.dart(not_enough_positional_arguments) 但我不知道如何传递参数。
await tester.pumpWidget(GameWrapper()); //
Your GameWrapper
class needs FlutterBirdGame
instance in it's constructor, try to add it:您的
GameWrapper
class 在其构造函数中需要FlutterBirdGame
实例,尝试添加它:
final birdGame = // init FlutterBirdGame variable
await tester.pumpWidget(GameWrapper(birdGame));
Your GameWrapper
class requires FlutterBirdGame
object: Try to do like this:您的
GameWrapper
class 需要FlutterBirdGame
object:尝试这样做:
final flutterBirdGame = new FlutterBirdGame();
await tester.pumpWidget(GameWrapper(flutterBirdGame));
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.