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.
45 lines
1.1 KiB
45 lines
1.1 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) {
|
|
var spans = (this as AutoSizeText).textSpan;
|
|
if (spans != null) {
|
|
spans = spans.match(match);
|
|
return Text.rich(spans);
|
|
}
|
|
if (this.runtimeType == Text) {
|
|
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;
|
|
}
|
|
}
|