【问题标题】:screen not displaying in flutter屏幕不显示颤动
【发布时间】:2019-08-13 06:07:31
【问题描述】:

我在登录屏幕上有 hese sn-p,当我在 android 设备上启动应用程序时,这些代码没有显示

这里是控制台 I/flutter (12389) 上的错误:══╡ 渲染库╞═════════════════════════════ ════════════════════════════════ I/flutter (12389):在 performLayout() 期间抛出了以下断言: I/flutter (12389):BoxConstraints 强制使用无限宽度。 I/flutter (12389):这些无效约束由 RenderAnimatedOpacity 的 layout() 函数提供 I/flutter (12389):以下函数,它可能计算了有问题的无效约束:

    import 'package:flutter/material.dart';

class UserEmail extends StatefulWidget{
  @override
  State<StatefulWidget> createState() {
    return UserEmailState();
  }

}

class UserEmailState extends State<UserEmail> {

  final TextEditingController _emailController = new TextEditingController();

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: new AppBar(
        backgroundColor: Colors.transparent,
        elevation: 0.0,
      ),

      body: ListView(
        children: <Widget>[
          Padding(
            padding: const EdgeInsets.all(16.0),
            child: SizedBox(
              child: new Row(
                children: <Widget>[
                  Text("Welcome",
                  style: TextStyle(color: Colors.black,fontWeight: FontWeight.bold
                  ),),
                  Text("A short slogan about the app...")
                ],
              ),
            ),
          ),

          Padding(
            padding: const EdgeInsets.all(24.0),
            child: SizedBox(
              child: Column(
                children: <Widget>[
                  Row(
                    children: <Widget>[
                      TextField(
                        controller: _emailController,
                        decoration: new InputDecoration(
                          labelText: "Email",
                          hintText: "Enter email address"
                        ),
                      )
                    ],
                  ),

                  Padding(
                    padding: const EdgeInsets.all(8.0),
                    child: new RaisedButton(
                        onPressed: null,
                        textColor: Colors.white,
                        color: Colors.blueGrey,
                        padding: const EdgeInsets.all(8.0),
                        child: new Text(
                            "Continue")
                    ),
                  ),
                ],
              ),
            ),
          )
        ],
      ),
    );
  }
}

【问题讨论】:

    标签: flutter


    【解决方案1】:

    将您的 TextField 包装在 Expanded 或 Flexible 小部件中。像这样:

                Flexible(
                          child: TextField(
                            controller: _emailController,
                            decoration: new InputDecoration(
                                labelText: "Email",
                                hintText: "Enter email address"
                            ),
                          ),
                        )
    

    【讨论】:

      猜你喜欢
      • 2020-12-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-03-19
      • 2015-02-20
      • 1970-01-01
      • 2021-03-13
      相关资源
      最近更新 更多