Now I am using this code to render some text:
import 'package:flutter/material.dart';
void main() async {
runApp(MaterialApp(
home: Scaffold(
body: Form(
key: GlobalKey(),
child: Center(
child: Row(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisSize: MainAxisSize.max,
children: [
SelectableText.rich(
TextSpan(
children: [
TextSpan(text: "sfwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwww"),
],
),
),
],
),
),
),
)));
}
but the text was overflow, is it possible to make it auto wrap accord the screen size and do not overflow? The rendered text was a dynamic string and I did not know the length.
CodePudding user response:
Wrap the SelectableText
with the Flexible widget.
As:
Flexible(child:
SelectableText.rich(
TextSpan(
children: [
TextSpan(text: "sfwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwww"),
],
),
)),