I want to create a custom widget for TextField widget and I want to transfer all properties to my custom widget. I have used in React Native ...props syntax.

My custom Widget:

return Container(
  decoration: BoxDecoration(
      color: Colors.white,
      border: Border.all(
        color: Colors.grey,
        width: 1,
      ),
      borderRadius: BorderRadius.all(Radius.circular(5))),
  margin: margin,
  padding: EdgeInsets.symmetric(horizontal: 10),
  child: TextField(
    decoration: InputDecoration(
        labelStyle: TextStyle(color: Colors.black),
        labelText: label,
        border: InputBorder.none,
        counterText: ""),
    textDirection: TextDirection.ltr,
    //I want to put here custom widget properties
  ),
);

I want to use custom widget like:

Input(
    label: "Şifre",
    margin: EdgeInsets.only(bottom: marginBottom),
    obscureText: true, //**
    textInputAction: TextInputAction.send, //**
    controller: passwordController, //**
)

I want to transfer commented ** properties to custom widget commented line

1 Answers

0
Miguel Ruivo On

You are using a TextField but look for a TextFormField instead. It gathers all the properties you are asking for.

  TextFormField(
      decoration: InputDecoration(
        labelStyle: TextStyle(color: Colors.black),
        labelText: label,
        border: InputBorder.none,
        counterText: ""),
        obscureText: true,
        textInputAction: TextInputAction.send,
        controller: passwordController,
    );