首页 > 其他 > 详细

flutter_screenutil

时间:2019-05-31 10:23:14      阅读:401      评论:0      收藏:0      [点我收藏+]

 

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

  

flutter_screenutil

原文:https://www.cnblogs.com/pythonClub/p/10953487.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!