Skip to content

Instantly share code, notes, and snippets.

@harkairt
Last active May 28, 2024 12:41
Show Gist options
  • Save harkairt/50a991df642728c5900770aee733dc21 to your computer and use it in GitHub Desktop.
Save harkairt/50a991df642728c5900770aee733dc21 to your computer and use it in GitHub Desktop.
wrap
import 'package:flutter/material.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
body: Wrap(
children: [
for (var i = 0; i < 100; i++)
_Channel(
iconData: Icons.ad_units,
title: 'title $i',
),
],
),
),
);
}
}
class _Channel extends StatelessWidget {
const _Channel({
required this.iconData,
required this.title,
});
final IconData iconData;
final String title;
@override
Widget build(BuildContext context) {
return ConstrainedBox(
constraints: const BoxConstraints(minWidth: 60, maxWidth: 200),
child: Container(
padding: const EdgeInsets.all(8),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(16),
border: Border.all(color: Colors.green, strokeAlign: 1),
color: Colors.yellow.shade100,
),
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
Icon(
iconData,
size: 24,
),
Text(
title,
),
],
),
),
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment