Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import 'package:flutter/material.dart';
- import 'package:flutter/services.dart';
- import 'package:flutter/widgets.dart';
- class InputField extends StatelessWidget {
- final IconData icon;
- final String hint;
- final bool obscure;
- final Stream<String> stream;
- final Function(String) onChanged;
- const InputField({
- Key key,
- this.icon,
- this.hint,
- this.obscure,
- this.stream,
- this.onChanged,
- }) : super(key: key);
- @override
- Widget build(BuildContext context) {
- return StreamBuilder<String>(
- stream: stream,
- initialData: "",
- builder: (context, snapshot) {
- print("Stream data: ${snapshot.data}");
- return TextField(
- onChanged: onChanged,
- decoration: InputDecoration(
- icon: Icon(icon, color: Colors.grey[600]),
- hintText: hint,
- hintStyle: TextStyle(color: Colors.grey[600]),
- focusedBorder: UnderlineInputBorder(
- borderSide: BorderSide(color: Colors.green),
- ),
- contentPadding: EdgeInsets.only(
- left: 5,
- right: 30,
- bottom: 30,
- top: 30,
- ),
- errorText: snapshot.hasError ? snapshot.error : null,
- ),
- style: TextStyle(color: Colors.grey[600]),
- obscureText: obscure,
- );
- },
- );
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment