当我运行我的 Flutter 应用程序时,我的 IOS 模拟器出现错误。
<块引用>有问题的小部件是:FutureBuilder 构建函数绝不能返回 null。要返回导致建筑小部件填充可用空间的空白空间,请返回“Container()”。要返回占用尽可能少空间的空白空间,请返回“new Container(width: 0.0, height: 0.0)
void main(){
WidgetsFlutterBinding.ensureInitialized();
runApp(App());
}
class App extends StatelessWidget {
final Future<FirebaseApp> _initialization = Firebase.initializeApp();
@override
Widget build(BuildContext context) {
return MaterialApp(
theme: ThemeData(
primaryColor: Color(0xFF6A8D73),
primaryColorDark: Color(0xFF475E4D),
accentColor: Color(0xffCFE8D5),
primaryColorLight: Colors.white
),
home: FutureBuilder(
future: _initialization,
builder: (context, snapshot){
if (snapshot.hasError) {
print(snapshot.error);
return null;
}
if (snapshot.connectionState == ConnectionState.done) {
return HomePage();
}
return Splash();
},
)
);
}
}
class HomePage extends StatelessWidget {
@override
Widget build(BuildContext context) {
return ChangeNotifierProvider(
create: (_) => UserRepository.instance(),
child: Consumer(
builder: (context, UserRepository user, _){
switch(user.status){
case Status.Uninitialized:
return Splash();
case Status.Unauthenticated:
case Status.Authenticating:
return LoginPage();
case Status.Authenticated:
return TaskBar();
default:
return null;
}
},
),
);
}
}
class Splash extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Material(
child: Center(
child: Text("Splash Screen"),
),
);
}
}
答案 0 :(得分:0)
你只需要在你检查错误的地方替换下面的代码-
<script src="https://unpkg.com/@arction/xydata@1.4.0/dist/xydata.iife.js"></script>
<script src="https://unpkg.com/@arction/lcjs@3.0.0/dist/lcjs.iife.js"></script>