为什么我不能在这里使用 children 数组?扑

Why can I not use children array here? Flutter

我有这个 class,从其中一个示例中提取并更改

class SignUpView extends StatelessWidget {
  const SignUpView({Key key}) : super(key: key);
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: Center(
        child: SizedBox(
          width: 400,
          child: Card(
            child: SignUpForm(),
          ),
        ),
      ),
    );
  }
}

但是如果我想用 children 代替 child,像这样

class SignUpView extends StatelessWidget {
  const SignUpView({Key key}) : super(key: key);
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: Center(
        children: [
          SizedBox(
            width: 400,
            child: Card(
              child: SignUpForm(),
            ),
          ),
        ],
      ),
    );
  }
}

它说命名参数 children 未定义。

如果我想在 Center 容器中放置多个 child 怎么办?

中心只能有一个child。使用 ColumnRowListView 之类的东西为中心使用 1 个以上的小部件。

import 'package:flutter/material.dart';

class SignUpView extends StatelessWidget {
  const SignUpView({Key key}) : super(key: key);
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: Center(
        child: ListView(
          children: [
            SizedBox(
              width: 400,
              child: Card(
                child: SignUpForm(),
              ),
            ),
          ],
        ),
      ),
    );
  }
}