Skip to content

Instantly share code, notes, and snippets.

@IhwanID
Last active June 10, 2020 08:42
Show Gist options
  • Save IhwanID/2a4f84ee78eccdcc1d70db500d9b713c to your computer and use it in GitHub Desktop.
Save IhwanID/2a4f84ee78eccdcc1d70db500d9b713c to your computer and use it in GitHub Desktop.
Custom Text Field with callback function
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