Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR DART

Determine the Screen size using the MediaQuery class Flutter

class Home extends StatefulWidget 
  const Home({Key? key}) : super(key: key);
  @override
  _HomeState createState() => _HomeState();
}
class _HomeState extends State {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text("Media Query"),
      ),
      body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: [
            Container(
              height: (MediaQuery.of(context).size.height / 2),
              width: (MediaQuery.of(context).size.width / 2),
              color: Colors.green,
              child: const Center(child: Text("Media Query Container")),
            )
          ],
        ),
      ),
    );
  }
}{
Source by www.linkedin.com #
 
PREVIOUS NEXT
Tagged: #Determine #Screen #size #MediaQuery #class #Flutter
ADD COMMENT
Topic
Name
3+2 =