Last active
June 10, 2020 08:42
-
-
Save IhwanID/2a4f84ee78eccdcc1d70db500d9b713c to your computer and use it in GitHub Desktop.
Custom Text Field with callback function
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'package:flutter/material.dart'; | |
class CustomTextField extends StatelessWidget { | |
final TextEditingController controller; | |
final String labelText; | |
final bool isObscureText; | |
final Function(String) onChanged; | |
CustomTextField( | |
{this.controller, | |
this.labelText, | |
this.isObscureText = false, | |
this.onChanged}); | |
@override | |
Widget build(BuildContext context) { | |
return TextField( | |
controller: controller, | |
decoration: InputDecoration(labelText: labelText), | |
obscureText: isObscureText, | |
onChanged: (text) { | |
onChanged(text); | |
}, | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment