pile_nav_new/lib/service/pile/public_widget.dart

76 lines
1.6 KiB
Dart
Raw Permalink Normal View History

2024-08-23 17:54:57 +08:00
import 'package:flutter/material.dart';
import 'device_type.dart';
class InlineRowWidget extends StatelessWidget {
final List<Widget> children;
const InlineRowWidget({super.key, required this.children});
@override
Widget build(BuildContext context) {
return IntrinsicWidth(
child: Row(
children: children,
),
);
}
}
class AlignWrapWidget extends StatelessWidget {
final List<Widget> children;
const AlignWrapWidget({super.key, required this.children});
@override
Widget build(BuildContext context) {
return Container(
padding: const EdgeInsets.symmetric(vertical: 10),
child: Align(
alignment: Alignment.centerLeft,
child: Wrap(
children: children,
),
),
);
}
}
// ignore: must_be_immutable
class FixedWidthTextWidget extends StatelessWidget {
final String text;
final double width;
final TextStyle? style;
FixedWidthTextWidget({
super.key,
required this.text,
this.width = 80,
this.style,
});
TextStyle? textStyle;
@override
Widget build(BuildContext context) {
final deviceType = getDeviceType(context);
double dynamicWidth = deviceType == DeviceType.mobile ? 0 : 50;
if (style != null) {
textStyle =
style!.copyWith(fontSize: deviceType == DeviceType.mobile ? 16 : 20);
} else {
textStyle =
TextStyle(fontSize: deviceType == DeviceType.mobile ? 16 : 20);
}
return Container(
margin: const EdgeInsets.symmetric(horizontal: 3),
width: width + dynamicWidth,
child: Text(
text,
style: textStyle,
),
);
}
}