Skip to content

Instantly share code, notes, and snippets.

@Luckey-Elijah
Last active February 9, 2021 18:50
Show Gist options
  • Save Luckey-Elijah/395c659d3be9ade5092b7cc109c8e987 to your computer and use it in GitHub Desktop.
Save Luckey-Elijah/395c659d3be9ade5092b7cc109c8e987 to your computer and use it in GitHub Desktop.
Wrapping text for a row widget
// Code snippet added to hleo answer StackOverflow question: https://stackoverflow.com/questions/66124352
import 'package:flutter/material.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
debugShowCheckedModeBanner: false,
theme: ThemeData(
primarySwatch: Colors.blue,
),
home: HomePage(),
);
}
}
class HomePage extends StatelessWidget {
static const title = 'Flutter Demo Home Page';
HomePage({Key key}) : super(key: key);
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: Colors.black,
body: Row(
children: [
Text('Row 1, Text 1',
style: TextStyle(fontSize: 24, color: Colors.red)),
SizedBox(width: 8),
Text('Row 1, Text 2',
style: TextStyle(fontSize: 24, color: Colors.orange)),
SizedBox(width: 8),
Flexible(
child: Container(
child: Text(
'Row 1, Text 3',
overflow: TextOverflow.ellipsis,
style: TextStyle(fontSize: 24, color: Colors.yellow),
),
),
),
SizedBox(width: 8),
Text('Row 1, Text 4',
style: TextStyle(fontSize: 24, color: Colors.green)),
SizedBox(width: 8),
],
),
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment