extractButtonText static method
提取按钮文本
Implementation
static String extractButtonText(Widget widget) {
try {
if (widget is ElevatedButton && widget.child is Text) {
final text = widget.child as Text;
return text.data ?? '';
}
if (widget is TextButton && widget.child is Text) {
final text = widget.child as Text;
return text.data ?? '';
}
if (widget is OutlinedButton && widget.child is Text) {
final text = widget.child as Text;
return text.data ?? '';
}
if (widget is IconButton && widget.tooltip != null) {
return widget.tooltip!;
}
if (widget is FloatingActionButton && widget.tooltip != null) {
return widget.tooltip!;
}
return '';
} catch (e) {
return '';
}
}