9Patch alternative in Flutter?

1k Views Asked by At

How do I implement a design as show below?

screenshot

The image shows a play button with text. I won't be creating it as a container with gradient of some sort. This leaves me with 2 options

  1. Define 2 growable rectangles before and after the text, which can be used to scale with width of the image.
  2. Define 1 growable rectangle for image without text and then somehow place the text within the image and also allow the button to have scalable size.

But how do I do any of that without 9patch of native android?

EDIT:

Container(
//        width: MediaQuery.of(context).size.width/2,
        child: FlatButton(
          onPressed: () => print('onPressed'),
          padding: EdgeInsets.zero,
          child: Ink.image(
            image: FileImage(File('btn_default_normal.9.png')),
            centerSlice: Rect.fromLTWH(18 - 1.0, 36 - 1.0, 2, 2),
            child: Text(
              'press me',
              style: TextStyle(color: Colors.blue, fontSize: 20),
            ),
          ),
        ),
      )

How to set the width? Uncommenting the width gives me screenshot

which means the button is taking half the screen width but not expanding.

0

There are 0 best solutions below