参数类型 'Widget' 无法分配给参数类型 'PreferredSizeWidget?'

Argument type 'Widget' can't be assigned to the parameter type 'PreferredSizeWidget?'

我尝试将 appBar 添加到 Feed 页面后出现错误。

import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:wecare_u/constants/Constantcolors.dart';

class FeedHelpers with ChangeNotifier {
ConstantColors constantColors = ConstantColors();
Widget appBar(BuildContext context) {
return AppBar(
  backgroundColor: constantColors.darkColor,
  centerTitle: true,
  actions: [
    IconButton(
        icon: Icon(Icons.camera_enhance_rounded,
            color: constantColors.greenColor),
        onPressed: () {})
  ],
  title: RichText(
    text: TextSpan(
        text: 'Social ',
        style: TextStyle(
          color: constantColors.whiteColor,
          fontWeight: FontWeight.bold,
          fontSize: 20.0,
        ),
        children: <TextSpan>[
          TextSpan(
              text: 'Feed',
              style: TextStyle(
                color: constantColors.blueColor,
                fontWeight: FontWeight.bold,
                fontSize: 20.0,
              ))
        ]),
  ),
  );
  }
  }

以上是我的 Feed_helpers.dart 文件,其中包含页面代码。

import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
import 'package:wecare_u/Designs/Feed_helpers.dart';

class Feed extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
  appBar: Provider.of<FeedHelpers>(context, listen: false).appBar(context),
  );}}

这是我的 feed.dart 文件,当我尝试在此页面中添加 appBar 时出现错误 '无法将参数类型 'Widget' 分配给参数类型 'PreferredSizeWidget?'。'

尝试用 PreferredSize 小部件包装 AppBar 小部件。

PreferredSize(
  preferredSize: Size.fromHeight(20.0), // height of appbar
  child:  AppBar(
             ..........
          ),
  ),