Flutter-Sliver列表内的Sliver Layout水平滚动

我尝试在 *

这是我的代码:

import 'package:flutter/material.dart';

class DetailScreen extends StatelessWidget {

@override

Widget build(BuildContext context) {

return Scaffold(

body: CustomScrollView(

slivers: <Widget>[

DetailAppBar(),

SliverPadding(

padding: EdgeInsets.all(16.0),

sliver: SliverList(

delegate: SliverChildListDelegate(

[

Card(child: Text('data'),),

Card(child: Text('data'),),

Card(child: Text('data'),),

Card(child: Text('data'),),

// Scrollable horizontal widget here

],

),

),

),

],

),

bottomNavigationBar: NavigationButton());

}

}

您能给我例子或解决方案吗?我真的需要一些帮助。

回答:

使用的ListView内部SliverToBoxAdapter

  @override

Widget build(BuildContext context) {

return Scaffold(

body: CustomScrollView(

slivers: <Widget>[

SliverPadding(

padding: EdgeInsets.all(16.0),

sliver: SliverList(

delegate: SliverChildListDelegate(

[

Card(

child: Text('data'),

),

Card(

child: Text('data'),

),

Card(

child: Text('data'),

),

Card(

child: Text('data'),

),

],

),

),

),

SliverToBoxAdapter(

child: Container(

height: 100.0,

child: ListView.builder(

scrollDirection: Axis.horizontal,

itemCount: 10,

itemBuilder: (context, index) {

return Container(

width: 100.0,

child: Card(

child: Text('data'),

),

);

},

),

),

),

],

),

);

}

以上是 Flutter-Sliver列表内的Sliver Layout水平滚动 的全部内容, 来源链接: utcz.com/qa/423074.html

回到顶部