Is there a way to apply media query to padding top in flutter? The location of top, left, right, bottom is different for each device, so how do I solve it?
import 'package:flutter/material.dart';
class menuwidget3 extends StatelessWidget {
const menuwidget3({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: const Color(0xfff9f9f9),
body: SafeArea(
child: Stack(
children: [
Padding(
padding: const EdgeInsets.only(top: 20, left: 15),
child: Row(
children: const [
Padding(
padding: EdgeInsets.only(left: 5),
child: Text(
'first',
style: TextStyle(
color: Colors.black,
fontFamily: 'Pretendard',
fontWeight: FontWeight.w600,
fontSize: 20),
),
),
],
),
),
CodePudding user response:
Remove const and you should be good to go.
padding: EdgeInsets.only(top: MediaQuery.of(context).size.width * 0.2, left: MediaQuery.of(context).size.width *0.1),
CodePudding user response:
Remove const and add line like this.
padding: EdgeInsets.only(top: MediaQuery.of(context).size.height* 0.2, left: MediaQuery.of(context).size.width * 0.15)```