Я получил эту ошибку A renderFlex overlowed на 100 пикселей внизу - PullRequest
0 голосов
/ 04 мая 2020

, как показано ниже, я пытаюсь добавить TextFormFiled, и после добавления возникает ошибка: overFlowed renderFlex:

 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,
          )),
        )
      ],
    );

Ответы [ 4 ]

0 голосов
/ 04 мая 2020

Обернуть столбец в 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,
          )),
        )
      ],
    ),),);
  }
}
0 голосов
/ 04 мая 2020

это сработало отлично, зацените. См. Код ниже:

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,
          )),
        )
      ],
    );

Надеюсь, это поможет.

0 голосов
/ 04 мая 2020

Дайте столбцу или вашему списку внутри строки фиксированную высоту. использовать контейнер или любой другой виджет

0 голосов
/ 04 мая 2020

Положите Column как child из SingleChildScrollView

...