mirror of
https://github.com/wger-project/flutter.git
synced 2026-12-01 02:02:35 +01:00
50 lines
1.3 KiB
Dart
50 lines
1.3 KiB
Dart
import 'package:flutter/material.dart';
|
|
|
|
/// NutritionTile is similar to a non-interactive ListTile,
|
|
/// but uses a fixed, easy to understand layout.
|
|
class NutritionTile extends StatelessWidget {
|
|
final Widget? leading; // always constrained to 40px wide
|
|
final double vPadding;
|
|
final Widget? title;
|
|
final Widget? subtitle;
|
|
final Widget? trailing; // always constrained to 20px wide
|
|
|
|
const NutritionTile({
|
|
this.leading,
|
|
this.title,
|
|
this.subtitle,
|
|
this.trailing,
|
|
this.vPadding = 8,
|
|
});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Padding(
|
|
padding: EdgeInsets.symmetric(horizontal: 8.0, vertical: vPadding),
|
|
child: Row(
|
|
mainAxisSize: MainAxisSize.max,
|
|
children: [
|
|
ConstrainedBox(
|
|
constraints: const BoxConstraints(minWidth: 40, maxWidth: 40),
|
|
child: leading ?? const SizedBox(width: 40),
|
|
),
|
|
const SizedBox(width: 8),
|
|
Expanded(
|
|
child: Column(
|
|
children: [
|
|
?title,
|
|
?subtitle,
|
|
],
|
|
),
|
|
),
|
|
const SizedBox(width: 8),
|
|
ConstrainedBox(
|
|
constraints: const BoxConstraints(minWidth: 20, maxWidth: 20),
|
|
child: trailing ?? const SizedBox(width: 20),
|
|
),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
}
|