@@ -7,9 +7,9 @@ import 'package:flutter/material.dart';
77import 'common.dart' ;
88import 'theme/theme.dart' ;
99
10- /// A DevTools-styled text field with a suffix action to clear the search field .
11- final class DevToolsClearableTextField extends StatelessWidget {
12- DevToolsClearableTextField ({
10+ /// A DevTools-styled text field.
11+ final class DevToolsTextField extends StatelessWidget {
12+ DevToolsTextField ({
1313 super .key,
1414 TextEditingController ? controller,
1515 this .labelText,
@@ -78,15 +78,7 @@ final class DevToolsClearableTextField extends StatelessWidget {
7878 height: inputDecorationElementHeight,
7979 child: Row (
8080 mainAxisSize: MainAxisSize .min,
81- children: [
82- ...additionalSuffixActions,
83- InputDecorationSuffixButton .clear (
84- onPressed: () {
85- controller.clear ();
86- onChanged? .call ('' );
87- },
88- ),
89- ],
81+ children: additionalSuffixActions,
9082 ),
9183 ),
9284 ),
@@ -95,6 +87,58 @@ final class DevToolsClearableTextField extends StatelessWidget {
9587 }
9688}
9789
90+ /// A DevTools-styled text field with a suffix action to clear the search field.
91+ final class DevToolsClearableTextField extends StatelessWidget {
92+ DevToolsClearableTextField ({
93+ super .key,
94+ TextEditingController ? controller,
95+ this .labelText,
96+ this .hintText,
97+ this .prefixIcon,
98+ this .additionalSuffixActions = const < Widget > [],
99+ this .onChanged,
100+ this .onSubmitted,
101+ this .autofocus = false ,
102+ this .enabled,
103+ this .roundedBorder = false ,
104+ }) : controller = controller ?? TextEditingController ();
105+
106+ final TextEditingController controller;
107+ final String ? hintText;
108+ final Widget ? prefixIcon;
109+ final List <Widget > additionalSuffixActions;
110+ final String ? labelText;
111+ final void Function (String )? onChanged;
112+ final void Function (String )? onSubmitted;
113+ final bool autofocus;
114+ final bool ? enabled;
115+ final bool roundedBorder;
116+
117+ @override
118+ Widget build (BuildContext context) {
119+ return DevToolsTextField (
120+ controller: controller,
121+ labelText: labelText,
122+ hintText: hintText,
123+ prefixIcon: prefixIcon,
124+ additionalSuffixActions: [
125+ ...additionalSuffixActions,
126+ InputDecorationSuffixButton .clear (
127+ onPressed: () {
128+ controller.clear ();
129+ onChanged? .call ('' );
130+ },
131+ ),
132+ ],
133+ onChanged: onChanged,
134+ onSubmitted: onSubmitted,
135+ autofocus: autofocus,
136+ enabled: enabled,
137+ roundedBorder: roundedBorder,
138+ );
139+ }
140+ }
141+
98142/// A DevTools-styled icon action button intended to be used as an
99143/// [InputDecoration.suffix] widget.
100144final class InputDecorationSuffixButton extends StatelessWidget {
0 commit comments