android - 位置参数必须出现在命名参数之前,并且 flutter 上的位置参数太多

标签 android visual-studio flutter dart

当我想在代码中添加文本表单字段时,我遇到了一些错误,提示“位置参数必须出现在命名参数之前”和“位置参数太多”,设计将类似于 this

我需要将文本表单字段放在文本下方,如何添加文本表单字段而不出现任何错误?

这是我的代码

import 'package:flutter/material.dart';

class ForgotPassword extends StatefulWidget {
  const ForgotPassword({Key? key}) : super(key: key);

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

class _ForgotPasswordState extends State<ForgotPassword> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        leading: IconButton(onPressed: () {}, icon: Icon(Icons.exit_to_app)),
      ),
      body: SingleChildScrollView(
        child: Center(
          child: Column(
            mainAxisAlignment: MainAxisAlignment.start,
            children: <Widget>[
              Padding(
                padding: EdgeInsets.symmetric(
                  vertical: 35.0,
                ),
                child: Text(
                  'Forgot Password',
                  style: TextStyle(
                      color: Colors.blue,
                      fontWeight: FontWeight.bold,
                      fontSize: 20.0),
                ),
              ),
              Padding(
                padding: EdgeInsets.fromLTRB(0, 12, 0, 0),
                child: Container(
                  child: Image.asset('assets/forgot password 1.png'),
                ),
              ),
              new Container(
                height: 440.0,
                color: Colors.transparent,
                child: Container(
                  decoration: new BoxDecoration(
                      color: Colors.blue,
                      borderRadius: new BorderRadius.only(
                        topLeft: const Radius.circular(40.0),
                        topRight: const Radius.circular(40.0),
                      )),
                  child: new Align(
                    alignment: Alignment.topCenter,
                    child: Padding(
                      padding: EdgeInsets.symmetric(vertical: 40),
                      child: Text(
                        'Masukkan Email',
                        style: TextStyle(
                            color: Colors.white,
                            fontSize: 14,
                            fontWeight: FontWeight.bold),
                      ),
                      sizedBox(height: 20,)
                    ), 
                  ),
                ),
              ),
            ],
          ),
        ),
      ),
    );
  }
}

最佳答案

将类的名称更改为您的类名,我在名称下方创建了 TextFormField

        import 'package:flutter/material.dart';
    
    class TabScreen extends StatefulWidget {
      const TabScreen({Key? key}) : super(key: key);
    
      @override
      _TabScreenState createState() => _TabScreenState();
    }
    
    class _TabScreenState extends State<TabScreen> {
      @override
      Widget build(BuildContext context) {
        return Scaffold(
          appBar: AppBar(
            leading: IconButton(onPressed: () {}, icon: Icon(Icons.exit_to_app)),
          ),
          body: SingleChildScrollView(
            child: Center(
              child: Column(
                mainAxisAlignment: MainAxisAlignment.start,
                children: <Widget>[
                  Column(
                    children: [
                      Padding(
                        padding: EdgeInsets.symmetric(
                          vertical: 35.0,
                        ),
                        child: Text(
                          'Forgot Password',
                          style: TextStyle(
                              color: Colors.blue,
                              fontWeight: FontWeight.bold,
                              fontSize: 20.0),
                        ),
                      ),
                      Padding(
                        padding: EdgeInsets.fromLTRB(0, 12, 0, 0),
                        child: Container(
                          child: Icon(Icons.exit_to_app),
                        ),
                      ),
                    ],
                  ),
                  Container(
                    height: 440.0,
                    color: Colors.transparent,
                    child: Container(
                      decoration: new BoxDecoration(
                          color: Colors.blue,
                          borderRadius: new BorderRadius.only(
                            topLeft: const Radius.circular(40.0),
                            topRight: const Radius.circular(40.0),
                          )),
                      child: new Align(
                        alignment: Alignment.topCenter,
                        child: Padding(
                          padding: EdgeInsets.symmetric(vertical: 40),
                          child: Column(
                            children: [
                              Text(
                                'Masukkan Email',
                                style: TextStyle(
                                    color: Colors.white,
                                    fontSize: 14,
                                    fontWeight: FontWeight.bold),
                              ),
                              Container(
                                margin: EdgeInsets.all(15),
                                child: TextFormField(showCursor: true, cursorColor: Colors.white,
                                  style: TextStyle(
                                    fontSize: 18,
                                    color: Colors.white,
                                    fontWeight: FontWeight.w600,
                                  ),
                                  decoration: InputDecoration(
                                    border: OutlineInputBorder(
                                      borderRadius: BorderRadius.circular(10.0),
                                    ),
                                    focusColor: Colors.white,
                                    focusedBorder: OutlineInputBorder(
                                      borderSide:
                                      const BorderSide(color: Colors.black, width: 1.0),
                                      borderRadius: BorderRadius.circular(10.0),
                                    ),
                                    // fillColor: Colors.grey,
    
                                    hintText: "Email",
                                  ),
                                ),
                              ),
                            ],
                          ),
                          // sizedBox(height: 20,)
                        ),
                      ),
                    ),
                  )
                ],
              ),
            ),
          ),
        );
      }
    }

关于android - 位置参数必须出现在命名参数之前,并且 flutter 上的位置参数太多,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/69341032/

相关文章:

php - 在下一个 Android Activity 中显示最近插入 MySQL 数据库的记录以进行编辑

java - Android BLE外围设备数据接收

c# - 是否可以在 Xamarin 表单中隐式应用转换器

Dart - 在初始值设定项中只能访问静态成员

flutter - 必须将非空字符串提供给文本小部件-Flutter Android

java - 安卓系统无法播放声音

java - 当我的应用程序崩溃时,如何向我发送错误数据?

c# - 识别 Visual Studio 中的一次性对象?

visual-studio - 我想在 4 个工作站上使用 VS 2010 Pro,哪种 MSDN 订阅或许可模式最好?

json - 如何在Dart中使用枚举的属性名称将JSON映射到对象