'ListView Horizontal PageScrollPhysics not align item center
I have some problem with Flutter. I need align in ListView after scroll with pagescrollphysics in horizontal axis in center. My container will go much left, and I don't understand how align item center in scrollview with axis horizontal direction.
I copi in my code. thanks to every all
Container of ListView:
Container(
height: 150,
width: double.infinity,
child: ListView(
physics: PageScrollPhysics(),
scrollDirection: Axis.horizontal,
children: childreenSeries,
),
),
childreenSeries is an array of widget builded with this method:
List<Widget> serieBuilderHome({List<Serie> serie}) {
List<Widget> childreen = [];
if (serie != null) {
this.series = serie;
}
for (int i = 0; i < series.length; i++) {
childreen.add(
MyCard(context: context, serie: series[i]),
);
}
return childreen;
}
MyCard is My Widget build like:
class MyCard extends StatelessWidget {
const MyCard({
Key key,
@required this.context,
@required this.film,
@required this.serie,
@required this.category,
}) : super(key: key);
final BuildContext context;
final Serie serie;
@override
Widget build(BuildContext context) {
return Container(
margin: EdgeInsets.all(8.0),
width: MediaQuery.of(context).size.width - 50,
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text(
'${serie.id}',
style: TextStyle(
fontWeight: FontWeight.w900,
color: Colors.white,
),
),
Text(
'${serie.name}',
style: TextStyle(
fontWeight: FontWeight.w900,
color: Colors.white,
),
),
Text(
'${serie.description}',
style: TextStyle(
fontWeight: FontWeight.w900,
color: Colors.white,
),
),
Text(
'${serie.cast ?? []}',
style: TextStyle(
fontWeight: FontWeight.w900,
color: Colors.white,
),
),
],
),
decoration: BoxDecoration(
gradient: LinearGradient(
begin: Alignment.centerLeft,
end: Alignment.centerRight,
colors: [
Colors.deepOrangeAccent,
Colors.deepOrange,
Colors.orange,
Colors.orangeAccent,
],
),
borderRadius: BorderRadius.circular(8.0),
),
);
}
}
Solution 1:[1]
When I ran into this, it fixed when I fully reloaded the app onto the phone where I was debugging; apparently hot-reload doesn't exactly work intuitively in certain cases.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | mwarrior |
