import 'package:Flutter/material.dart'; import 'package:Flutter_screenutil/Flutter_screenutil.dart'; import 'dart:ui'; main()=>runApp(MaterialApp( home: MyApp(), )); class MyApp extends StatefulWidget{ @override State<StatefulWidget> createState() { return MyAppState(); } } class MyAppState extends State<MyApp> { c(DragDownDetails x){ var a = 750 * x.globalPosition.dx/350.0; var b = 1334 * x.globalPosition.dy/672; print('a:$a, b:$b'); } @override Widget build(BuildContext context) { print(MediaQuery.of(context).size); ScreenUtil.instance = ScreenUtil(width: 750, height: 1334, allowFontScaling: true)..init(context); var t = MediaQuery.of(context).padding.top; print('t: $t'); var s = ScreenUtil.statusBarHeight; print('s: $s'); var wx = window.physicalSize; print('wx: $wx'); var wp = window.padding; print('wp: $wp'); var ss = window.devicePixelRatio; print('ss: $ss'); var su = ScreenUtil.pixelRatio; print('su: $su'); return Scaffold( // appBar: AppBar(title: Text('abc'),), body: Container( width: ScreenUtil().setWidth(750.0), height: ScreenUtil().setHeight(1334), color: Colors.red, child: GestureDetector( onPanDown: (v){ c(v); }, child: Text('HELLO', style: TextStyle(color: Colors.white),), ), ), ); } }
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。