Reputation: 2018
I have a cupertino picker, however when I enter the view I can see a lot of empty space at the top. How can I make an infinite scroll there, or remove the empty space?
@override
Widget build(BuildContext context) {
return Container(
decoration: BoxDecoration(
border: Border.all(
color: Colors.black,
),
),
child: CupertinoPicker(
scrollController: scrollController,
itemExtent: 64.0,
selectionOverlay: Container(),
onSelectedItemChanged: (value) => widget.callback(widget.data[value]),
children: widget.data
.map(
(e) => Center(child: Container(
width: double.infinity,
decoration: BoxDecoration(
border: Border.all(color: Colors.blueAccent)
),
child: Text(e))),
)
.toList()),
);
}
Upvotes: 1
Views: 511
Reputation: 2013
Set your parent container height and/or set your initialItem to something other than the default 0.
scrollController = FixedExtentItemScrollController(initialItem: 3);
Upvotes: 1