iPhone XR CustomScrollView with Sliver widget(s) scroll issue

626 Views Asked by At

I haven't check in real device but testing Simulators.

I have code some Sliver(s) in CustomScrollView. Look at below code. When I run snippets of code I faced screen didn't scroll smoothly while scroll up-down in the simulator iPhone XR. After checking other simulators it's working good? Anything is wrong in below code? I don't think so, otherwise I would not be worked on other simulators?

import 'package:flutter/material.dart';

class AnimalWidget extends StatefulWidget {
  _AnimalWidgetState createState() => _AnimalWidgetState();
}

class _AnimalWidgetState extends State<AnimalWidget> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: CustomScrollView(
        slivers: <Widget>[
          SliverAppBar(
            expandedHeight: 210,
            pinned: true,
            flexibleSpace: FlexibleSpaceBar(
              background: Image.network(
                  'https://static.independent.co.uk/s3fs-public/thumbnails/image/2017/09/12/11/naturo-monkey-selfie.jpg?w968h681',
                  fit: BoxFit.cover),
              title: Text('Animals Dashboard'),
            ),
          ),
          SliverToBoxAdapter(
            child: Container(
              margin: EdgeInsets.only(left: 8, top: 12, right: 8),
              child: Card(
                elevation: 4,
                child: Container(
                  margin: EdgeInsets.only(left: 8, top: 8, right: 8, bottom: 8),
                  child: Column(
                    crossAxisAlignment: CrossAxisAlignment.stretch,
                    children: <Widget>[
                      Container(
                        decoration: BoxDecoration(
                            border: Border.all(
                                color: Theme.of(context).primaryColor,
                                width: 1,
                                style: BorderStyle.solid)),
                        child: ListTile(
                          leading: Icon(Icons.fastfood,
                              color: Theme.of(context).primaryColor, size: 30),
                          title: Text(
                            "Monkey",
                            style: TextStyle(
                                color: Theme.of(context).primaryColor),
                          ),
                          trailing: Icon(
                            Icons.arrow_drop_down,
                            color: Theme.of(context).primaryColor,
                            size: 40,
                          ),
                          onTap: () {},
                        ),
                      ),
                      SizedBox(
                        height: 15,
                      ),
                      Container(
                        decoration: BoxDecoration(
                            border: Border.all(
                                color: Theme.of(context).primaryColor,
                                width: 1,
                                style: BorderStyle.solid)),
                        child: ListTile(
                          leading: Icon(Icons.local_florist,
                              color: Theme.of(context).primaryColor, size: 30),
                          title: Text(
                            "Donkey",
                            style: TextStyle(
                                color: Theme.of(context).primaryColor),
                          ),
                          trailing: Icon(
                            Icons.arrow_drop_down,
                            color: Theme.of(context).primaryColor,
                            size: 40,
                          ),
                          onTap: () {},
                        ),
                      ),
                      SizedBox(
                        height: 15,
                      ),
                      Container(
                        decoration: BoxDecoration(
                            border: Border.all(
                                color: Theme.of(context).primaryColor,
                                width: 1,
                                style: BorderStyle.solid)),
                        child: ListTile(
                          leading: Icon(Icons.find_replace,
                              color: Theme.of(context).primaryColor, size: 30),
                          title: Text(
                            "Camel",
                            style: TextStyle(
                                color: Theme.of(context).primaryColor),
                          ),
                          trailing: Icon(
                            Icons.arrow_drop_down,
                            color: Theme.of(context).primaryColor,
                            size: 40,
                          ),
                          onTap: () {},
                        ),
                      ),
                      SizedBox(height: 15),
                      Container(
                          height: 50,
                          color: Colors.teal,
                          child: FlatButton(
                            onPressed: () {},
                            color: Theme.of(context).primaryColor,
                            child: Text('SELECT ANIMAL',
                                style: TextStyle(
                                    color: Colors.white,
                                    fontSize: 16,
                                    fontWeight: FontWeight.w600)),
                          )),
                      SizedBox(height: 15),
                    ],
                  ),
                ),
              ),
            ),
          ),
          SliverList(delegate: SliverChildBuilderDelegate(
            (BuildContext context, int index) {
              return ListTile(
                leading: CircleAvatar(
                  child: Text(
                    'A',
                    style: TextStyle(fontSize: 18, fontWeight: FontWeight.bold),
                    textAlign: TextAlign.center,
                  ),
                ),
                title: Text('Animal => $index'),
              );
            },
          )),
        ],
      ),
    );
  }
}

For it, check just copy and paste the code.

1

There are 1 best solutions below

0
On

It's probably about the emulator. I tested your code on iPhone X emulator, Pixel 2XL emulator and on my real Pixel 3XL device. iPhone X emulator was laggy like page scrolled when I stopped scrolling, and 2XL emulator was normal like expected. Also 3XL real device was normal as expected.