开始拖动 NestedScrollView 主体时的瞬时跳转

问题描述

import 'package:Flutter/material.dart';

void main() => runApp(const MyApp());

class MyApp extends StatelessWidget {
  const MyApp({Key? key}) : super(key: key);

  static const String _title = 'Flutter Code Sample';

  @override
  Widget build(BuildContext context) {
    return const MaterialApp(
      title: _title,home: MyStatelessWidget(),);
  }
}

class MyStatelessWidget extends StatelessWidget {
  const MyStatelessWidget({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    final List<String> _tabs = <String>['Tab 1','Tab 2'];
    return DefaultTabController(
      length: _tabs.length,// This is the number of tabs.
      child: Scaffold(
        body: nestedScrollView(
          headerSliverBuilder: (BuildContext context,bool innerBoxIsScrolled) {
            return <Widget>[
              SliverToBoxAdapter(
                child: SizedBox(
                  height: 250,),SliverOverlapAbsorber(
                handle: nestedScrollView.sliverOverlapAbsorberHandleFor(context),sliver: SliverAppBar(
                  title: const Text('Books'),pinned: true,expandedHeight: 150.0,forceElevated: innerBoxIsScrolled,bottom: TabBar(
                    tabs: _tabs.map((String name) => Tab(text: name)).toList(),];
          },body: TabBarView(
            children: _tabs.map((String name) {
              return SafeArea(
                top: false,bottom: false,child: Builder(
                  builder: (BuildContext context) {
                    return CustomScrollView(
                      key: PageStorageKey<String>(name),slivers: <Widget>[
                        SliverOverlapInjector(
                          handle: nestedScrollView.sliverOverlapAbsorberHandleFor(context),SliverPadding(
                          padding: const EdgeInsets.all(8.0),sliver: SliverFixedExtentList(
                            itemExtent: 48.0,delegate: SliverChildBuilderDelegate(
                              (BuildContext context,int index) {
                                return ListTile(
                                  title: Text('Item $index'),);
                              },childCount: 30,],);
                  },);
            }).toList(),);
  }
}

我遇到了 Flutter 的 nestedScrollView 的滚动行为问题。 当我在 SliverOverlapAbsorber 上方放置一些条子(在本例中为 SliverToBoxAdapter)时,滚动条会在正文开始处瞬间跳跃。 当我删除它时,滚动行为变得很好。 你可以试试上面的代码。 任何帮助将不胜感激!

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...