高架按钮在身体条款中不用作为儿童的小部件

发布于 2025-02-11 19:19:38 字数 989 浏览 2 评论 0原文

我试图在这个无状态的小部件中拥有一个高架的小部件。括号的层次结构还可以,但它并不认识到高架the的窗口小部件是儿童的参数

class buildProfileView extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: Column(
        mainAxisSize: MainAxisSize.min,
        children: [
          Center(
            child: CircleAvatar(
              backgroundImage:
                  Image.network(controller.googleAccount.value?.photoUrl ?? '')
                      .image,
              radius: 100,
            ),
          ),
          Text(
            controller.googleAccount.value?.displayName ?? '',
            style: Get.textTheme.headline1,
          ),
          Text(controller.googleAccount.value?.email ?? '',
              style: Get.textTheme.bodyText1),
          //),
        ],
        child: ElevatedButton(
          onPressed: () {},
          child: Text('Continue to Main Menu'),
          backgroundColor: Colors.blue,
        ),
      ),
    );
  }
}

I am trying to have an ElevatedButton widget in this stateless widget. The hierarchy of the brackets is ok but it is not recognizing the ElevatedButton widget being a parameter of child

class buildProfileView extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: Column(
        mainAxisSize: MainAxisSize.min,
        children: [
          Center(
            child: CircleAvatar(
              backgroundImage:
                  Image.network(controller.googleAccount.value?.photoUrl ?? '')
                      .image,
              radius: 100,
            ),
          ),
          Text(
            controller.googleAccount.value?.displayName ?? '',
            style: Get.textTheme.headline1,
          ),
          Text(controller.googleAccount.value?.email ?? '',
              style: Get.textTheme.bodyText1),
          //),
        ],
        child: ElevatedButton(
          onPressed: () {},
          child: Text('Continue to Main Menu'),
          backgroundColor: Colors.blue,
        ),
      ),
    );
  }
}

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

┼── 2025-02-18 19:19:39

问题在于代码 -

     //),
        ],
        child: ElevatedButton(
          onPressed: () {},

升高button不超出列范围。
它将

  body: Column(mainAxisSize: MainAxisSize.min, children: [
        Center(
          child: CircleAvatar(
            backgroundImage:
                Image.network(controller.googleAccount.value?.photoUrl ?? '')
                    .image,
            radius: 100,
          ),
        ),
        Text(
          controller.googleAccount.value?.displayName ?? '',
          style: Get.textTheme.headline1,
        ),
        Text(controller.googleAccount.value?.email ?? '',
            style: Get.textTheme.bodyText1),
        ElevatedButton(
          onPressed: () {},
          child: Text('Continue to Main Menu'),
        ),
      ]),

更多地是关于 didget 。

The issue lies on code-strucure

     //),
        ],
        child: ElevatedButton(
          onPressed: () {},

where ElevatedButton is out of the column scope.
It will be

  body: Column(mainAxisSize: MainAxisSize.min, children: [
        Center(
          child: CircleAvatar(
            backgroundImage:
                Image.network(controller.googleAccount.value?.photoUrl ?? '')
                    .image,
            radius: 100,
          ),
        ),
        Text(
          controller.googleAccount.value?.displayName ?? '',
          style: Get.textTheme.headline1,
        ),
        Text(controller.googleAccount.value?.email ?? '',
            style: Get.textTheme.bodyText1),
        ElevatedButton(
          onPressed: () {},
          child: Text('Continue to Main Menu'),
        ),
      ]),

More about Column widget.

城歌 2025-02-18 19:19:39

是的,您不能将儿童和儿童财产分配给专栏。专栏将孩子带到[](正方形支架)内部的儿童街区。

Yeah you can't assign both child and children property to a Column. Column takes children so move ElevatedButton to children block inside [](square brackets).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文