1. 获取状态栏高度

import 'dart:ui';
MediaQueryData.fromWindow(window).padding.top

2. 设置AppBar的高度

Scaffold(
appBar: PreferredSize(
child: AppBar(
),
preferredSize: Size.fromHeight(screenSize.height * 0.07))
);

3. 系统默认的AppBar、TabBar高度

Dart Packages/flutter/src/material/constans.dart

/// The height of the toolbar component of the [AppBar].
const double kToolbarHeight = 56.0; /// The height of the bottom navigation bar.
const double kBottomNavigationBarHeight = 56.0; /// The height of a tab bar containing text.
const double kTextTabBarHeight = 48.0; /// The amount of time theme change animations should last.
const Duration kThemeChangeDuration = Duration(milliseconds: ); /// The radius of a circular material ink response in logical pixels.
const double kRadialReactionRadius = 20.0; /// The amount of time a circular material ink response should take to expand to its full size.
const Duration kRadialReactionDuration = Duration(milliseconds: ); /// The value of the alpha channel to use when drawing a circular material ink response.
const int kRadialReactionAlpha = 0x1F; /// The duration of the horizontal scroll animation that occurs when a tab is tapped.
const Duration kTabScrollDuration = Duration(milliseconds: ); /// The horizontal padding included by [Tab]s.
const EdgeInsets kTabLabelPadding = EdgeInsets.symmetric(horizontal: 16.0); /// The padding added around material list items.
const EdgeInsets kMaterialListPadding = EdgeInsets.symmetric(vertical: 8.0);

4. 获取当前时间戳

var now = new DateTime.now();
print(now.millisecondsSinceEpoch); //单位毫秒,13位时间戳 /** 或者 */
/** 返回当前时间戳 */
static int currentTimeMillis() {
return new DateTime.now().millisecondsSinceEpoch;
}

5.时间戳转化成日期

var now = new DateTime.now();
var a=now.millisecondsSinceEpoch; //时间戳
print(DateTime.fromMillisecondsSinceEpoch(a));

6. 获取控件大小和相对屏幕位置

.首先先需要对控件进行渲染
初始化GlobalKey :GlobalKey anchorKey = GlobalKey(); .在需要测量的控件的下面添加key:
child: Text("点击弹出悬浮窗",
style: TextStyle(fontSize: ),
key: anchorKey
), .获取控件的坐标:
RenderBox renderBox = anchorKey.currentContext.findRenderObject();
var offset = renderBox.localToGlobal(Offset.zero); 控件的横坐标:offset.dx
控件的纵坐标:offset.dy 如果想获得控件正下方的坐标:
RenderBox renderBox = anchorKey.currentContext.findRenderObject();
var offset = renderBox.localToGlobal(Offset(0.0, renderBox.size.height)); 控件下方的横坐标:offset.dx
控件下方的纵坐标:offset.dy .获取控件的大小:
RenderBox renderBox = anchorKey.currentContext.findRenderObject();
final size = renderBox.size;

7.有网络请求的地方基本上就有md5

dart有内置的md5加密包,先引入头文件:

import 'dart:convert';
import 'package:convert/convert.dart';
import 'package:crypto/crypto.dart';

md5加密方法:

// md5 加密
String generateMd5(String data) {
var content = new Utf8Encoder().convert(data);
var digest = md5.convert(content);
// 这里其实就是 digest.toString()
return hex.encode(digest.bytes);
}

8. flutter 引入图片资源

可以单个图片引入,也可以整个文件夹引入

最新文章

  1. 第二天-uboot学习
  2. C# 超时工具类 第二版
  3. ThinkPHP开启事物
  4. dsaf
  5. Flash动画
  6. 剑指Offer 旋转数组的最小数字
  7. Sqlserver创建连接MySql的链接服务器
  8. 学习练习 java 线程
  9. bzoj2749
  10. 自定义复选框 checkbox 样式
  11. js的for循环闭包问题
  12. 解决执行sql脚本报错:没有足够的内存继续执行程序。
  13. USB设备驱动概述
  14. FragmentTabHostUnderLineDemo【FragmentTabHost带下划线】
  15. mysql 语法积累
  16. 认识RabbitMQ交换机模型
  17. html css 其他常用 onclick跳转
  18. 【转】MySQL索引原理及慢查询优化
  19. React封装RadioGroup
  20. 浅谈Android选项卡(四)

热门文章

  1. C#readonly和const对比
  2. 原生JS发送Ajax请求、JSONP
  3. vulkan的subpass
  4. 为什么size_t重要?(Why size_t matters)
  5. ACM-ICPC 2018 南京赛区现场赛 E. Eva and Euro coins (思维)
  6. BZOJ 1458 / Luogu P4311 士兵占领 (上下界最小流 / 直接最大流)
  7. 5、Spring Boot 2.x 启动原理解析
  8. 【算法进阶-康托展开】-C++
  9. 快速了解AMD、CMD、CommonJS、ESM
  10. MySQL percona-toolkit工具详解