![](/img/trans.png)
[英]How can i clear my recyclerView data? I have tried a lot of stuff from same type of questions but nothing has helped me
[英]"The method 'SplashScreen' isn't defined for the type 'MyApp'.". I have tried a lot of things and nothing. Any solution?
主要飞镖:
import 'package:flutter/material.dart' show BuildContext, Colors, MaterialApp, StatelessWidget, ThemeData, VisualDensity, Widget, runApp;
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
// This widget is the root of your application.
Widget build(BuildContext context) {
return MaterialApp(
debugShowCheckedModeBanner: false,
// Application name
title: 'UranteX',
theme: ThemeData(
primarySwatch: Colors.red,
visualDensity: VisualDensity.adaptivePlatformDensity,
),
home: SplashScreen());
}
splashScreen.dart(第 2 页)
import 'package:flutter/material.dart' show BuildContext, Center, Column, Container, CrossAxisAlignment, Image, MainAxisAlignment, Scaffold, SizedBox, State, StatefulWidget, Widget;
class SplashScreen extends StatefulWidget {
@override
_SplashScreenState createState() => _SplashScreenState();
}
class _SplashScreenState extends State<SplashScreen> {
@override
Widget build(BuildContext context) {
return Scaffold(
body: Container(
height: double.infinity,
width: double.infinity,
child: Center(
child: Column(crossAxisAlignment: CrossAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.center, children: [
SizedBox(
height: 300.0,
child: Image.asset('Images/logo.png'),
)
]),
),
),
);
}
}
///代码不起作用,它说“方法'SplashScreen'没有为类型'MyApp'定义”。 我知道解决方案可能在“容器”上,但我无法解决。
解决方案:您必须将 splashScreen.dart 文件导入 main.dart 问题原因:您正在调用另一个文件中的 SplashScreen 类,因此 main.dart 文件将如何知道那里的 SplashScreen 所以您需要导入 splashscreen .dart 文件,以便 main.dart 知道 SplashScreen 是 splashScreen.dart 文件中的一个类。
如果您仍然有疑问,那么您可以询问您是否满意,然后给这个答案一个赞成票,以便更多人了解这一点。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.