mirror of
https://github.com/flame-engine/flame.git
synced 2025-11-01 09:39:12 +08:00
Adding method for text
This commit is contained in:
@ -5,6 +5,8 @@ import 'package:flutter/services.dart';
|
|||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
import 'dart:ui';
|
import 'dart:ui';
|
||||||
|
|
||||||
|
import 'dart:ui' as ui show TextStyle;
|
||||||
|
|
||||||
class Util {
|
class Util {
|
||||||
Future<Size> initialDimensions() async {
|
Future<Size> initialDimensions() async {
|
||||||
// https://github.com/flutter/flutter/issues/5259
|
// https://github.com/flutter/flutter/issues/5259
|
||||||
@ -26,6 +28,13 @@ class Util {
|
|||||||
void enableEvents() {
|
void enableEvents() {
|
||||||
new _CustomBinder();
|
new _CustomBinder();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Paragraph text(String text, { double fontSize = 24.0, Color color = Colors.white, fontFamily: 'Arial', double maxWidth = 180.0 }) {
|
||||||
|
ParagraphBuilder paragraph = new ParagraphBuilder(new ParagraphStyle());
|
||||||
|
paragraph.pushStyle(new ui.TextStyle(color: color, fontSize: fontSize, fontFamily: fontFamily));
|
||||||
|
paragraph.addText(text);
|
||||||
|
return paragraph.build()..layout(new ParagraphConstraints(width: maxWidth));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class _CustomBinder extends BindingBase with ServicesBinding {
|
class _CustomBinder extends BindingBase with ServicesBinding {
|
||||||
|
|||||||
Reference in New Issue
Block a user