The problem is when I used mediaquery.of(context).size the error appears only in this specific external method.
I used the mediaquery in another class and it work successful and i tried to add context parameter in method but the error is not gone.
Error found:
I/flutter (24468): ══╡ EXCEPTION CAUGHT BY WIDGETS LIBRARY ╞═══════════════════════════════════════════════════════════ I/flutter (24468): The following assertion was thrown building Home(dirty, dependencies: [MediaQuery], state:
I/flutter (24468): HomeState#c4bef):
I/flutter (24468): 'package:flutter/src/widgets/media_query.dart': Failed assertion: line 715 pos 12: 'context !=
I/flutter (24468): null': is not true.
I/flutter (24468): I/flutter (24468): Either the assertion indicates an error in the framework itself, or we should provide substantially
I/flutter (24468): more information in this error message to help you determine and fix the underlying cause.
I/flutter (24468): In either case, please report this assertion by filing a bug on GitHub:
I/flutter (24468):
https://github.com/flutter/flutter/issues/new?template=BUG.mdI/flutter (24468):
I/flutter (24468): User-created ancestor of the error-causing widget was:
I/flutter (24468): Container
the code:
Widget slide() {
return Container(
height: MediaQuery.of(context).size.width / 4,
width: MediaQuery.of(context).size.width *1,
child: Carousel(
dotSize: 5,
showIndicator: false,
autoplay: true,
images: [
ExactAssetImage("images/01.jpg"),
ExactAssetImage("images/02.jpg"),
ExactAssetImage('images/03.jpg'),
ExactAssetImage("images/04.jpg"),
ExactAssetImage("images/05.jpg"),
ExactAssetImage('images/06.jpg')
],
));
}
ContexttoMediaQuery.of(context)- pskink