Add TextBoxConfig options and fix TextBoxComponent bugs (#534)

* Add TextBoxConfig options and fix TextBxoComponent bugs

* Add changelog entry

* Fix snackbar deprecation

* All examples to have publish to none

* One argument per line

* No explicit types for local variables

* Cache the width

* Fix formatting
This commit is contained in:
Lukas Klingsbo
2020-11-22 21:45:10 +01:00
committed by renancaraujo
parent 5dc93e1987
commit d09d2bd449
30 changed files with 140 additions and 61 deletions

View File

@ -20,16 +20,31 @@ TextConfig tiny = regular.withFontSize(12.0);
class MyTextBox extends TextBoxComponent {
MyTextBox(String text)
: super(text, config: tiny, boxConfig: TextBoxConfig(timePerChar: 0.05));
: super(
text,
config: tiny,
boxConfig: TextBoxConfig(
timePerChar: 0.05,
growingBox: true,
margins: const EdgeInsets.symmetric(horizontal: 10, vertical: 15),
),
);
@override
void drawBackground(Canvas c) {
final Rect rect = Rect.fromLTWH(0, 0, width, height);
c.drawRect(rect, Paint()..color = const Color(0xFFFF00FF));
final margin = boxConfig.margins;
final Rect innerRect = Rect.fromLTWH(
margin.left,
margin.top,
width - margin.horizontal,
height - margin.vertical,
);
c.drawRect(
rect.deflate(boxConfig.margin),
innerRect,
Paint()
..color = BasicPalette.black.color
..color = BasicPalette.white.color
..style = PaintingStyle.stroke);
}
}