Home > Net >  Positional arguments must occur before named arugments, And Too many positional arguments on flutter
Positional arguments must occur before named arugments, And Too many positional arguments on flutter

Time:09-27

I had some error that says "Positional arguments must occur before named arguments" and " too many positional arguments" when i wanted to add an textformfield on my code, the design will looks like this

I need put the textformfield below the text how do i add the textformfield without making any error?

heres my code

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

CodePudding user response:

Change the name of class as your class name, I created TextFormField below the name

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

CodePudding user response:

use this code, it will work

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: Column(
                      children: [
                        Padding(
                          padding: EdgeInsets.symmetric(vertical: 40),
                          child: Text(
                            'Masukkan Email',
                            style: TextStyle(
                                color: Colors.white,
                                fontSize: 14,
                                fontWeight: FontWeight.bold),
                          ),
                        ),
                        TextFormField(.....)
                      ],
                    ),
                  ),
                ),
              ),
              SizedBox(
                height: 20,
              )
            ],
          ),
        ),
      ),
    );
  }
}

CodePudding user response:

I don't really understand the error you are getting. but here's how to put TextFormField below

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:  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),
                  ),
                  SizedBox(height: 20,),
                  TextFormField(decoration: InputDecoration(
                    fillColor: Colors.white,
                    filled: true
                  ),),
                ],
              ),
            ),
        ),
      ),
    ),
  • Related