listHeaderView static method

Widget listHeaderView({
  1. required String title,
  2. VoidCallback? onMorePressed,
  3. String moreText = "查看更多",
  4. bool showMore = true,
})

通用的列表区块标题组件

Implementation

static Widget listHeaderView({
  required String title,
  VoidCallback? onMorePressed,
  String moreText = "查看更多",
  bool showMore = true,
}) {
  return Container(
    padding: EdgeInsets.only(left: 16, right: 2),
    // 比 red 更通用,适配更多页面风格
    child: Row(
      mainAxisAlignment: MainAxisAlignment.spaceBetween,
      children: [
        Text(
          title,
          style: TextStyle(
            fontSize: 18,
            fontWeight: FontWeight.bold,
            color: const Color.fromRGBO(0, 0, 0, 0.87),
          ),
        ),
        if (showMore)
          TextButton(
            onPressed: onMorePressed,
            style: TextButton.styleFrom(
              padding: EdgeInsets.zero,
              minimumSize: Size(40, 30),
              tapTargetSize: MaterialTapTargetSize.shrinkWrap,
            ),
            child: Container(
              padding: EdgeInsets.symmetric(horizontal: 8),
              child: Row(
                mainAxisSize: MainAxisSize.min,
                children: [
                  Text(
                    moreText,
                    style: TextStyle(
                      fontSize: 14,
                      fontWeight: FontWeight.bold,
                      color: AppColors.primaryColor,
                    ),
                  ),
                  const SizedBox(width: 4),
                  Icon(
                    Icons.arrow_forward_ios,
                    size: 14,
                    color: AppColors.primaryColor,
                  ),
                ],
              ),
            ),
          ),
      ],
    ),
  );
}