Saturday, November 21, 2026
HomeiOS Developmentios - Flutter Padding on CupertinoScrollbar - methods to forestall row from...

ios – Flutter Padding on CupertinoScrollbar – methods to forestall row from disappearing as quickly as they enter the padding space?

[ad_1]

My precise app is much more advanced however it is a easier instance which may reproduce this difficulty.

My CupertinoScrollbar is inside a Padding widget with prime padding of 300. Ideally, I would like the rows within the Checklist to scroll up the complete “padding space” earlier than disappearing. Nonetheless, as you discover, the rows disappear as quickly because it goes into the padding space.

Though I’ve outlined clipBehavior: Clip.none, it nonetheless disappears as quickly because it enters the padding space.

If I take away the clipBehavior: Clip.none, then the row is just clipped as quickly because it enters the padding space as an alternative of solely being eliminated after it goes out.

How can I be sure the rows do not get eliminated UNTIL they go exterior the padding (on this case, the highest fringe of display screen)?

On iOS, UITableView’s contentInset property let me obtain this.

enter image description here

enter image description here

This is my code:

class MyHomePage extends StatefulWidget {
  const MyHomePage({Key? key, required this.title}) : tremendous(key: key);

  closing String title;

  @override
  State<MyHomePage> createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  ScrollController scrollController = ScrollController();

  @override
  Widget construct(BuildContext context) {
    return Scaffold(
      physique: Padding(
        padding: EdgeInsets.solely(prime: 300),
        youngster: CupertinoScrollbar(
          controller: scrollController,
          youngster: CustomScrollView(
            clipBehavior: Clip.none,
            controller: scrollController,
            slivers: [
              SliverList(
                delegate: SliverChildListDelegate(
                  List.generate(words.length, (index) {
                    return Padding(
                      padding: const EdgeInsets.only(left: 8.0, right: 8.0),
                      child: Card(
                        child: ListTile(
                          title: Text("$index. ${words[index]}"),
                          onTap: () {
                            setState(() {
                              phrases.removeAt(index);
                            });
                          },
                        ),
                      ),
                    );
                  }),
                ),
              ),
            ],
          ),
        ),
      ),
      floatingActionButton: FloatingActionButton(
        youngster: Icon(
          Icons.add_rounded,
          dimension: 35,
          coloration: Colours.white,
        ),
        onPressed: () {
          setState(() {
            addWords(howMany: 1);
          });
        },
      ),
    );
  }
}

[ad_2]

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments