title property
Builder function for title of search app bar, expected TextField. Defaults to null.
You do NOT need to overwrite this. But if you still want to, please use snippet below as template:
...
title: (context) {
final mainWidget = AppBarWithSearchSwitch.of(context)!;
return Directionality(
textDirection: Directionality.of(context),
child: TextField(
focusNode: mainWidget.searchFocusNode,
keyboardType: mainWidget.keyboardType,
decoration: InputDecoration(
hintText: mainWidget.fieldHintText,
enabledBorder: InputBorder.none,
focusedBorder: InputBorder.none,
border: InputBorder.none,
),
// Don't use parameter `onChanged` here:
// - it don't catch cases then textEditController changed directly,
// - it already subscribed to textEditController.
onSubmitted: mainWidget.submitCallbackForTextField,
autofocus: true,
// or autofocus: !mainWidget.isSpeechMode.value, // don't show keyboard on speech recognition
controller: mainWidget.textEditingController,
),
);
}
}
Implementation
final Widget Function(BuildContext context)? title;