Я изучаю флаттер. У меня есть страница с ListView, которые отображают
изображения в горизонтальной прокрутке. Кроме того, у меня есть еще один просмотр списка, который
отображать изображения внизу горизонтального списка. Теперь, когда я
проверьте данные Listview с помощью горизонтальной прокрутки и, наконец, достигните
положение элемента, в то время я проверяю другие данные в нижней части
просмотр списка с использованием вертикальной прокрутки. Первый просмотр списка невидим. этот
идеально, но когда я прокручиваю снизу вверх, горизонтальный список
все еще остаются в последней позиции вместо нулевой позиции.
Как мне это сделать?
Я приложил свой код и скриншот, что я хочу?
[![import 'package:flutter/material.dart';
class HomePage1 extends StatefulWidget {
@override
_HomePageState createState() => _HomePageState();
}
class _HomePageState extends State<HomePage1> {
BuildContext context;
@override
Widget build(BuildContext context) {
this.context = context;
// TODO: implement build
return MaterialApp(
debugShowCheckedModeBanner: false,
home: Scaffold(
appBar: AppBar(
centerTitle: true,
backgroundColor: Colors.white,
title: Text(
'Demo App',
style: TextStyle(color: Colors.black),
),
),
body: SingleChildScrollView(
scrollDirection: Axis.vertical,
child: Column(
children: <Widget>\[
_buildTrandingUI(),
_buildcardwithimg('assets/blue.png', ''),
_buildcardwithimg('assets/blue.png', ''),
\],
),
)),
);
}
@override
void initState() {
super.initState();
}
//Design Sale UI
_buildcardwithimg(String imgpath, String text) {
return Container(
height: 380,
margin: const EdgeInsets.symmetric(vertical: 8.0),
child: new Stack(
children: <Widget>\[
new Container(
margin: const EdgeInsets.only(right: 8.0, left: 8.0),
decoration: new BoxDecoration(
color: Colors.white,
shape: BoxShape.rectangle,
borderRadius: new BorderRadius.circular(8.0),
boxShadow: <BoxShadow>\[
new BoxShadow(
color: Colors.grey,
blurRadius: 10.0,
offset: new Offset(0.0, 10.0),
)
\],
image: DecorationImage(
fit: BoxFit.cover, image: new AssetImage(imgpath)),
),
child: new Container(
alignment: Alignment.topLeft,
padding: const EdgeInsets.all(10.0),
child: Text(
text,
style: TextStyle(
color: Colors.white,
fontWeight: FontWeight.bold,
fontSize: 14.0),
),
),
),
\],
),
);
}
//Desing Tranding UI
_buildTrandingUI() {
List<String> titlearr = \[\];
titlearr.add('The Grunge Collection!');
titlearr.add('On Point!');
titlearr.add('A Fresh Edge To Every Wear');
titlearr.add('Up to 50% Off');
List<String> sbutitlearr = \[\];
sbutitlearr.add('Born For the Road');
sbutitlearr.add('Premium Bags That Steak The Spotlight');
sbutitlearr.add('Printed Tees');
sbutitlearr.add('Born For the Road');
List<String> Traimgarr = \[\];
Traimgarr.add('assets/grun.png');
Traimgarr.add('assets/onpoint.png');
Traimgarr.add('assets/grun.png');
Traimgarr.add('assets/onpoint.png');
return Container(
height: 280.0,
margin: const EdgeInsets.symmetric(vertical: 4.0),
child: new Stack(
children: <Widget>\[
new Container(
margin: const EdgeInsets.only(left: 8.0, right: 8.0),
decoration: new BoxDecoration(
color: Colors.white,
shape: BoxShape.rectangle,
borderRadius: BorderRadius.circular(8.0),
boxShadow: <BoxShadow>\[
new BoxShadow(
color: Colors.grey,
blurRadius: 10.0,
offset: new Offset(0.0, 10.0),
)
\]),
child: new Container(
alignment: Alignment.topLeft,
padding: const EdgeInsets.all(10.0),
child: Text(
'Trending Now',
style: TextStyle(color: Colors.blueGrey),
),
),
),
new Center(
child: new Container(
height: 245.0,
margin: const EdgeInsets.only(left: 10.0, right: 10.0, top: 20.0),
child: ListView.builder(
scrollDirection: Axis.horizontal,
itemCount: Traimgarr.length,
itemBuilder: (context, index) {
return Column(
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisSize: MainAxisSize.min,
children: <Widget>\[
Container(
height: 190.0,
width: 280.0,
margin: EdgeInsets.all(10.0),
child: Image.asset(
Traimgarr\[index\],
fit: BoxFit.cover,
),
),
Text(
titlearr\[index\],
style: TextStyle(fontWeight: FontWeight.bold),
),
Text(
sbutitlearr\[index\],
style: TextStyle(color: Colors.grey),
)
\],
);
}),
))
\],
));
}
}][1]][1]