Code Monkey home page Code Monkey logo

flutter-in-action's Issues

对书顺序的一些意见

作者是否能通调整下章节的顺序,能否先讲布局和容器因为在基础的widget中用到了很多布局和容器,在没有这些概念前感觉读者读起来很费劲,而且不便于对书中的代码理解。

typo: “勘”误

书中每页底部的:
“本书仍在堪误阶段,请勿以任何形式私自传播,作者保留对本书的版权。”
中的勘误写错了。

主题-Theme的demo代码floatingActionButton不会跟随主题变色

Widget build(BuildContext context) {
ThemeData themeData = Theme.of(context);
return Theme(
data: ThemeData(
accentColor: currentThemeColor,
accentIconTheme: IconThemeData(
color: Colors.white
),
primaryColor: currentThemeColor,
iconTheme: IconThemeData(color: currentThemeColor),
),
......
}

需要加上accentColor跟accentIconTheme才能实现教程中图片的效果。

TextField的下划线可以单独设置颜色

一种方式是在Theme的inputDecorationTheme
另外一种方式是在TextField的decoration

focusedBorder: UnderlineInputBorder(borderSide: BorderSide(color: Colors.lightGreenAccent)),
enabledBorder: UnderlineInputBorder(borderSide: BorderSide(color: Colors.yellowAccent)),

chapter8 事件总线,示例代码存在一点问题

我按示例代码中的逻辑测试发现,bus.on("xx",(arg){}) 添加在了一个页面,这个页面每次加载会多次添加监听事件。这时当另一个页面(比如登录页面)触发bus.emit(“xx”);时,前面on的地方也会被多次调用。

第4章流式布局Flow

x += context.getChildSize(i).width + margin.left + margin.right;应该放到else内~~
如图:
image

问一个问题,在「滚动监听及控制ScrollController」关于NotificationListener的示例。

NotificationListener的示例中,有一个Stack里面有一个ListViewCircleAvatar

child: Stack(
          alignment: Alignment.center,
          children: <Widget>[
            ListView.builder(
                itemCount: 100,
                itemExtent: 50.0,
                itemBuilder: (context, index) {
                  return ListTile(title: Text("$index"));
                }
            ),
            CircleAvatar(  //显示进度百分比
              radius: 30.0,
              child: Text(_progress),
              backgroundColor: Colors.black54,
            )
          ],
        ),

我debug模式运行在真机上滑动ListView会卡顿,后来我尝试了一下把ListView提取出来在build方法外用变量声明再跑竟然就不会卡顿了,还是在debug模式

 final ListView listView = ListView.builder(
                  itemCount: 100,
                  itemExtent: 50.0,
                  itemBuilder: (context, index) {
                    return ListTile(title: Text("$index"),);
                  }
              );

Stack(
                  alignment: Alignment.center,
                  children: <Widget>[
                    listView,
                    CircleAvatar(  //显示进度百分比
                      radius: 30.0,
                      child: Text(_progress),
                      backgroundColor: Colors.black54,
                    )
                  ],
                )

我仿写前面demo的时候试过把要改变的 Widget 单独提取成StatefulWidget,性能能提高,但是这虽然把ListView提取出来了,还是在这个Statebuild方法中,讲道理应该还是会重新绘制的,为什么这样还会有性能区别呢?

书籍错别字修正

开头第一个 “缘由”里面有句话叫:当然还有另外一个原因就是要做实体书的“化”。。。这里的化应该是“话”

书里的window下的安装方法,不太适用当前版本了。

书里提到windows下可以手动下载SDK,但似乎现在windows下flutter不能通过手动下载SDK来安装,必须通过git clone。

按照书里手动下载的话,会报错,并提示用git clone官方github库。

而且clone下来后,运行“flutter docter“命令还会报一个“Error: Unable to update Dart SDK. Retrying...“的错误,需要配置另外一个环境变量才能解决

加载图片

在配置文件中
assets:

  • images/icon_home_dis.png

在项目images文件夹下建立了2.0x、3.0x文件夹,分别放2x、3x图
_bdc82612-4623-4c60-8a7a-c1645d431e04

在代码中,使用如下:
Image.asset('images/icon_home_dis.png');
运行报错,images/icon_home_dis.png not found

按照官方解释,images/icon_home_dis.png是主资源,而2x和3x是变体,会根据设备分辨率自动加载合适的图片。但是,这样会造成打包之后,资源包会多出主资源的图片,实际上我们只需要2x和3x图

转换成PDF出错

在使用gitbook pdf命令将电子书导出成PDF的过程中报错
{ Error: Cannot find module 'prismjs/components/prism-shell.js'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:580:15)
at Function.Module._load (internal/modules/cjs/loader.js:506:25)
at Module.require (internal/modules/cjs/loader.js:636:17)
at require (internal/modules/cjs/helpers.js:20:18)
at requireSyntax (/Users/minghe/Workspaces/GitHub/flutter-in-action/node_modules/gitbook-plugin-prism/index.js:31:3)
at Object.code (/Users/minghe/Workspaces/GitHub/flutter-in-action/node_modules/gitbook-plugin-prism/index.js:103:11)
at Record.TemplateBlock.applyBlock (/Users/minghe/.gitbook/versions/3.2.3/lib/models/templateBlock.js:205:23)
at /Users/minghe/.gitbook/versions/3.2.3/lib/output/getModifiers.js:56:33
at /Users/minghe/.gitbook/versions/3.2.3/lib/output/modifiers/highlightCode.js:47:24
at /Users/minghe/.gitbook/versions/3.2.3/lib/output/modifiers/editHTMLElement.js:11:16 code: 'MODULE_NOT_FOUND' }
Failed to load prism syntax: shell
大概就是这样的错误,多次出现,不知道是不是我自己操作的问题。

最新版本flutter命名路由已经可以传参数了

///
/// void _showWeather() {
/// Navigator.pushNamed(
/// context,
/// '/weather',
/// arguments: WeatherRouteArguments(city: 'Berlin', country: 'Germany'),
/// );
/// }
/// ```
/// {@end-tool}
@optionalTypeArgs
static Future pushNamed(
BuildContext context,
String routeName, {
Object arguments,
}) {
return Navigator.of(context).pushNamed(routeName, arguments: arguments);
}

【勘误】关于flutter-in-action/docs/chapter1/configuration.md

flutter-in-action/docs/chapter1/configuration.md 中最后 安卓包配置问题 第4点

原文
“进入 File/ Settings/ Build, Execution, Deployment/ Gradle/ Android Studio 中,勾选上 Enable embedded Maven repository ,重启 Android Studio 即可解决”

应为
“进入 File/ Settings/ Build, Execution, Deployment/ BuildTools/ Gradle/ Android Studio 中,勾选上 Enable embedded Maven repository ,重启 Android Studio 即可解决”

Json 转 model : Unsupported operation: The class `` has no default constructor.

[INFO] Generating build script...
[INFO] Generating build script completed, took 281ms

[INFO] Initializing inputs
[INFO] Reading cached asset graph...
[INFO] Reading cached asset graph completed, took 103ms

[INFO] Checking for updates since last build...
[INFO] Checking for updates since last build completed, took 653ms

[INFO] Running build...
[INFO] Running build completed, took 16ms

[INFO] Caching finalized dependency graph...
[INFO] Caching finalized dependency graph completed, took 65ms

[SEVERE] json_serializable on lib/http/mo/template.dart (cached):
Error running JsonSerializableGenerator
Unsupported operation: The class `` has no default constructor.
[SEVERE] Failed after 99ms
pub finished with exit code 1

执行 mo.sh 文件一直报错,以上是执行日志。

Hero动画中的demo代码

  1. PageScaffold 是什么?是不是可以换成Scaffold。
  2. 路由B中的代码,有个“,”写成了“,”。

《数据共享-InheritedWidget》

  1. 若要与图片的显示效果相同,_InheritedWidgetTestRouteState的build方法,根节点应该是Scaffold

  2. 最后一段,“应该在didChangeDependencies()中做什么?”中“昂贵的操作” 猜测是 “耗时的操作”

文件操作如何读取assets下的文件

示例中new File('$dir/counter.txt'); 想咨询下,这个counter.txt存放在flutter项目的哪里?如果我想在assets下存放一个文件,然后读取该如何获取路径?

《流式布局》中Flow代码片段中代码错误

在《流式布局》这章中,Flow的代码片段paintChildren这个方法中,如果想要实现图片的效果x += context.getChildSize(i).width + margin.left + margin.right; 要移出eles外。即

void paintChildren(FlowPaintingContext context) {
  for (int i = 0; i < context.childCount; i++) {
    if (w < context.size.width) {
      ···
    }else{
     ···
    }
       x += context.getChildSize(i).width+ margin.left + margin.right;
  }
}

发现一个错别字

有些语言即可以以JIT方式...

有些语言既可以以JIT方式...

追加一个

旨在让读者心中有一个整体的映像

旨在让读者心中有一个整体的印象

关于自定义字体多人协作以及后续维护问题

image
1、如上图所示,flutter支持自定义图标,按这种方式,后续如何进行自定义图标的增加、删减呢?
另外如果想使用自己设计的图片应该如何生成tff文件以及相应的dart文件呢?我查出来有一个http://fluttericon.com/ 但是也有维护等相关问题,同时转换的部分图标由线性转换为了实体填充。
2、如果需要多人协作的情况,如何避免自己加了新图标的文件被冲掉?
如有好的方法,请指教

gitbook install 异常

按照指示命令可以安装成功,但是运行gitbook install 异常。
错误信息如下:
You need to install "gitbook-cli" to have access to the gitbook command anywhere on your system.
If you've installed this package globally, you need to uninstall it.

Run "npm uninstall -g gitbook" then "npm install -g gitbook-cli"

按照提示重新执行了一次,gitbook install 就成功了。
是否可以变更 为: npm install -g gitbook-cli

按钮这篇文章没有

Git上有,但是网站上没有,不知道是不是因为没完成,还是说忘记放链接了。

InheritedWidget章节代码注释问题

InheritedWidget章节中,应该是返回true则依赖本控件data的子树会执行didChangeDependencies()回调,原文是false
原文:

  //该回调决定当data发生变化时,是否通知子树中依赖data的Widget  
  @override
  bool updateShouldNotify(ShareDataWidget old) {
    //如果返回false,则子树中依赖(build函数中有调用)本widget
    //的子widget的`state.didChangeDependencies`会被调用
    return old.data != data;
  }

开发效率问题

qq 20181228202502

这里 RN/Weex 为代表的开发效率应该是高才对,种种实践表明,RN/Weex 的开发效率比 Flutter 还要快。(快很多),有点误导人了。

《包管理》章节语句修改

在第一段的最后一句是:
本节我们主要介绍一下flutter下如何是使用配置文件pubspec.yaml(位于项目根目录)来管理第三方依赖包。
这句读起来有点拗口,改成
本节我们主要介绍一下flutter如何使用配置文件pubspec.yaml(位于项目根目录)来管理第三方依赖包。
是否会更通顺易读呢?

第六章 SliverGridDelegateWithMaxCrossAxisExtent maxCrossAxisExtent的疑问

SliverGridDelegateWithMaxCrossAxisExtent
该子类实现了一个纵轴子元素为固定最大长度的layout算法,其构造函数为:

SliverGridDelegateWithMaxCrossAxisExtent({
double maxCrossAxisExtent,
double mainAxisSpacing = 0.0,
double crossAxisSpacing = 0.0,
double childAspectRatio = 1.0,
})
maxCrossAxisExtent为子元素在纵轴上的最大长度,之所以是“最大”长度,是因为纵轴方向每个子元素的长度仍然是等分的,举个例子,如果ViewPort的纵轴长度是450,那么当maxCrossAxisExtent的值在区间(450/4,450/3]内的话,子元素最终实际长度都为150,而childAspectRatio所指的子元素纵轴和主轴的长度比为最终的长度比。其它参数和SliverGridDelegateWithFixedCrossAxisCount相同。

看了这篇的说法 maxCrossAxisExtent 字段我还是不太理解
(450/4,450/3]内的话 4 和3 哪来的, 和childAspectRatio 又有什么关系

希望可以描述的更加清楚

gitbook serve启动时出现错误

已安装npm install -g gitbook-cli
Failed to load prism syntax: shell
{ Error: Cannot find module 'prismjs/components/prism-shell.js'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:594:15)
at Function.Module._load (internal/modules/cjs/loader.js:520:25)
at Module.require (internal/modules/cjs/loader.js:650:17)
at require (internal/modules/cjs/helpers.js:20:18)
at requireSyntax (/Users/unreal/Downloads/html/flutter-in-action/node_modules/gitbook-plugin-prism/index.js:31:3)
at Object.code (/Users/unreal/Downloads/html/flutter-in-action/node_modules/gitbook-plugin-prism/index.js:103:11)
at Record.TemplateBlock.applyBlock (/Users/unreal/.gitbook/versions/3.2.3/lib/models/templateBlock.js:205:23)
at /Users/unreal/.gitbook/versions/3.2.3/lib/output/getModifiers.js:56:33
at /Users/unreal/.gitbook/versions/3.2.3/lib/output/modifiers/highlightCode.js:47:24
at /Users/unreal/.gitbook/versions/3.2.3/lib/output/modifiers/editHTMLElement.js:11:16 code: 'MODULE_NOT_FOUND' }
Failed to load prism syntax: shell

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.