123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132 |
- import 'package:flutter/material.dart';
- class VListFormCellGroup extends StatelessWidget {
- final List<Widget> children;
- const VListFormCellGroup({
- Key? key,
- required this.children,
- }) : super(key: key);
- @override
- Widget build(BuildContext context) {
- final divider = Divider(thickness: 1, color: Colors.grey.shade400);
- final kids = <Widget>[];
- for (var i = 0; i < children.length; i++) {
- if (i > 0) {
- kids.add(divider);
- }
- kids.add(children[i]);
- }
- return Container(
- alignment: Alignment.center,
- padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 20),
- decoration: BoxDecoration(
- color: Colors.white,
- borderRadius: BorderRadius.circular(16),
- ),
- child: Column(
- mainAxisSize: MainAxisSize.min,
- mainAxisAlignment: MainAxisAlignment.start,
- children: kids,
- ),
- );
- }
- }
- class VListFormCell extends StatelessWidget {
- final String? label;
- final Widget? labelWidget;
- final String? content;
- final Widget? contentWidget;
- final VoidCallback? onTap;
- final double? height;
- const VListFormCell({
- super.key,
- this.label,
- this.labelWidget,
- this.content,
- this.contentWidget,
- this.onTap,
- this.height,
- }) : assert(label != null || labelWidget != null);
- @override
- Widget build(BuildContext context) {
- final children = <Widget>[];
- children.add(_buildLabel());
- children.add(SizedBox(width: 500, child: _buildRightPart()));
- return SizedBox(
- height: height ?? 40,
- child: InkWell(
- onTap: onTap,
- child: Row(
- mainAxisAlignment: MainAxisAlignment.spaceBetween,
- children: children,
- ),
- ),
- );
- }
- Widget _buildRightPart() {
- final children = <Widget>[];
- final contentChild = _buildContent();
- if (contentChild != null) {
- children.add(contentChild);
- }
- if (onTap != null) {
- children.add(
- SizedBox(
- height: height ?? 40,
- child: _buildAction(),
- ),
- );
- } else {
- children.add(const SizedBox(width: 12));
- }
- return Row(
- mainAxisAlignment: MainAxisAlignment.end,
- mainAxisSize: MainAxisSize.max,
- children: children,
- );
- }
- Widget _buildLabel() {
- Widget widget;
- if (labelWidget != null) {
- widget = labelWidget!;
- } else {
- widget = Text(
- label!,
- style: const TextStyle(color: Colors.black, fontSize: 20),
- );
- }
- return SizedBox(width: 200, child: widget);
- }
- Widget? _buildContent() {
- if (contentWidget != null) {
- return contentWidget!;
- }
- if (content != null && content!.isNotEmpty) {
- return Text(
- content!,
- style: TextStyle(color: Colors.grey.shade700, fontSize: 20),
- );
- }
- return null;
- }
- Widget _buildAction() {
- return Icon(
- Icons.keyboard_arrow_right,
- size: 32,
- color: Colors.grey.shade400,
- );
- }
- }
|