input_box.dart 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. import 'package:flutter/material.dart';
  2. class InputBoxContainer extends StatefulWidget {
  3. InputBoxContainer({Key key, this.onChange, this.icon, this.type, this.value = "", this.submit,
  4. this.password = false, this.iconColor = Colors.grey, this.hintText, this.focusNode, this.action }) : super(key: key);
  5. final onChange;
  6. final String value;
  7. final IconData icon;
  8. final bool password;
  9. final Color iconColor;
  10. final String hintText;
  11. final Function submit;
  12. final TextInputAction action;
  13. final FocusNode focusNode;
  14. final TextInputType type;
  15. @override
  16. State<StatefulWidget> createState() {
  17. return InputBoxContainerBuilder();
  18. }
  19. }
  20. class InputBoxContainerBuilder extends State<InputBoxContainer> {
  21. Widget build(BuildContext context) {
  22. return Container(
  23. padding: EdgeInsets.only(left: 10.0, right: 10.0, top: 2.0, bottom: 2.0),
  24. margin: EdgeInsets.only(bottom: 30.0),
  25. decoration: BoxDecoration(
  26. borderRadius: BorderRadius.circular(100.0),
  27. border: Border.all(
  28. width: 1.0,
  29. style: BorderStyle.solid,
  30. color: Color.fromRGBO(0, 0, 0, 0.1))),
  31. child: TextField(
  32. focusNode: widget.focusNode,
  33. onSubmitted: widget.submit,
  34. textInputAction: widget.action,
  35. controller: TextEditingController.fromValue(TextEditingValue(text: widget.value)),
  36. keyboardType: widget.type,
  37. obscureText: widget.password,
  38. onChanged: widget.onChange,
  39. decoration: InputDecoration(
  40. border: InputBorder.none,
  41. hintText: widget.hintText,
  42. icon: widget.icon != null ? Icon(widget.icon, color: widget.iconColor) : null),
  43. ),
  44. );
  45. }
  46. }