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.
ansu_ui/lib/extension/widget_extension.dart

46 lines
1.2 KiB

import 'package:ansu_ui/utils/match_text.dart';
import 'package:auto_size_text_pk/auto_size_text_pk.dart';
import 'package:flutter/material.dart';
import 'Text_extension.dart';
extension WidgetExt on Widget {
Widget paddingExt(double horizontal, [double vertical = 0]) =>
Padding(
padding: EdgeInsets.symmetric(
horizontal: horizontal,
vertical: vertical,
),
child: this,
);
Widget match(String match) {
if (this.runtimeType == Text) {
// var spans = (this as Text).textSpan;
// if (spans != null) {
// spans = spans.match(match);
// return Text.rich(spans);
// }
return MatchText(
matchText: match,
text: (this as Text).data ?? '',
style: (this as Text).style,
);
}
if (this.runtimeType == AutoSizeText) {
var spans = (this as AutoSizeText).textSpan;
if (spans != null) {
spans = spans.match(match);
return AutoSizeText.rich(spans);
}
return MatchText(
matchText: match,
text: (this as AutoSizeText).data ?? '',
style: (this as AutoSizeText).style,
);
}
return this;
}
}