Malisha De Silva
Malisha De Silva

Reputation: 441

Flutter nullable error when creating class parameterized constructor

I updated flutter stable version 2.2.1 (Nullable feature enabled). When I write constructor of the class as following code, I got error as following image shows. Please help me to resolve this. enter image description here

class FlavorBanner extends StatelessWidget {
  final Widget child ;
  late BannerConfig bannerConfig;
  FlavorBanner({@required this.child});

}

Upvotes: 1

Views: 63

Answers (1)

quoci
quoci

Reputation: 3557

Use the new keyword required instead of @required, which says the property is mandatory.

class FlavorBanner extends StatelessWidget {
  final Widget child;
  late BannerConfig bannerConfig;
  FlavorBanner({
    required this.child,
  });
}

Upvotes: 1

Related Questions