8wDlpd.png
8wDFp9.png
8wDEOx.png
8wDMfH.png
8wDKte.png

Flutter 如何在表中添加行和列?

Tran To 1月前

8 0

如何让ProgramDayTable水平显示,ProgramDayTable垂直显示,如下表所示。这个问题我所有方法都试过了,还是没能解决。...

如何让ProgramDayTable水平显示,ProgramDayTable垂直显示,如下表所示。这个问题我所有方法都试过了,还是没能解决。


                             ProgramTable(title)

 ProgramDayTable(months)                |        ProgramDayTable(months)                | ...

    Day          |     Description      |         day        |     Description          | ...

节目日表(daye)|节目日表(des)|节目日表(daye)|节目日表(des) |


import 'package:addbird/models/ornithology/ornithology.dart';
import 'package:addbird/provider/program/program_provider.dart';
import 'package:addbird/widgets/column_widgets.dart';
import 'package:addbird/widgets/date_widgets.dart';
import 'package:flutter/material.dart';
import 'package:hooks_riverpod/hooks_riverpod.dart';

class DetailProgramForm extends HookConsumerWidget {
  const DetailProgramForm({
    required this.program,
    super.key,
  });

  final ProgramTableData program;

  @override
  Widget build(BuildContext context, WidgetRef ref) {
    final theme = Theme.of(context);
    final programAsync = ref.watch(allProgram(program.id));

    return ColumnWidgets(
      children: [
        DateWidgets(icon: Icons.edit_calendar, date: program.updatedat),
        const SizedBox(height: 30),
        Column(
          children: [
            SizedBox(
              width: double.infinity,
              child: Container(
                padding: const EdgeInsets.symmetric(vertical: 10),
                decoration: BoxDecoration(
                  borderRadius: BorderRadius.circular(5),
                  border: Border.all(
                    color: theme.colorScheme.outline.withOpacity(.1),
                  ),
                ),
                child: Center(
                  child: Text(program.title.toUpperCase()),
                ),
              ),
            ),
            programAsync.when(
              data: (data) {
                if (data != null) {
                  return Table(
                    border: TableBorder.all(
                      color: theme.colorScheme.outline.withOpacity(.1),
                    ),
                    children: [

                    ],
                  );
                } else {
                  return const Text('No data available');
                }
              },
              loading: () => const Center(child: CircularProgressIndicator()),
              error: (error, stack) => const Text('Error loading data'),
            ),
          ],
        ),
      ],
    );
  }
}

final allProgram = FutureProvider.family<Program?, int>((ref, id) {
  final notifier = ref.read(programProvider.notifier);
  return notifier.getAll(id);
});

桌子

part of '../ornithology.dart';

@TableIndex(
  name: 'uniq_program',
  columns: {#title},
  unique: true,
)

/// programme de alimentation
class ProgramTable extends Table {
  IntColumn get id => integer().autoIncrement()();
  TextColumn get title => text()();
  TextColumn get updatedat => text()();
}

/// programme de alimentation par mois
class ProgramMonthTable extends Table {
  TextColumn get id => text()();
  IntColumn get program => integer().references(ProgramTable, #id)();
  TextColumn get months => text()();
}

/// programme de alimentation par jour
class ProgramDayTable extends Table {
  TextColumn get id => text()();
  TextColumn get months => text().references(ProgramMonthTable, #id)();
  IntColumn get daye => integer()();
  TextColumn get descriptions => text()();
}

class Program {
  Program({
    required this.id,
    required this.title,
    required this.month,
    required this.day,
    required this.updatedat,
  });

  final int id;
  final String title;
  final DateTime updatedat;
  final List<ProgramMonthTableData> month;
  final Map<String, List<ProgramDayTableData>> day;
}

我尝试了所有方法,但没有得到想要的结果

帖子版权声明 1、本帖标题:Flutter 如何在表中添加行和列?
    本站网址:http://xjnalaquan.com/
2、本网站的资源部分来源于网络,如有侵权,请联系站长进行删除处理。
3、会员发帖仅代表会员个人观点,并不代表本站赞同其观点和对其真实性负责。
4、本站一律禁止以任何方式发布或转载任何违法的相关信息,访客发现请向站长举报
5、站长邮箱:yeweds@126.com 除非注明,本帖由Tran To在本站《dart》版块原创发布, 转载请注明出处!
最新回复 (0)
返回
作者最近主题: