我收到此错误 A renderFlex overFlowed by 100 pixels on the bottom

I got this error A renderFlex overFlowed by 100 pixels on the bottom

如下所示,我尝试添加一个 TextFormField,添加后出现错误 renderFlex overFlowed:

 Widget build(BuildContext context) {
    return Column(
      children: <Widget>[
        Text('Rate the order !', style: TextStyle(fontSize: 18, fontWeight: FontWeight.bold),),
        SizedBox(height: 10,),
        Row(
          mainAxisAlignment: MainAxisAlignment.center,
          children: List.generate(starCount, (index)=>buildStar(context, index)),
        ),
        Padding(
          padding: EdgeInsets.all(10),
          child: Form(child:TextFormField(
            decoration: (InputDecoration(
              labelText: 'add your notes'
            )),
            textInputAction: TextInputAction.done,
          )),
        )
      ],
    );

Column作为SingleChildScrollView

child

这非常有效,请检查一下。请参阅下面的代码:

import 'package:flutter/material.dart';

Widget build(BuildContext context) {
    return Column(
      children: <Widget>[
        Text('Rate the order !', style: TextStyle(fontSize: 18, fontWeight: FontWeight.bold),),
        SizedBox(height: 10,),
        Expanded(
                  child: Row(
            mainAxisAlignment: MainAxisAlignment.center,
            children: List.generate(starCount, (index)=>buildStar(context, index)),
          ),
        ),
        Padding(
          padding: EdgeInsets.all(10),
          child: Form(child:TextFormField(
            decoration: (InputDecoration(
              labelText: 'add your notes'
            )),
            textInputAction: TextInputAction.done,
          )),
        )
      ],
    );

希望对您有所帮助。

为行内的列或列表指定固定高度。使用容器或任何其他小部件

将列包装在 SingleChildScrollView 中。

DartPad 上的工作示例: https://dartpad.dev/b6409e10de32b280b8938aa75364fa7b

import 'package:flutter/material.dart';

void main() => runApp(MyApp());

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      debugShowCheckedModeBanner: false,
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: MyHomePage(title: 'Flutter Demo Home Page'),
    );
  }
}

class MyHomePage extends StatefulWidget {
  MyHomePage({Key key, this.title}) : super(key: key);

  final String title;

  @override
  _MyHomePageState createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {

  Widget build(BuildContext context) {
    return Material(child: 
                    SingleChildScrollView(child:
                    Column(
      children: <Widget>[
        Text('Rate the order !', style: TextStyle(fontSize: 18, fontWeight: FontWeight.bold),),
        SizedBox(height: 10,),
        Row(
          mainAxisAlignment: MainAxisAlignment.center,
          children: List.generate(10, (index)=>Icon(Icons.star)),
        ),
        SizedBox(height: 10,),
        Column(
          mainAxisAlignment: MainAxisAlignment.center,
          // add many children just to overflow on the bottom 
          children: List.generate(100, (index)=>Icon(Icons.video_call)),
        ),
        Padding(
          padding: EdgeInsets.all(10),
          child: Form(child:TextFormField(
            decoration: (InputDecoration(
              labelText: 'add your notes'
            )),
            textInputAction: TextInputAction.done,
          )),
        )
      ],
    ),),);
  }
}