Skip to content

Instantly share code, notes, and snippets.

@rei-codes
Last active June 1, 2023 07:57
Show Gist options
  • Save rei-codes/230a4b68ad6f6590796bdde4f277ac82 to your computer and use it in GitHub Desktop.
Save rei-codes/230a4b68ad6f6590796bdde4f277ac82 to your computer and use it in GitHub Desktop.
MediaQuery as an InheritedModel
class HomePage extends StatelessWidget {
const HomePage({super.key});
@override
Widget build(BuildContext context) {
log('HomePage');
return Scaffold(
appBar: AppBar(),
body: Center(
child: Text(
MediaQuery.of(context).platformBrightness.name,
),
),
floatingActionButton: FloatingActionButton(
onPressed: () {
Navigator.of(context).push(
MaterialPageRoute(builder: (_) => const DetailsPage()),
);
},
),
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment