Skip to content

Instantly share code, notes, and snippets.

@kostasoft
Last active February 15, 2023 20:57
Show Gist options
  • Select an option

  • Save kostasoft/1b4b6168b44ea9428137bb26fafdfcb0 to your computer and use it in GitHub Desktop.

Select an option

Save kostasoft/1b4b6168b44ea9428137bb26fafdfcb0 to your computer and use it in GitHub Desktop.
import 'package:flutter/material.dart';
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
Widget item(String title, String text, Color background) => ColoredBox(
color: background,
child: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
ColoredBox(
color: Colors.blueGrey,
child: Padding(padding: const EdgeInsets.all(8.0), child: Text(title)),
),
Padding(padding: const EdgeInsets.all(8.0), child: Text(text)),
]));
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter App',
home: Scaffold(
backgroundColor: Colors.white,
body: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
item('short title', 'looooooooooooooooong text', Colors.grey),
const SizedBox(height: 8.0),
item('loooooooooooooong title', 'short text', Colors.grey),
],
),
),
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment