Error: A value of type 'AppStateNotifier' can't be assigned to a variable of type 'Widget

Error: A value of type 'AppStateNotifier' can't be assigned to a variable of type 'Widget

学习本教程。 https://itnext.io/app-theming-in-flutter-dark-mode-light-mode-27d9adf3cee

void main() {
  WidgetsFlutterBinding.ensureInitialized();
  SystemChrome.setPreferredOrientations([
    DeviceOrientation.portraitUp,
    DeviceOrientation.portraitDown,
  ]);
  runApp(
    ChangeNotifierProvider<AppStateNotifier>(
      builder: (context) => AppStateNotifier(), //<--COMPILER ERROR, details below.
      child: MyApp(),
    ),
  );
}

class MyApp extends StatelessWidget {
  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return Consumer<AppStateNotifier>(
      builder: (context, appState, child) {
        return MaterialApp(
          title: 'Lockify',
          debugShowCheckedModeBanner: false,
          theme: AppTheme.lightTheme, 
          darkTheme:
              AppTheme.darkTheme, 
          home: MyHomePage(),
          themeMode: appState.isDarkModeOn ? ThemeMode.dark : ThemeMode.light,
        );
      },
    );
  }
}

错误: 编译器消息: lib/main.dart:16:29: 错误:'AppStateNotifier' 类型的值无法分配给 'Widget'.

类型的变量

lib/main.dart:16:16: 错误:参数类型 'Widget Function(BuildContext)' 无法分配给参数类型 'Widget Function(BuildContext, Widget)'.

尝试在 ChangeNotifierProvider 小部件上将 builder 更改为 create