arturomf
arturomf

Reputation: 21

Is there any way of using Text with spritewidget in Flutter?

I'm developing a game in Flutter with spritewidget library. I'd like to know if is it possible to use text inside a SpriteWidget.

I know i can use regular Flutter widgets but i need that the text size is relative to SpriteWidget so it can be consistently shown in different screen sizes.

I have searched library documentation but i haven't found anything related to text render.

Any suggestion would be appreciated!!

Upvotes: 2

Views: 243

Answers (1)

Vik
Vik

Reputation: 341

You can absolutely use text inside a SpriteWidget. There is the Label node for that particular purpose. If you need more advanced text rendering, you can use the code from the Label as your starting point.

Example:

Label label = Label(
  'My text label',
  textAlign: TextAlign.center,
  textStyle: new TextStyle(
    fontFamily: 'Orbitron',
    letterSpacing: 10.0,
    color: Colors.white,
    fontSize: 24.0,
    fontWeight: FontWeight.w600
  )
);
addChild(label);

Upvotes: 2

Related Questions