Skip to content

Commit 8805d48

Browse files
committed
compose [nfc]: Make _ContentInput stateless
The state that had been here now lives on the TypingNotifier widget.
1 parent 4c0369f commit 8805d48

File tree

1 file changed

+7
-12
lines changed

1 file changed

+7
-12
lines changed

lib/widgets/compose_box.dart

+7-12
Original file line numberDiff line numberDiff line change
@@ -486,7 +486,7 @@ class _TypingNotifierState extends State<_TypingNotifier> with WidgetsBindingObs
486486
Widget build(BuildContext context) => widget.child;
487487
}
488488

489-
class _ContentInput extends StatefulWidget {
489+
class _ContentInput extends StatelessWidget {
490490
const _ContentInput({
491491
required this.narrow,
492492
required this.controller,
@@ -497,11 +497,6 @@ class _ContentInput extends StatefulWidget {
497497
final ComposeBoxController controller;
498498
final String hintText;
499499

500-
@override
501-
State<StatefulWidget> createState() => _ContentInputState();
502-
}
503-
504-
class _ContentInputState<T extends _ContentInput> extends State<T> {
505500
static double maxHeight(BuildContext context) {
506501
final clampingTextScaler = MediaQuery.textScalerOf(context)
507502
.clamp(maxScaleFactor: 1.5);
@@ -532,9 +527,9 @@ class _ContentInputState<T extends _ContentInput> extends State<T> {
532527
final designVariables = DesignVariables.of(context);
533528

534529
return ComposeAutocomplete(
535-
narrow: widget.narrow,
536-
controller: widget.controller.content,
537-
focusNode: widget.controller.contentFocusNode,
530+
narrow: narrow,
531+
controller: controller.content,
532+
focusNode: controller.contentFocusNode,
538533
fieldViewBuilder: (context) => ConstrainedBox(
539534
constraints: BoxConstraints(maxHeight: maxHeight(context)),
540535
// This [ClipRect] replaces the [TextField] clipping we disable below.
@@ -543,8 +538,8 @@ class _ContentInputState<T extends _ContentInput> extends State<T> {
543538
top: _verticalPadding, bottom: _verticalPadding,
544539
color: designVariables.composeBoxBg,
545540
child: TextField(
546-
controller: widget.controller.content,
547-
focusNode: widget.controller.contentFocusNode,
541+
controller: controller.content,
542+
focusNode: controller.contentFocusNode,
548543
// Let the content show through the `contentPadding` so that
549544
// our [InsetShadowBox] can fade it smoothly there.
550545
clipBehavior: Clip.none,
@@ -570,7 +565,7 @@ class _ContentInputState<T extends _ContentInput> extends State<T> {
570565
// that 54px distance while also making the scrolling work like
571566
// this and offering two lines of touchable area.
572567
contentPadding: const EdgeInsets.symmetric(vertical: _verticalPadding),
573-
hintText: widget.hintText,
568+
hintText: hintText,
574569
hintStyle: TextStyle(
575570
color: designVariables.textInput.withFadedAlpha(0.5))))))));
576571
}

0 commit comments

Comments
 (0)