72 lines
1.9 KiB
Dart
72 lines
1.9 KiB
Dart
import 'package:flutter/material.dart';
|
|
|
|
|
|
class DetailRow extends StatelessWidget {
|
|
final String label;
|
|
final String value;
|
|
final bool multiline;
|
|
final bool monospaced;
|
|
|
|
const DetailRow({
|
|
super.key,
|
|
required this.label,
|
|
required this.value,
|
|
this.multiline = false,
|
|
this.monospaced = false,
|
|
});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
final theme = Theme.of(context);
|
|
final valueStyle = monospaced
|
|
? theme.textTheme.bodyMedium?.copyWith(fontFamily: 'monospace')
|
|
: theme.textTheme.bodyMedium;
|
|
|
|
return Padding(
|
|
padding: const EdgeInsets.symmetric(vertical: 2),
|
|
child: LayoutBuilder(
|
|
builder: (context, constraints) {
|
|
final isNarrow = constraints.maxWidth < 250;
|
|
if (isNarrow) {
|
|
return Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
Text(
|
|
label,
|
|
style: theme.textTheme.bodySmall?.copyWith(
|
|
color: theme.colorScheme.onSurfaceVariant,
|
|
),
|
|
),
|
|
const SizedBox(height: 2),
|
|
SelectableText(value, style: valueStyle),
|
|
],
|
|
);
|
|
}
|
|
|
|
return Row(
|
|
crossAxisAlignment: multiline
|
|
? CrossAxisAlignment.start
|
|
: CrossAxisAlignment.center,
|
|
children: [
|
|
Expanded(
|
|
flex: 2,
|
|
child: Text(
|
|
label,
|
|
style: theme.textTheme.bodySmall?.copyWith(
|
|
color: theme.colorScheme.onSurfaceVariant,
|
|
),
|
|
),
|
|
),
|
|
const SizedBox(width: 8),
|
|
Expanded(
|
|
flex: 3,
|
|
child: SelectableText(value, style: valueStyle),
|
|
),
|
|
],
|
|
);
|
|
},
|
|
),
|
|
);
|
|
}
|
|
}
|