helper property

Widget? helper
final

Optional widget that appears below the InputDecorator.child.

If non-null, the helper is displayed below the InputDecorator.child, in the same location as error. If a non-null error or errorText value is specified then the helper is not shown.

This example shows a TextField with a Text.rich widget as the helper. The widget contains Text and Icon widgets with different styles.

To see it in action, copy and run this code snippet on DartPad.

import 'package:material_ui/material_ui.dart';

/// Flutter code sample for [InputDecoration.helper].

void main() => runApp(const HelperExampleApp());

class HelperExampleApp extends StatelessWidget {
  const HelperExampleApp({super.key});

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(title: const Text('InputDecoration.helper Sample')),
        body: const HelperExample(),
      ),
    );
  }
}

class HelperExample extends StatelessWidget {
  const HelperExample({super.key});

  @override
  Widget build(BuildContext context) {
    return const Center(
      child: TextField(
        decoration: InputDecoration(
          helper: Text.rich(
            TextSpan(
              children: <InlineSpan>[
                WidgetSpan(child: Text('Helper Text ')),
                WidgetSpan(
                  child: Icon(
                    Icons.help_outline,
                    color: Colors.blue,
                    size: 20.0,
                  ),
                ),
              ],
            ),
          ),
        ),
      ),
    );
  }
}

Only one of helper and helperText can be specified.

Implementation

// TODO(framework): Replace the following block with a @dartpad directive
// when it's supported. https://github.com/dart-lang/dartdoc/issues/4123
/// {@macro material_ui.dartpad_guide}
///
/// {@example /example/lib/input_decorator/input_decoration.helper.0.dart#body}
///
/// </callout-box>
///
/// Only one of [helper] and [helperText] can be specified.
final Widget? helper;