如何让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;
}
我尝试了所有方法,但没有得到想要的结果