Flutter 时间轴代码精简优化:更简洁的代码结构
dailycourse = [ _buildTimeContainer('上午'), _buildCourseTile('1,2节 8;00 - 9:35', false, true), _buildCourseTile('', true, false), _buildCourseTile('3,4节 9:55 -11:30', true, false), _buildTimeContainer('下午'), _buildCourseTile('5,6节 13;30 - 15:05', false, true), _buildCourseTile('', true, false), _buildCourseTile('7,8节 15:25 - 17:00', true, false), _buildTimeContainer('晚课'), _buildCourseTile('9,10节 18:00 - 19:35', false, true), _buildCourseTile('', true, false), _buildCourseTile('11,12节 19:55 - 21:30', true, false), ];
Widget _buildTimeContainer(String time) { return Container( padding: EdgeInsets.only(left: 60, top: 30), child: Row( children: [ Text( time, style: TextStyle( fontSize: 30, fontWeight: FontWeight.bold, color: Global.home_currentcolor), ), ], ), ); }
Widget _buildCourseTile(String time, bool hasStartConnector, bool hasEndConnector) { return Container( child: TimelineTile( oppositeContents: Padding( padding: const EdgeInsets.all(8.0), child: Card( child: Container( width: widthx, padding: EdgeInsets.all(8.0), child: Text( time, style: TextStyle( color: Colors.black, fontWeight: FontWeight.bold), ), ), ), ), contents: Card( //透明 color: Colors.transparent, shadowColor: Colors.transparent, child: Container( width: widthx, padding: EdgeInsets.all(8.0), child: Text( ', style: TextStyle(color: Colors.white), ), ), ), node: TimelineNode( indicator: DotIndicator( color: Global.home_currentcolor, ), startConnector: hasStartConnector ? SolidLineConnector( color: Global.home_currentcolor, ) : null, endConnector: hasEndConnector ? SolidLineConnector( color: Global.home_currentcolor, ) : null, ), ), ); }
原文地址: http://www.cveoy.top/t/topic/ojGa 著作权归作者所有。请勿转载和采集!