Skip to content

Flutter API

yotsuba_gantt 是原生 Flutter Widget,不使用 WebView。

YotsubaGantt 参数

参数类型默认值说明
tasksList<YgTask>必填有序、不可变任务行
controllerYgGanttController?-命令式控制
rangeStart / rangeEndDateTime?数据前后 7 天任意时间范围
viewModeYgViewModeweek年、季、月、周、日、时
onViewModeChangedValueChanged<YgViewMode>?-维度变化
themeYgGanttThemeData?light()视觉令牌
heightdouble520固定高度,最小 240
sidebarWidthdouble280初始任务表宽度
minSidebarWidth / maxSidebarWidthdouble180 / 480分栏限制
sidebarResizeStepdouble8分栏吸附步长
resizableSidebarbooltrue允许拖动分栏
autoFocusYgAutoFocusdensenonedenseearliesttoday
denseWindowDuration14 天密度桶窗口
showDependencies / showProgressbooltrue依赖线和进度
showOffscreenIndicatorsbooltrue逐行视口外入口
linkGroupYgGanttLinkGroup?-多图联动组
syncModeYgSyncModenonenonescrollviewall
interactivebooltrue允许拖动和缩放
selectedTaskIdString?-宿主选中任务
entryTransitionYgEntryTransitionfadeSlide虚拟行入场
entryDurationDuration180 ms入场时长

Builders

参数类型说明
taskBarBuilderYgTaskBarBuilder任务条内部;获得任务、行号、选中态和几何
rowHeaderBuilderYgRowHeaderBuilder左侧任务行
entryTransitionBuilderYgEntryTransitionBuilder使用提供的 Animation<double> 包装新行
edgeIndicatorBuilderYgEdgeIndicatorBuilder左右边缘入口;调用 details.jump() 定位

回调

参数载荷说明
onTaskTapYgTask单击任务
onTaskDoubleTapYgTask双击任务
onTaskChangedYgTaskChange移动或缩放后的不可变替换值
onVisibleRangeChangedYgVisibleRange当前日期与行窗口;每帧最多一次

YgTaskChange.previous 是交互前对象,task 是建议替换值,kindmoveresizeStartresizeEnd

YgTask

字段类型说明
id / titleString稳定 ID 与标题
start / endDateTime起止时间
progressdouble0...1
kindYgTaskKindtaskprojectmilestone
barStyleYgBarStylesolidoutlinesoftprogress
colorColor?任务颜色
parentId / ownerString?层级与负责人
dependenciesList<String>前置任务 ID
metadataMap<String, Object?>宿主业务字段

任务不可变;使用 copyWith() 创建替换对象。

YgGanttController

dart
controller.isAttached
await controller.scrollToDate(date, duration: duration)
await controller.scrollTaskIntoView(taskId, duration: duration)
await controller.scrollToRow(rowIndex, duration: duration)
controller.setView(YgViewMode.month)
await controller.fitToTasks()

YgGanttThemeData

主题开放背景、任务表、表头、网格、主色、今天线、主/次文字、依赖线颜色,任务与表头文字样式,以及 rowHeighttaskHeighttaskRadius。可从 YgGanttThemeData.light(seed:) 开始并用 copyWith() 修改。

以 MIT License 开源