Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/flutter/10.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Flutter 颤振柱子项超过约束框父项_Flutter - Fatal编程技术网

Flutter 颤振柱子项超过约束框父项

Flutter 颤振柱子项超过约束框父项,flutter,Flutter,下面的颤振示例将导致绿色框和文本实际超出父容器的约束。为什么在这种情况下会发生这种情况?基本上,该列超过了其传入父容器约束高度400,并且在决定在何处布局其子容器时,似乎使用了顶部父容器高度。黑色边框是否也不可见 我也尝试过使用sizedbox和constrainedbox,结果是一样的 这纯粹是为了更详细地理解发生这种情况的原因 import 'package:flutter/material.dart'; final Color darkBlue = Color.fromARGB(255,

下面的颤振示例将导致绿色框和文本实际超出父容器的约束。为什么在这种情况下会发生这种情况?基本上,该列超过了其传入父容器约束高度400,并且在决定在何处布局其子容器时,似乎使用了顶部父容器高度。黑色边框是否也不可见

我也尝试过使用sizedbox和constrainedbox,结果是一样的

这纯粹是为了更详细地理解发生这种情况的原因

import 'package:flutter/material.dart';

final Color darkBlue = Color.fromARGB(255, 18, 32, 47);

void main() {
  runApp(MyApp());
}

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      theme: ThemeData.dark().copyWith(scaffoldBackgroundColor: darkBlue),
      debugShowCheckedModeBanner: false,
      home: Scaffold(
        body: Center(
          child: MyWidget(),
        ),
      ),
    );
  }
}

class MyWidget extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Container(
      width: double.infinity,
      height: double.infinity,      
      color: Colors.red,
      child: Container(
        height: 400,
        decoration: BoxDecoration(border: Border.all(color: Colors.black)),
        constraints: BoxConstraints(maxHeight: 400),
        child: Column(
          mainAxisAlignment: MainAxisAlignment.spaceAround,
          mainAxisSize: MainAxisSize.min,
          children: [
            SizedBox(
              height: 50,
              width: 50,
              child: Container(
                color: Colors.green,
              )
            ),
            Text("Test")
          ]
        )
      )
    );
  }
}

请尝试将SingleChildScrollView添加到任何位置列、正文或返回容器()@markThank中,但问题是为什么会发生这种情况。