Rich text editor for Flutter
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

27 lines
739 B

import 'package:flutter/material.dart';
typedef WidgetWrapper = Widget Function(Widget child);
/// Provides utiulity widgets.
class UtilityWidgets {
const UtilityWidgets._();
/// Conditionally wraps the [child] with [Tooltip] widget if [message]
/// is not null and not empty.
static Widget maybeTooltip({
required Widget child,
String? message,
}) =>
(message?.isNotEmpty ?? false)
? Tooltip(message: message, child: child)
: child;
/// Conditionally wraps the [child] with [wrapper] widget if [enabled]
/// is true.
static Widget maybeWidget({
required WidgetWrapper wrapper,
required Widget child,
bool enabled = false,
}) =>
enabled ? wrapper(child) : child;
}