Flutter auto line break in Text Widget

Issue

I am very new to Flutter.

I am currently writing a simple memo app, with a list of titles shown like this:
titles

Those Text widgets should be separate, but I have no idea how to break text line.
Being specific, which widget should be used for the code below?

import 'package:flutter/material.dart';

void main() => runApp(const AppMain());

class AppMain extends StatelessWidget {
  const AppMain({super.key});

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Memo',
      home: Scaffold(
        body: SafeArea(
            child: <WHICH WIDGET SHOULD I USE>(
                children: [
                    Text("The first text"),
                    Text("Second Memo Title"),
                    Text("Third One"),
                    Text("and so on"),
                ],
      ),
      debugShowCheckedModeBanner: false,
    );
  }
}

I have tried Wrap widget, but it does not break the Text in it.

Thanks.

Solution

Use RichText widget which takes list of TextSpan widgets.

Answered By – Rahul

Answer Checked By – Senaida (FlutterFixes Volunteer)

Leave a Reply

Your email address will not be published. Required fields are marked *