Sim*_*ani 7 user-interface dart flutter
我有一个银子列表,我想将其封装在一张卡片中。这是我的银名单代码:
Widget hello() {
return SliverPadding(
padding: const EdgeInsets.only(
top: 0.0,
bottom: 100.0,
),
sliver: SliverList(
delegate: SliverChildBuilderDelegate(
(BuildContext context, int index) {
return Padding(
padding: const EdgeInsets.only(
top: 4,
bottom: 4,
left: 8,
right: 8,
),
child: Column(
children: <Widget>[
Container(
color: Color(0xff9a9a9a),
height: 0.5,
),
SizedBox(
height: 4,
),
ListTile(
leading: ClipRRect(
borderRadius: BorderRadius.circular(12.0),
child: Container(
child: Image.network('http://cdn.akc.org/content/hero/cute_puppies_hero.jpg'),
),
),
title: Row(
children: <Widget>[
Text('Hello',
),
],
),
subtitle: Text(
'This is a puppy',
),
SizedBox(
height: 4,
),
],
),
);
},
childCount: 8,
),
),
);
}
Run Code Online (Sandbox Code Playgroud)
我就是这样称呼它的:
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: Color.fromRGBO(247, 248, 251, 1),
body: Container(
child: Stack(
children: <Widget>[
CustomScrollView(
slivers: <Widget>[
hello(),
..other widgets are called here..
],
),
],
),
),
);
}
Run Code Online (Sandbox Code Playgroud)
这就是我试图用我的 SliverList 实现的目标,我想将其显示在卡片内:

当我尝试用 Card 包装 SliverList 时,出现 RenderFlex 错误,并且它不接受该 Card 作为子项。
Igo*_*nov 10
对于那些仍在寻找答案的人:您可以使用精彩的包sliver_tools中的 SliverStack 小部件:
import 'package:flutter/material.dart';
import 'package:sliver_tools/sliver_tools.dart';
CustomScrollView(
slivers: [
SliverStack(
insetOnOverlap: false,
children: [
SliverPositioned.fill(child: Card()),
SliverList(...),
],
),
],
);
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3343 次 |
| 最近记录: |