Complete the code to get the current theme using BuildContext.
ThemeData theme = Theme.of([1]);widget or state instead of context.this which is not a BuildContext.The BuildContext is used to access inherited widgets like Theme. Here, context is the correct argument.
Complete the code to navigate to a new screen using BuildContext.
Navigator.of([1]).push(MaterialPageRoute(builder: (context) => NewScreen()));widget or state instead of context.this which is not a BuildContext.Navigation requires the BuildContext to find the Navigator in the widget tree. context is the correct argument.
Fix the error in accessing the ScaffoldMessenger using BuildContext.
ScaffoldMessenger.of([1]).showSnackBar(SnackBar(content: Text('Hello')));
widget or state instead of context.this which is not a BuildContext.The BuildContext is needed to find the ScaffoldMessenger. Use context here.
Fill both blanks to create a widget tree with a Builder to get a new BuildContext.
return Scaffold( body: Builder( builder: ([1]) { return Text('Context is [2]'); }, ), );
widget or state as the builder parameter.The builder function provides a new BuildContext named context. Use context for both blanks.
Fill all three blanks to access MediaQuery data inside a widget build method.
Widget build(BuildContext [1]) { final size = MediaQuery.of([2]).size; return Container( width: size.[3], height: size.height, ); }
context for the BuildContext parameter.size.height instead of size.width for width.The build method receives a BuildContext named context. Use it to get MediaQuery data. Then access the width property of the size.