我在列中有一个水平的 ListView。
我的 ListView 正在渲染 100 x 100 的项目,我想稍后将它们的高度设置为 200。
我将我的 ListView 包装在一个高度为 200 的容器中,否则我会收到错误并且代码将无法运行
现在的问题是列表项将它们的高度拉伸到 200。有没有办法防止这种行为,我尝试对齐但它没有用。这是到目前为止的代码
Scaffold(
body: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Container(
height: 200,
child: ListView(
scrollDirection: Axis.horizontal,
children: <Widget>[
CCard(),
CCard(),
CCard(),
CCard(),
CCard(),
],
),
),
],
));
Run Code Online (Sandbox Code Playgroud)
和列表项
class CCard extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Container(
margin: EdgeInsets.symmetric(horizontal: 8.0),
height: 100,
width: 100,
color: Colors.red[200],
);
}
}
Run Code Online (Sandbox Code Playgroud) 我有这些类型:
type Exercise = {
type: string
prompt: string
answer: string
}
type ComplexExercise = {
type: string
prompt: string,
subExercises: Exercise[]
}
Run Code Online (Sandbox Code Playgroud)
我正在尝试制作一个从 api 获取数据并根据类型呈现它的组件
type Exercise = {
type: string
prompt: string
answer: string
}
type ComplexExercise = {
type: string
prompt: string,
subExercises: Exercise[]
}
Run Code Online (Sandbox Code Playgroud)
我收到以下错误
<script lang="ts">
let promise = getExercise(params.exerciseId).then((ex) => (exercise = ex));
let exercise: ComplexExercise | Exercise;
</script>
...
{#await promise}
<p>Loading exercise</p>
{:then}
{#if exercise.type !== "COMPLEX"}
<BaseEditor {exercise} />
{:else}
{#each …Run Code Online (Sandbox Code Playgroud)