Skip to content

Commit

Permalink
Cards look a bit better
Browse files Browse the repository at this point in the history
  • Loading branch information
srgtuszy committed Oct 22, 2024
1 parent 6447949 commit 2005a26
Showing 1 changed file with 22 additions and 27 deletions.
49 changes: 22 additions & 27 deletions lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -230,34 +230,29 @@ class _HomePageState extends State<HomePage> {
builder: (context, snapshot) {
if (snapshot.hasData) {
final tips = snapshot.data!;
return LayoutBuilder(
builder: (context, constraints) {
final double cardWidth = (constraints.maxWidth - 10) / 2;
return GridView.builder(
shrinkWrap: true,
physics: const NeverScrollableScrollPhysics(),
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: 2,
crossAxisSpacing: 10,
mainAxisSpacing: 10,
childAspectRatio: cardWidth / 100,
),
itemCount: tips.length,
itemBuilder: (context, index) {
final tip = tips[index];
return Card(
child: Padding(
padding: const EdgeInsets.all(10),
child: Center(
child: Text(
tip.tip,
textAlign: TextAlign.center,
style: const TextStyle(fontSize: 14),
),
),
return GridView.builder(
shrinkWrap: true,
gridDelegate: const SliverGridDelegateWithMaxCrossAxisExtent(
maxCrossAxisExtent: 200,
mainAxisSpacing: 10,
crossAxisSpacing: 10,
),
itemCount: tips.length,
itemBuilder: (context, index) {
final tip = tips[index];
return Card(
child: Padding(
padding: const EdgeInsets.all(10),
child: Center(
child: Text(
tip.tip,
textAlign: TextAlign.center,
style: const TextStyle(fontSize: 14),
maxLines: 6,
overflow: TextOverflow.fade,
),
);
},
),
),
);
},
);
Expand Down

0 comments on commit 2005a26

Please sign in to comment.