• flutter_screenutil


    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( 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(
             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),),
            ),
          ),
        );
      }
    }
    

      

  • 相关阅读:
    Windows下MarialDB使用
    线程同步synchronized和ReentrantLock
    4种事务特性,5种隔离级别,7种传播行为
    Spring bean的作用域
    java经典30笔试题
    finally中的return
    springboot中Controller没有被扫描
    面试如何回答优化数据库
    Windows定时任务没有执行
    .Net应用程序打包部署总结
  • 原文地址:https://www.cnblogs.com/pythonClub/p/10953487.html
Copyright © 2020-2023  润新知