Dave
Dave

Reputation: 2018

CupertinoPicker infinite scroll instead empty space

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?

enter image description here

  @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

Answers (1)

jbryanh
jbryanh

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

Related Questions