Flutter 构造函数返回类型';动态';那不是';预期类型的t';小部件';。dart(无效的_cast _new _expr)名称';第'页;是在库中定义的
错误出现在第66行itemBuilder:(上下文,索引)=>新页面上( 整个错误如下所示: 构造函数返回的类型“dynamic”不是预期的类型“Widget”.dart(无效的\u cast\u new\u expr) “页面”的名称是在库的“package:datingapp/Screens/Login/pages.dart”和“package:flatter/src/widgets/navigator.dart”中定义的。 尝试对其中一个导入指令使用“as prefix”,或对除一个导入之外的所有导入隐藏名称Flutter 构造函数返回类型';动态';那不是';预期类型的t';小部件';。dart(无效的_cast _new _expr)名称';第'页;是在库中定义的,flutter,Flutter,错误出现在第66行itemBuilder:(上下文,索引)=>新页面上( 整个错误如下所示: 构造函数返回的类型“dynamic”不是预期的类型“Widget”.dart(无效的\u cast\u new\u expr) “页面”的名称是在库的“package:datingapp/Screens/Login/pages.dart”和“package:flatter/src/widgets/navigator.dart”中定义的。 尝试对其中一个导入指令使用“as prefix”,或对除一个导入之
导入'dart:async';
导入“package:datingapp/Screens/Login/pages.dart”;
导入“package:datingapp/Screens/Login/styles.dart”;
进口“包装:颤振/材料.省道”;
导入“包:flifter/services.dart”;
类登录扩展StatefulWidget{
@凌驾
_LoginState createState()=>new_LoginState();
}
类_LoginState使用TickerProviderStateMixin扩展状态{
页面控制器;
var指数=0;
bool-loader=false;
initState(){
super.initState();
控制器=新页面控制器(初始页面:0,保留页面:true);
}
Future\u login()异步{
设置状态(){
加载器=真;
});
Navigator.of(context.pushNamed(“/home”);
设置状态(){
loader=false;
});
}
@凌驾
处置{
controller.dispose();
super.dispose();
}
@凌驾
小部件构建(构建上下文){
SystemChrome.SetSystemEmioVerlayStyle(SystemUiOverlayStyle.dark);
Size screenSize=MediaQuery.of(context).Size;
归还新脚手架(
主体:新容器(
宽度:screenSize.width,
高度:屏幕大小。高度,
填充:新边缘设置。全部(20.0),
装饰:新盒子装饰(图片:背景图片),
子:新列(
//mainAxisAlignment:mainAxisAlignment.space,
儿童:[
新容器(
宽度:screenSize.width,
高度:screenSize.height-200,
子项:新建PageView.builder(
onPageChanged:(值){
设置状态(){
指数=价值;
});
},
控制器:控制器,
itemCount:pages.length,
itemBuilder:(上下文,索引)=>新页面(
viewModel:页面[索引],
),
),
),
新容器(
宽度:120.0,
身高:20.0,
边距:仅限新边集(底部:20.0),
孩子:新的一排(
mainAxisAlignment:mainAxisAlignment.spaceBetween,
子项:pages.map((项){
退回新货柜(
宽度:10.0,
身高:10.0,
装饰:新盒子装饰(
形状:BoxShape.circle,
颜色:页面[索引%4]==项目
?颜色:白色
:颜色。白色70),
);
}).toList()),
),
新扁平按钮(
onPressed:\u登录,
子容器:新容器(
宽度:300.0,
身高:50.0,
对齐:对齐.center,
装饰:新盒子装饰(
颜色:颜色,白色,
边界半径:
新边界半径。全部(新半径。圆形(50.0)),
孩子:!加载器
?新文本(
“使用Facebook登录”,
样式:新文本样式(
字体大小:15.0,
字母间距:1.0,
颜色:颜色,黑色,
fontWeight:fontWeight.w100),
)
:新循环压缩机指示器(
值:null,
冲程宽度:5.0,
valueColor:
全新AlwaysStoppedAnimation(颜色:蓝色),
),
),
),
],
),
));
}
}
import 'dart:async';
import 'package:datingapp/Screens/Login/pages.dart';
import 'package:datingapp/Screens/Login/styles.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
class Login extends StatefulWidget {
@override
_LoginState createState() => new _LoginState();
}
class _LoginState extends State<Login> with TickerProviderStateMixin {
PageController controller;
var index = 0;
bool loader = false;
initState() {
super.initState();
controller = new PageController(initialPage: 0, keepPage: true);
}
Future<Null> _login() async {
setState(() {
loader = true;
});
Navigator.of(context).pushNamed("/home");
setState(() {
loader = false;
});
}
@override
dispose() {
controller.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) {
SystemChrome.setSystemUIOverlayStyle(SystemUiOverlayStyle.dark);
Size screenSize = MediaQuery.of(context).size;
return new Scaffold(
body: new Container(
width: screenSize.width,
height: screenSize.height,
padding: new EdgeInsets.all(20.0),
decoration: new BoxDecoration(image: backgroundImage),
child: new Column(
// mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: <Widget>[
new Container(
width: screenSize.width,
height: screenSize.height - 200,
child: new PageView.builder(
onPageChanged: (value) {
setState(() {
index = value;
});
},
controller: controller,
itemCount: pages.length,
itemBuilder: (context, index) => new Page(
viewModel: pages[index],
),
),
),
new Container(
width: 120.0,
height: 20.0,
margin: new EdgeInsets.only(bottom: 20.0),
child: new Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: pages.map((item) {
return new Container(
width: 10.0,
height: 10.0,
decoration: new BoxDecoration(
shape: BoxShape.circle,
color: pages[index % 4] == item
? Colors.white
: Colors.white70),
);
}).toList()),
),
new FlatButton(
onPressed: _login,
child: new Container(
width: 300.0,
height: 50.0,
alignment: Alignment.center,
decoration: new BoxDecoration(
color: Colors.white,
borderRadius:
new BorderRadius.all(new Radius.circular(50.0))),
child: !loader
? new Text(
"Login with Facebook",
style: new TextStyle(
fontSize: 15.0,
letterSpacing: 1.0,
color: Colors.black,
fontWeight: FontWeight.w100),
)
: new CircularProgressIndicator(
value: null,
strokeWidth: 5.0,
valueColor:
new AlwaysStoppedAnimation<Color>(Colors.blue),
),
),
),
],
),
));
}
}