Reputation: 1161
I wrap the app in a scrollconfiguration to remove the scrollglow. This always worked but it has been quite a time since i used flutter so i created a new project but it gives this error.
ProviderScope(
child: MaterialApp(
title: 'testing',
themeMode: ThemeMode.light,
darkTheme: darkTheme(),
theme: lightTheme(),
onGenerateRoute: RouteGenerator.generateRoute,
initialRoute: '/',
builder: (context, child) {
return ScrollConfiguration(
behavior: RemoveScrollGlow(),
child: child,
);
},
)
)
The probleme is child: child. I have no idea how to fix this.
class RemoveScrollGlow extends ScrollBehavior {
@override
Widget buildOverscrollIndicator(
BuildContext context, Widget child, ScrollableDetails details) {
return child;
}
}
Upvotes: 16
Views: 38949
Reputation: 5190
If you are sure the value will never be null, you can cast it to the non-nullable type, ie. Widget
explicitly. Or simply add an !
suffix, like this: child!
.
Upvotes: 19
Reputation: 134
You would have updated the dart SDK version and hence null safety is included in your project.
It's pretty simple to solve just go to your pubspec.yaml file and under environment variable, you will find the dart SDK range which should be something like this sdk: ">=2.12.0 <3.0.0".
Now you just have to change it from 2.12.0 to 2.7.0 which will enable your project to run without null safety and will make your project error-free. So the updated sdk version should look like sdk: ">=2.7.0 <3.0.0".
Hope it will help you.
Upvotes: 5
Reputation: 1710
You have enabled the null-safety in your project. and your child
have the type of Widget?
where as child of ScrollConfiguration
requires the type Widget
.
What is the difference between Widget
and Widget?
?
Widget?
indicates that it can have null value whereas the type of Widget
is non-null.
Read more at https://dart.dev/null-safety
Upvotes: 0