Skip to Content
ComponentsPrimitiveInput

PrimitiveInput

A flexible text input component built on Flutter’s EditableText primitive. It provides a clean, composition-ready API without the heavy weight of Material’s TextField.

Overview

PrimitiveInput wraps standard text editing logic in a customizable container that manages focus states, error states, and visual variants.

Primitive Input DemoOpen in new tab ↗

Basic Usage

import 'package:primitive_ui/primitive_ui.dart'; // Default Outline Input PrimitiveInput( placeholder: 'Enter your name', onChanged: (value) => print(value), ) // Search Input with Icons PrimitiveInput( placeholder: 'Search...', leading: Icon(Icons.search), variant: PrimitiveInputVariant.filled, ) // Password Field PrimitiveInput( placeholder: 'Password', obscureText: true, trailing: Icon(Icons.visibility_off), )

API Reference

ParameterTypeRequiredDefaultDescription
placeholderString?nullText displayed when the input is empty.
variantPrimitiveInputVariantoutlineVisual style: outline, filled, or flushed.
sizePrimitiveInputSizemdHeight and padding size: sm, md, lg.
leadingWidget?nullWidget displayed before the text input.
trailingWidget?nullWidget displayed after the text input.
hasErrorboolfalseIf true, changes the border color to indicate an error.
controllerTextEditingController?nullControls the text being edited.

Philosophy

Following the library’s primitive approach, this component uses EditableText directly rather than TextField. This gives us complete control over the decoration container without fighting Material’s default InputDecoration sizing and padding. It is designed to be composed into larger forms rather than being a “smart” form field itself.

Last updated on