defaultTitleBuilder method
build title
Implementation
Widget? defaultTitleBuilder() {
AnythingPickerOptions options = getOptions;
Widget? getTextWidget() {
String? mTitle = widget.title;
if (mTitle == null) {
return null;
}
Widget textView = Text(
mTitle,
style: options.titleStyle,
maxLines: options.titleMaxLines,
overflow: options.titleOverflow,
);
var onTap = widget.funcOfTitleOnTapped;
if (onTap != null) {
/// Important!!! do not use result = Builder... for reusing the return statement, cause dart do a reference copy ...
return Builder(builder: (context) => GestureDetector(onTap: () => onTap(this, context), child: textView));
}
return textView;
}
/// title widget
Widget? _widget = getTextWidget();
/// title tails
List<Widget>? titleTailWidgets = options.titleTailWidgets;
/// https://stackoverflow.com/a/69116599 /// Wrap with [Flexible].
bool _isWrapFlexible = titleTailWidgets != null && options.titleWrapFlexible;
Widget? titleWidget = _isWrapFlexible && _widget != null ? Flexible(child: _widget) : _widget;
if (titleWidget == null && titleTailWidgets == null) {
return null;
}
if (titleTailWidgets != null) {
List<Widget> children = [...titleTailWidgets];
if (titleWidget != null) {
children.insert(0, titleWidget);
}
return Row(children: children);
}
return titleWidget;
}