Skip to content

Instantly share code, notes, and snippets.

@dayerdl
Last active June 27, 2023 01:43
Show Gist options
  • Save dayerdl/7b7e989ae8b1a795258e878f05a7043e to your computer and use it in GitHub Desktop.
Save dayerdl/7b7e989ae8b1a795258e878f05a7043e to your computer and use it in GitHub Desktop.
Using the Scaffold scope
import 'package:flutter/material.dart';
class ScreenSizeScreen extends StatelessWidget {
@override
Widget build(BuildContext context) {
print("ZAXA >>>>> build on the ScreenSizeScreen trigggered");
return Scaffold(
appBar: AppBar(
title: Text('Screen Size'),
),
body: LayoutBuilder(
builder: (BuildContext context, BoxConstraints constraints) {
final screenHeight = MediaQuery.of(context).size.height;
return Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text(
'Screen Height: $screenHeight',
style: TextStyle(fontSize: 18.0),
),
SizedBox(height: 16.0),
ElevatedButton(
onPressed: () {
Navigator.push(
context,
MaterialPageRoute(builder: (context) => SecondScreen()),
);
},
child: Text('Open Second Screen'),
),
],
),
);
},
),
);
}
}
class SecondScreen extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('Second Screen'),
),
body: Center(
child: TextField(
style: TextStyle(fontSize: 18.0),
),
),
);
}
}
void main() {
runApp(MaterialApp(
home: ScreenSizeScreen(),
));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment