Home > Back-end >  Wrap widget inside text in flutter
Wrap widget inside text in flutter

Time:07-24

How to wrap a widget inside a multiline text in flutter.

Container inside text

CodePudding user response:

You can achieve this with RichText and WidgetSpan. Example from this link:

const Text.rich(
  TextSpan(
    children: <InlineSpan>[
      TextSpan(text: 'Flutter is'),
      WidgetSpan(
        child: SizedBox(
          width: 120,
          height: 50,
          child: Card(
            child: Center(
              child: Text('Hello World!')
            )
          ),
        )
      ),
      TextSpan(text: 'the best!'),
    ],
  )
)
  • Related