Flutter 如何在Flatter中为页面视图使用animateTojump()
我正在点击按钮更改页面视图的页面。页面更改得非常好,但没有动画工作。我使用了方法animateTopage()方法,但没有动画工作 我参加了班级开学考试。此类在其布局中具有pageview。每当我点击任何一张卡片,下一页就会显示出来,没有任何动画Flutter 如何在Flatter中为页面视图使用animateTojump(),flutter,flutter-animation,Flutter,Flutter Animation,我正在点击按钮更改页面视图的页面。页面更改得非常好,但没有动画工作。我使用了方法animateTopage()方法,但没有动画工作 我参加了班级开学考试。此类在其布局中具有pageview。每当我点击任何一张卡片,下一页就会显示出来,没有任何动画 Widget build(BuildContext context) { return Scaffold( backgroundColor: Colors.white, appBar: AppBar( backgroundColor:
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: Colors.white,
appBar: AppBar(
backgroundColor: Colors.white,
elevation: 1,
iconTheme: IconThemeData(color: Colors.black),
actions: <Widget>[
Padding(
padding: EdgeInsets.only(right: 60),
child: Row(
children: <Widget>[],
))
],
title: Text(
'Test',
style: TextStyle(color: Colors.black),
),
),
body: FutureBuilder<List<questions_data>>(
future: _fetch_questions(),
builder: (context, snapshot) {
switch (snapshot.connectionState) {
case ConnectionState.none:
return Text('Failed to connect');
case ConnectionState.waiting:
return Center(
child: Text(
'Loading',
style: TextStyle(color: Colors.grey),
));
case ConnectionState.done:
if (snapshot.hasError) {
return Center(
child: InkWell(
child: Padding(
padding: const EdgeInsets.all(32.0),
child: Column(
children: <Widget>[
Text('Error in connection'),
Text('Tap to retry')
],
),
),
onTap: () {
setState(() {
CircularProgressIndicator();
});
},
),
);
} else if (snapshot.hasData) {
return Padding(
padding: EdgeInsets.all(20),
child: PageView.builder(
physics: AlwaysScrollableScrollPhysics(),
controller: _controller,
itemCount: snapshot.data.length,
itemBuilder: (ctx, i) {
return Container(
decoration: BoxDecoration(
borderRadius: BorderRadius.only(
topRight: Radius.circular(10),
topLeft: Radius.circular(10),
),
color: Colors.transparent,
border: Border.all(
color: Colors.grey.shade200, width: 1)),
child: ListView(
children: <Widget>[
Container(
decoration: BoxDecoration(
color: Colors.grey.shade300,
borderRadius: BorderRadius.only(
topRight: Radius.circular(10),
topLeft: Radius.circular(10),
)),
height: 60,
child: Padding(
padding: EdgeInsets.all(15),
child: Center(
child: Text(
"Q",
style: TextStyle(color: Colors.black),
),
),
),
),
Container(
height: MediaQuery.of(context).size.height,
color: Colors.white,
child: Column(
children: <Widget>[
Padding(
padding: EdgeInsets.all(15),
child: SingleChildScrollView(
child: Text(
'Flutter is Google’s mobile UI open source framework to build high-quality native (super fast) interfaces for iOS and Android apps with the unified codebase. build high-quality native (super fast) interfaces for iOS and Android apps with the unified codebase.',
style: TextStyle(
color: Colors.black,
fontSize: 15),
),
)),
Padding(
padding: EdgeInsets.all(5),
child: Card(
elevation: 2,
child: SizedBox(
width: MediaQuery.of(context)
.size
.width,
child: InkWell(
onTap: () {
_controller.animateToPage(
i + 1,
duration: Duration(
microseconds: 600),
curve: Curves.ease);
},
child: Padding(
padding: EdgeInsets.all(20),
child: Text(
snapshot.data[i].ans_one,
style: TextStyle(
color: Colors.black),
),
),
),
)),
),
Padding(
padding: EdgeInsets.all(5),
child: Card(
elevation: 2,
child: SizedBox(
width: MediaQuery.of(context)
.size
.width,
child: InkWell(
onTap: () {
_controller.animateToPage(
i + 1,
duration: Duration(
microseconds: 15000),
curve: Curves.ease);
},
child: Padding(
padding: EdgeInsets.all(20),
child: Text(
snapshot.data[i].ans_two,
style: TextStyle(
color: Colors.black),
),
),
),
)),
),
Padding(
padding: EdgeInsets.all(5),
child: Card(
elevation: 2,
child: SizedBox(
width: MediaQuery.of(context)
.size
.width,
child: InkWell(
onTap: () {
_controller.animateToPage(
i + 1,
duration: Duration(
microseconds: 15000),
curve: Curves.ease);
},
child: Padding(
padding: EdgeInsets.all(20),
child: Text(snapshot
.data[i].ans_three),
),
),
)),
),
Padding(
padding: EdgeInsets.all(5),
child: Card(
elevation: 2,
child: SizedBox(
width: MediaQuery.of(context)
.size
.width,
child: ***InkWell(
onTap: () {
_controller.animateToPage(
i + 1,
duration: Duration(
microseconds: 15000),
curve: Curves.ease);
},***
child: Padding(
padding: EdgeInsets.all(20),
child: Text(snapshot
.data[i].ans_four),
),
),
)),
)
],
),
)
],
),
);
}),
);
}
return Center(
child: InkWell(
child: Padding(
padding: const EdgeInsets.all(32.0),
child: Column(
children: <Widget>[
Text('Error in connection'),
Text('Tap to retry')
],
),
),
onTap: () {
setState(() {
CircularProgressIndicator();
});
},
),
);
default:
return Text('Loading...');
}
;
}),
);
小部件构建(构建上下文){
返回脚手架(
背景颜色:Colors.white,
appBar:appBar(
背景颜色:Colors.white,
立面图:1,
iconTheme:IconThemeData(颜色:Colors.black),
行动:[
填充物(
填充:仅限边缘设置(右:60),
孩子:排(
儿童:[],
))
],
标题:正文(
"测试",,
样式:TextStyle(颜色:Colors.black),
),
),
正文:未来建设者(
未来:_fetch_questions(),
生成器:(上下文,快照){
交换机(快照.连接状态){
案例连接状态。无:
返回文本('连接失败');
案例连接状态。正在等待:
返回中心(
子:文本(
“加载”,
样式:TextStyle(颜色:Colors.grey),
));
案例连接状态。完成:
if(snapshot.hasError){
返回中心(
孩子:InkWell(
孩子:填充(
填充:常数边集全部(32.0),
子:列(
儿童:[
文本(“连接错误”),
文本('点击重试')
],
),
),
onTap:(){
设置状态(){
循环前进指示器();
});
},
),
);
}else if(snapshot.hasData){
返回填充(
填充:边缘设置。全部(20),
子项:PageView.builder(
物理:AlwaysScrollableScrollPhysics(),
控制器:_控制器,
itemCount:snapshot.data.length,
项目生成器:(ctx,i){
返回容器(
装饰:盒子装饰(
borderRadius:仅限borderRadius(
右上角:半径。圆形(10),
左上:半径。圆形(10),
),
颜色:颜色。透明,
边界:边界(
颜色:Colors.grey.shade200,宽度:1),
子:ListView(
儿童:[
容器(
装饰:盒子装饰(
颜色:Colors.grey.shade300,
borderRadius:仅限borderRadius(
右上角:半径。圆形(10),
左上:半径。圆形(10),
)),
身高:60,
孩子:填充(
填充:边缘设置。全部(15),
儿童:中心(
子:文本(
“Q”,
样式:TextStyle(颜色:Colors.black),
),
),
),
),
容器(
高度:MediaQuery.of(context).size.height,
颜色:颜色,白色,
子:列(
儿童:[
填充物(
填充:边缘设置。全部(15),
子:SingleChildScrollView(
子:文本(
“Flatter是谷歌的移动用户界面开源框架,用于使用统一代码库为iOS和Android应用程序构建高质量本机(超快)接口。使用统一代码库为iOS和Android应用程序构建高质量本机(超快)接口。”,
样式:TextStyle(
颜色:颜色,黑色,
尺寸:15),,
),
)),
填充物(
填充:边缘设置。全部(5),
孩子:卡片(
标高:2,
孩子:大小盒子(
宽度:MediaQuery.of(上下文)
.尺寸
.宽度,
孩子:InkWell(
onTap:(){
_controller.animateToPage(
i+1,
持续时间:持续时间(
微秒:600),
曲线:曲线。轻松);
},
孩子:填充(
填充:边缘设置。全部(20),
子:文本(
快照数据[
_controller.animateToPage(
i + 1,
duration: Duration(
microseconds: 600),
curve: Curves.ease,
);