Flutter MediaQuery简单使用

1.通过MediaQuery.removePadding可以移除元素的pandding,需要注意要指定移除哪个方向的padding,例如移除上面的padding

1MediaQuery.removePadding( 2 removeTop: true, 3 context: context, 4 child: , 5)

2.获取状态栏高度

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

同时我们也可以在flutter/src/material/constants.dart中查看flutter自带的AppBar的默认参数

1/// The height of the toolbar component of the [AppBar]. 2const double kToolbarHeight = 56.0; 3 4/// The height of the bottom navigation bar. 5const double kBottomNavigationBarHeight = 56.0;

3.引入官方webview_flutter: ^0.3.7+1 ,提示错误需要使用AndroidX

1' *********************************************************' 2' WARNING: This version of ' + PLUGIN + ' will break your Android build if it or its dependencies aren\'t compatible with AndroidX.' 3' See https://goo.gl/CP92wY for more information on the problem and how to fix it.' 4' This warning prints for all Android build failures. The real root cause of the error may be unrelated.' 5' *********************************************************'

解决方法:
打开flutter的android宿主项目点击Refactor-Migrate to AndroidX

image.png

接下来再弹出的窗口点击Do Refactor 让Android Studio自动将项目转化为AndroidX依赖

转化完毕后可以clean Project看看还有其他错误没,没有错误后回到Flutter项目运行即可

点赞
收藏

评论区

加载中...

相关推荐

手写Java HashMap源码

HashMap的使用教程HashMap的使用教程HashMap的使用教程HashMap的使用教程HashMap的使用教程22

tidb损坏tikv节点怎么恢复集群

tikv节点宕机(机器再起不来),或者数据节点被rmrf 掉了怎么办正常情况下tikv节点down掉了。此时不要去执行store delete store\_id。数据一般可以正常访问,但是如果永久损坏的tikv节点。我们总想要把它移除。如何移除呢? (移除kv节点过程中,如果kv节点健康在线,可以实现动态移除。如果kv节点不可用,可能导致访

JavaScript用html5新方法操作元素类名

现在网页中类属性使用越来越多,经常会通过增加类、移除类给指定的元素修改样式效果。早先JavaScript处理起来特别不方便,需要先取到class属性,然后对字符串进行处理。现在html5给所有元素增加了classList属性来操作类属性,非常方便。classList先看如下代码:html栏目1栏目2栏目3//获取到当前的li元素letacti

springboot项目打成war包

在某种情况下,比如。。。。。。。。。。之下,我们不得不,将springboot打成war包1、在pom.xml文件中修改<packagingwar</packaging2、移除springboot自带的tomcat<!移除自带的tomcat<dependency<groupIdorg.spri

前端性能优化 - 雅虎军规

无论是在工作中,还是在面试中,web前端性能的优化都是很重要的,那么我们进行优化需要从哪些方面入手呢?可以遵循雅虎的前端优化35条军规,这样对于优化有一个比较清晰的方向.35条军规1.尽量减少HTTP请求个数——须权衡2.使用CDN(内容分发网络)3.为文件头指定Expires或CacheControl,使内容具有缓存性。4.避免空的

PHP 利用confirm删除指定数据库的数据

完整的效果图方法一a标签href中的是你要删除记录html<ahref"PHPtest.php?name1"onclick"returnconfirm('是否要移除该小说?')"方法二下面这个方法是js代码,点击获取id,弹出提示框,确定是否删除,confirm好像可以返回true或者falsejavascriptfunctiond