Flutter 试图在颤振中实现视差滚动视图,但其未反映在UI中
我试图在颤振web中实现一个视差效果,并按照程序在其中实现该效果,但它似乎没有像预期的那样反映在UI中 我尝试添加所有必要的东西,但效果仍然没有显示出来。 我添加了所有定位的小部件,声明了topOne和topTwo等变量,并添加了通知侦听器 以下是我的代码片段:Flutter 试图在颤振中实现视差滚动视图,但其未反映在UI中,flutter,dart,parallax,flutter-web,Flutter,Dart,Parallax,Flutter Web,我试图在颤振web中实现一个视差效果,并按照程序在其中实现该效果,但它似乎没有像预期的那样反映在UI中 我尝试添加所有必要的东西,但效果仍然没有显示出来。 我添加了所有定位的小部件,声明了topOne和topTwo等变量,并添加了通知侦听器 以下是我的代码片段: body: SingleChildScrollView( child: NotificationListener( onNotification: (v) {
body: SingleChildScrollView(
child: NotificationListener(
onNotification: (v) {
if (v is ScrollUpdateNotification) {
setState(() {
topOne = topOne - v.scrollDelta / 3;
topTwo = topTwo - v.scrollDelta / 1;
});
}
},
child: SafeArea(
child: Column(
children: [
Stack(
children: [
NavBar(
h: h / 1.2,
w: w / 1,
sel0: false,
sel1: false,
sel2: true,
sel3: false,
sel4: false,
)
],
),
SizedBox(
height: h / 12,
),
Container(
height: h / 1,
width: w / 1,
decoration: BoxDecoration(
gradient: LinearGradient(
begin: Alignment.topCenter,
end: Alignment.bottomCenter,
colors: [
Colors.transparent,
Colors.grey[100],
AppColors.getWhite(),
]),
),
child: Stack(
children: [
Positioned(
top: 30,
left: 30,
child: Text(
'F L EX',
style:
TextStyle(fontSize: 500, color: Colors.white),
),
),
Positioned(
top: topOne, //I wanted this to move in the normal speed
left: 100,
child: Container(
height: h / 1.1,
width: w / 1.2,
decoration: BoxDecoration(color: Colors.white,
// borderRadius: BorderRadius.circular(8),
boxShadow: [
BoxShadow(
color: AppColors.getGrey(),
blurRadius: 60.0,
),
]),
),
),
Positioned(
top: 80,
left: 150,
child: RotationTransition(
turns: new AlwaysStoppedAnimation(50 / 360),
child: Container(
height: h / 6,
width: w / 12,
decoration: BoxDecoration(
border: Border.all(
color: AppColors.getGrey(), width: 4)),
),
),
),
Positioned(
top: topTwo, // I wanted this to move slow than the above
left: 200,
child: Text(
'WE DO IT ALL.',
style: GoogleFonts.roboto(
fontSize: 30,
fontWeight: FontWeight.normal,
color: AppColors.getBlack()),
),
),