Home > OS >  All final variables must be initialized, but '' isn't. Try adding an initializer for
All final variables must be initialized, but '' isn't. Try adding an initializer for

Time:09-23

I just need to pass an attribute to a constructor AppTheme, but i received an error:

All final variables must be initialized, but '' isn't. Try adding an initializer for the field.dartfinal_not_initialized_constructor

the code is:

class AppTheme extends StatelessWidget {
  const AppTheme({required this.navigator}); // => Cursor error 
  final  Widget navigator,
  @override
  Widget build(BuildContext context) {
    throw UnimplementedError();
  }}

CodePudding user response:

class AppTheme extends StatelessWidget {
  const AppTheme({required this.navigator}); 
  final  Widget navigator; // from , to ;
  @override
  Widget build(BuildContext context) {
    throw UnimplementedError();
  }}
  • Related