Code
// FlockUI Component: Text Field (Filled)
// Description: A Material 3 filled text field with label and hint text.
// Category: Forms
// External Dependencies: none
//
// This is a template component. When creating new components, follow this structure:
// 1. Add header comments describing your component
// 2. The class must extend `StatefulWidget` — you can name it anything you like
// 3. If using external packages, list them in the header comments above
// 4. Keep the entire component in a single .dart file
import 'package:flutter/material.dart';
class FilledTextField extends StatefulWidget {
const FilledTextField({super.key});
@override
State<FilledTextField> createState() => _FilledTextFieldState();
}
class _FilledTextFieldState extends State<FilledTextField> {
final _controller = TextEditingController();
@override
void dispose() {
_controller.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) {
final theme = Theme.of(context);
return Padding(
padding: const EdgeInsets.symmetric(horizontal: 16),
child: SizedBox(
width: 260,
child: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
// Label
Text(
'Full Name',
style: theme.textTheme.titleSmall?.copyWith(
fontWeight: FontWeight.w600,
),
),
const SizedBox(height: 8),
// Filled text field
TextField(
controller: _controller,
decoration: InputDecoration(
hintText: 'Enter your full name',
prefixIcon: const Icon(Icons.person_outline),
filled: true,
fillColor: theme.colorScheme.surfaceContainerHighest,
border: OutlineInputBorder(
borderRadius: BorderRadius.circular(12),
borderSide: BorderSide.none,
),
),
textCapitalization: TextCapitalization.words,
),
const SizedBox(height: 6),
// Helper text
Text(
'Your name will appear on your profile.',
style: theme.textTheme.bodySmall?.copyWith(
color: theme.colorScheme.onSurfaceVariant,
),
),
],
),
),
);
}
}
Preview