scaffold

Flutter 上的一个 Bug 带你了解键盘与路由的另类知识点

蹲街弑〆低调 提交于 2020-07-29 03:50:39
事情是这样的,由于近期 Flutter 发布了 1.17 的稳定版,按照“惯例”开始着手把生产项目升级到 1.12.13+hotfix.9 版本,在升级适配完成之后,一个突如其来的 Bug 让我陷入了沉思。 如上图所示,可以看到在键盘 B 页面打开后,退回上一个页面 A 时键盘已经收起,但是原先键盘所在的区域在 A 页面变成了空白,而 A 页面内容也被 resize 成了键盘弹出后的大小。 1、Scaffold 针对这个问题,首先想到的 Scaffold 的 resizeToAvoidBottomInset 属性。 在 Flutter 中 Scaffold 默认情况下 resizeToAvoidBottomInset 为 true ,当 resizeToAvoidBottomInset 为 true 时, Scaffold 内部会将 mediaQuery.viewInsets.bottom 参与到 BoxConstraints 的大小计算,也就是 键盘弹起时调整了内部的 bottom 位置来迎合键盘。 但是问题发送在 A 界面,这时候键盘已经收起, mediaQuery.viewInsets.bottom 应该更新为 0 ,那为何界面没有产生应有的更新呢? 2、MediaQuery 那么猜测问题可能出现在 MediaQuery 上。 从源码我们得知 MediaQuery 是一个

Flutter设置statusBar为白色

£可爱£侵袭症+ 提交于 2020-07-29 02:55:53
import 'dart:io'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; void main() { runApp(MyApp()); //主要代码 if (Platform.isAndroid) { SystemUiOverlayStyle systemUiOverlayStyle = SystemUiOverlayStyle( statusBarColor: Colors.transparent, ); SystemChrome.setSystemUIOverlayStyle(systemUiOverlayStyle); print("systemUiOverlayStyle"); } } class MyApp extends StatelessWidget { @override Widget build(BuildContext context) { return MaterialApp( title: 'Flutter Demo', theme: ThemeData(primarySwatch: Colors.red, primaryColor: Colors.white), //设置App主题 home: MyHomePage(title:

Why does passing BuildContext say there is no Scaffold in that Context?

两盒软妹~` 提交于 2020-07-09 07:10:14
问题 import 'package:flutter/material.dart'; main() { runApp(MaterialApp( home: HomeScreen(), )); } class HomeScreen extends StatelessWidget { @override Widget build(BuildContext context) { return new Scaffold( appBar: new AppBar( title: new Text('Rite.ly'), ), body: new Container( decoration: new BoxDecoration( image: new DecorationImage( image: new AssetImage('assets/login_background.png'), fit: BoxFit.fill, )), child: new ListView( children: [ new Padding( padding: const EdgeInsets.only(top: 16

How to hide drawer in flutter after changing Scaffold.body value

家住魔仙堡 提交于 2020-05-25 23:51:03
问题 I am using the method in this question to change the body of a Scaffold in flutter: Flutter Drawer Widget - change Scaffold.body content The method described works perfectly. Now I would like just the drawer to automatically close after the users taps on one of the items. I tried using the Navigator.pop() method, but it pops the entire screen, not just the drawer. It leaves me with a totally black screen. Any suggestions? 回答1: Are you using exactly Navigator.of(context).pop() ? I cannot

How to hide drawer in flutter after changing Scaffold.body value

删除回忆录丶 提交于 2020-05-25 23:49:20
问题 I am using the method in this question to change the body of a Scaffold in flutter: Flutter Drawer Widget - change Scaffold.body content The method described works perfectly. Now I would like just the drawer to automatically close after the users taps on one of the items. I tried using the Navigator.pop() method, but it pops the entire screen, not just the drawer. It leaves me with a totally black screen. Any suggestions? 回答1: Are you using exactly Navigator.of(context).pop() ? I cannot

How to hide drawer in flutter after changing Scaffold.body value

帅比萌擦擦* 提交于 2020-05-25 23:47:41
问题 I am using the method in this question to change the body of a Scaffold in flutter: Flutter Drawer Widget - change Scaffold.body content The method described works perfectly. Now I would like just the drawer to automatically close after the users taps on one of the items. I tried using the Navigator.pop() method, but it pops the entire screen, not just the drawer. It leaves me with a totally black screen. Any suggestions? 回答1: Are you using exactly Navigator.of(context).pop() ? I cannot

Skip jbuilder files when I generate a scaffold?

元气小坏坏 提交于 2020-05-25 15:24:12
问题 When I scaffold I don't want it to generate these files: invoke jbuilder create app/views/tests/index.json.jbuilder create app/views/tests/show.json.jbuilder But how? in my application.rb I have this: config.generators do |g| g.assets false g.helper false g.test_framework nil end 回答1: Use config.generators.jbuilder = false or config.generators do |g| g.assets false g.helper false g.test_framework nil g.jbuilder false end 回答2: Deleting or commenting out jbuilder from you Gemfile will do the

Flutter 粘合剂CustomScrollView控件

元气小坏坏 提交于 2020-05-07 09:14:46
老孟导读:快乐的51假期结束了,切换为努力模式,今天给大家分享CustomScrollView组件,此组件在以后的项目中会经常用到,CustomScrollView就像一个粘合剂,将多个组件粘合在一起,具统一的滚动效果。 CustomScrollView CustomScrollView是使用Sliver组件创建自定义滚动效果的滚动组件。使用场景: ListView和GridView相互嵌套场景,ListView嵌套GridView时,需要给GridView指定高度,但我们希望高度随内容而变化(不指定),ListView和GridView使用同一个滚动效果。 一个页面顶部是AppBar,然后是GridView,最后是ListView,这3个区域以整体来滚动,AppBar具有吸顶效果。 CustomScrollView就像一个粘合剂,将多个组件粘合在一起,具统一的滚动效果。 Sliver系列组件有很多,比如SliverList、SliverGrid、SliverFixedExtentList、SliverPadding、SliverAppBar等。 相互嵌套场景 在实际业务场景中经常见到这样的布局,顶部是网格布局(GridView),然后是列表布局(ListView),滚动的时候做为一个整体,此场景是无法使用GridView+ListView来实现的

Flutter 粘合剂CustomScrollView控件

人走茶凉 提交于 2020-05-07 08:53:11
老孟导读:快乐的51假期结束了,切换为努力模式,今天给大家分享CustomScrollView组件,此组件在以后的项目中会经常用到,CustomScrollView就像一个粘合剂,将多个组件粘合在一起,具统一的滚动效果。 CustomScrollView CustomScrollView是使用Sliver组件创建自定义滚动效果的滚动组件。使用场景: ListView和GridView相互嵌套场景,ListView嵌套GridView时,需要给GridView指定高度,但我们希望高度随内容而变化(不指定),ListView和GridView使用同一个滚动效果。 一个页面顶部是AppBar,然后是GridView,最后是ListView,这3个区域以整体来滚动,AppBar具有吸顶效果。 CustomScrollView就像一个粘合剂,将多个组件粘合在一起,具统一的滚动效果。 Sliver系列组件有很多,比如SliverList、SliverGrid、SliverFixedExtentList、SliverPadding、SliverAppBar等。 相互嵌套场景 在实际业务场景中经常见到这样的布局,顶部是网格布局(GridView),然后是列表布局(ListView),滚动的时候做为一个整体,此场景是无法使用GridView+ListView来实现的

2.NET 4.6.1向.NET core 2.0项目迁移(EntityFramework篇)

徘徊边缘 提交于 2020-04-27 20:01:37
作为一个.net core 的新手,在代码迁移的道路上,到处是坑,但是不要害怕,遇水搭桥、遇坑填坑,今天记录下EF所遇到的问题。 众所周知,EF是微软推出的很好用的实体映射框架(ORM object record mapping),我工作过的项目从.net 2.0以来到.net 4.6,所有项目都用它来访问数据库不论是mysql\sql server或是oracle, 到.net core微软同样出了Microsoft.EntityFrameworkCore的包支持。 https://www.nuget.org/packages?q=entityframeworkcore 你可以看到各种数据库对应的.net core版本。 Microsoft.EntityFrameworkCore Oracle.EntityFrameworkCore Microsoft.EntityFrameworkCore.SqlServer Microsoft.EntityFrameworkCore.Sqlite MySql.Data.EntityFrameworkCore 这里列出几个常用的数据库, 本例使用VS Code经过实测,mysql 和sql server版本都成功的实现了实体生成,oracle的实体生成过程遇到一些问题。 以下说一下过程: 1. Sql Server