mirror of
https://github.com/flame-engine/flame.git
synced 2025-11-03 20:36:31 +08:00
linting
This commit is contained in:
@ -46,7 +46,8 @@ class TextBoxComponent extends PositionComponent with Resizable {
|
||||
|
||||
TextBoxConfig get boxConfig => _boxConfig;
|
||||
|
||||
TextBoxComponent(String text, {
|
||||
TextBoxComponent(
|
||||
String text, {
|
||||
TextConfig config,
|
||||
TextBoxConfig boxConfig,
|
||||
}) {
|
||||
|
||||
@ -27,7 +27,7 @@ class TextComponent extends PositionComponent {
|
||||
_updateBox();
|
||||
}
|
||||
|
||||
TextComponent(this._text, {TextConfig config }) {
|
||||
TextComponent(this._text, {TextConfig config}) {
|
||||
_config = config ?? TextConfig();
|
||||
_updateBox();
|
||||
}
|
||||
|
||||
@ -1,12 +1,11 @@
|
||||
|
||||
/// Simple class to cache values on the cache
|
||||
///
|
||||
class MemoryCache <K, V> {
|
||||
class MemoryCache<K, V> {
|
||||
final Map<K, V> _cache = {};
|
||||
final List<K> _addedOrder = [];
|
||||
final int cacheSize;
|
||||
|
||||
MemoryCache({ this.cacheSize = 10 });
|
||||
MemoryCache({this.cacheSize = 10});
|
||||
|
||||
void setValue(K key, V value) {
|
||||
if (!_cache.containsKey(key)) {
|
||||
|
||||
@ -53,7 +53,8 @@ class TextConfig {
|
||||
/// For proper fonts of languages like Hebrew or Arabic, replace this with [TextDirection.rtl].
|
||||
final TextDirection textDirection;
|
||||
|
||||
final MemoryCache _textPainterCache = MemoryCache<String, material.TextPainter>();
|
||||
final MemoryCache _textPainterCache =
|
||||
MemoryCache<String, material.TextPainter>();
|
||||
|
||||
/// Creates a constant [TextConfig] with sensible defaults.
|
||||
///
|
||||
@ -98,18 +99,18 @@ class TextConfig {
|
||||
material.TextPainter toTextPainter(String text) {
|
||||
if (!_textPainterCache.containsKey(text)) {
|
||||
final material.TextStyle style = material.TextStyle(
|
||||
color: color,
|
||||
fontSize: fontSize,
|
||||
fontFamily: fontFamily,
|
||||
color: color,
|
||||
fontSize: fontSize,
|
||||
fontFamily: fontFamily,
|
||||
);
|
||||
final material.TextSpan span = material.TextSpan(
|
||||
style: style,
|
||||
text: text,
|
||||
style: style,
|
||||
text: text,
|
||||
);
|
||||
final material.TextPainter tp = material.TextPainter(
|
||||
text: span,
|
||||
textAlign: textAlign,
|
||||
textDirection: textDirection,
|
||||
text: span,
|
||||
textAlign: textAlign,
|
||||
textDirection: textDirection,
|
||||
);
|
||||
tp.layout();
|
||||
|
||||
|
||||
@ -29,4 +29,3 @@ void main() {
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user