Adding method for text

This commit is contained in:
Luan Nico
2017-10-29 19:35:01 -02:00
parent 4b9c0bce73
commit eff7bc814d

View File

@ -5,6 +5,8 @@ import 'package:flutter/services.dart';
import 'dart:async';
import 'dart:ui';
import 'dart:ui' as ui show TextStyle;
class Util {
Future<Size> initialDimensions() async {
// https://github.com/flutter/flutter/issues/5259
@ -26,6 +28,13 @@ class Util {
void enableEvents() {
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 {