我对颤振和飞镖仍然很陌生,但我目前正在尝试返回一个未来的小部件,它是我在 StatefulWidget 内的主要游戏,我想知道我是否需要使用未来的构建器,或者是否有其他方法可以做到这一点?
import 'package:flutter/material.dart';
import 'package:shared_preferences/shared_preferences.dart';
import 'package:untitled2/screens/game.dart';
class GamePlay extends StatefulWidget {
GamePlay({Key key}) : super(key: key);
@override
_GamePlayState createState() => _GamePlayState();
}
class _GamePlayState extends State<GamePlay> {
@override
Widget build(BuildContext context) async { // THIS IS WHERE IT SAYS THE PROBLEM IS
SharedPreferences storage = await SharedPreferences.getInstance();
MainGame mainGame = MainGame(storage);
return Scaffold(
body: mainGame.widget,
);
}
}