V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
PopeyeLau
V2EX  ›  程序员

Flutter 最近很火呀 用 Flutter 写了个 人人影视 的小 demo

  •  6
     
  •   PopeyeLau ·
    popeyelau · 2018-07-30 21:49:56 +08:00 · 16249 次点击
    这是一个创建于 2067 天前的主题,其中的信息可能已经有所发展或是发生改变。

    GitHub 地址

    不得不说有 Hot Reload 写起来真是太爽了.

    部分截图:

    参考资料: 官方文档

    Flutter 中文网

    Flutter 跨平台移动应用开发实战

    48 条回复    2019-03-07 08:51:07 +08:00
    HuHui
        1
    HuHui  
       2018-07-30 22:51:10 +08:00
    :strong
    WildCat
        2
    WildCat  
       2018-07-30 22:51:37 +08:00
    不错,最近要准备开发 wetoo 第二版了。
    jowuIM
        3
    jowuIM  
       2018-07-30 22:57:16 +08:00 via Android
    dart 跟 js 写起来差别大吗?最近也想写几个 demo,感觉 flutter 很简洁
    PopeyeLau
        4
    PopeyeLau  
    OP
       2018-07-30 23:02:35 +08:00 via iPhone
    @jowuIM 差别不太 可以直接上手
    Zzdex
        5
    Zzdex  
       2018-07-30 23:04:02 +08:00
    好火啊,,,想接触一下
    WildCat
        6
    WildCat  
       2018-07-30 23:05:33 +08:00
    Crash 挺多的,我 run 了下你的有个 nosuchmethod error
    PopeyeLau
        7
    PopeyeLau  
    OP
       2018-07-30 23:07:25 +08:00 via iPhone
    @WildCat 麻烦 贴一下 error 信息
    PopeyeLau
        8
    PopeyeLau  
    OP
       2018-07-30 23:15:18 +08:00
    WildCat
        9
    WildCat  
       2018-07-30 23:18:30 +08:00
    @PopeyeLau =。=
    我更新了下我的 flutter sdk,结果直接无法启动了: https://github.com/flutter/flutter/issues/19618
    WildCat
        10
    WildCat  
       2018-07-31 01:01:52 +08:00
    还是有 Error:

    the right.
    [VERBOSE-2:dart_error.cc(16)] Unhandled exception:
    type 'String' is not a subtype of type 'List<dynamic>'
    #0 Networking.fetchVideoComments (package:yyets/api/api.dart:162:42)
    <asynchronous suspension>
    #1 _VideoPageState.initState (package:yyets/pages/video.dart:40:10)
    #2 StatefulElement._firstBuild (package:flutter/src/widgets/framework.dart:3764:58)
    #3 ComponentElement.mount (package:flutter/src/widgets/framework.dart:3630:5)
    #4 Element.inflateWidget (package:flutter/src/widgets/framework.dart:2920:14)
    #5 Element.updateChild (package:flutter/src/widgets/framework.dart:2723:12)
    #6 SingleChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:4667:14)
    #7 Element.inflateWidget (package:flutter/src/widgets/framework.dart:2920:14)
    #8 Element.updateChild (package:flutter/src/widgets/framework.dart:2723:12)
    #9 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3666:16)
    #10 Element.rebuild (package:flutter/src/<…>
    flutter: Another exception was thrown: A RenderFlex overflowed by 4.5 pixels on the right.
    flutter: Another exception was thrown: A RenderFlex overflowed by 4.5 pixels on the right.
    flutter: Another exception was thrown: A RenderFlex overflowed by 4.5 pixels on the right.
    WildCat
        11
    WildCat  
       2018-07-31 01:12:43 +08:00   ❤️ 1
    整体可以运行,估计你的 flutter 分支是 master,我的是 dev,不是很兼容。

    poster 的 magic move 效果很赞,能介绍下是怎么实现的吗?简单读了下代码没理解。

    代码很强大,star 下。
    debuggerx
        12
    debuggerx  
       2018-07-31 04:50:37 +08:00   ❤️ 3
    @WildCat 典型的 json 映射解析错误,按照官网文档推荐的写法确实容易报这种类型错误……可以试试我的解析工具自动生成 bean 代码:
    https://juejin.im/post/5b4e04bbe51d45198c018e6e

    你说的 magic move 估计是 MD 里的 Hero,Flutter 的 SDK 里自带了 Hero 的实现:
    https://flutter.io/animations/hero-animations/
    WildCat
        13
    WildCat  
       2018-07-31 04:55:17 +08:00   ❤️ 1
    @debuggerx 太感谢了,专业!
    目前有个问题,似乎 flutter master 分支上没法跑这个项目了,提示 JSON 不存在。似乎在 convert 这个包里,但是新版 dart language 似乎没有这个了?
    ericgui
        14
    ericgui  
       2018-07-31 06:26:08 +08:00
    非常困惑的第一个地方:yyets 开放了 api ?
    ericgui
        15
    ericgui  
       2018-07-31 06:33:51 +08:00
    哦,看来是抓包
    PopeyeLau
        16
    PopeyeLau  
    OP
       2018-07-31 06:43:37 +08:00 via iPhone   ❤️ 1
    @WildCat 回头用 json_serializable 重新写一下。
    WildCat
        17
    WildCat  
       2018-07-31 06:47:53 +08:00
    @PopeyeLau 你的电脑上 flutter 可以用 IntelliJ 调试么?我这里只能 vscode 调试,IntelliJ 的插件调试失败。好多坑。
    PopeyeLau
        18
    PopeyeLau  
    OP
       2018-07-31 06:50:31 +08:00   ❤️ 1
    @WildCat #17 我一直用 VSCode , 还没遇到什么大坑
    debuggerx
        19
    debuggerx  
       2018-07-31 06:52:24 +08:00   ❤️ 2
    @WildCat 我一直用的推荐的 beta 分支。。具体没查证,不过看你说的估计是因为 convert 包里的 JSON 解析器彻底删除了,beta 版本则是"过时的"状态。。dart2.0 以后 sdk 里大量的静态工具对象名都从大写改成了小写,并把大写的版本标记为过时,可能最新的 master 全给删了吧。。

    我当时也是为这事给自己的工具专门更新了个版本……:
    https://github.com/debuggerx01/JSONFormat4Flutter/commit/ad5fc83d066933a906967cf4543ef9944f278ae8
    debuggerx
        20
    debuggerx  
       2018-07-31 07:16:42 +08:00   ❤️ 1
    @PopeyeLau 确认了下,确实时删了。。
    beta 分支使用的 SDK 源码,第 68 ~ 70 行还有标记为删除的 JSON 静态对象:
    https://github.com/dart-lang/sdk/blob/2.0.0-dev.58.0/sdk/lib/convert/json.dart
    到了最新的版本,在同样位置已经只剩 json 了:
    https://github.com/dart-lang/sdk/blob/master/sdk/lib/convert/json.dart

    可以批量替换更新下工程了。
    类似的可能还有,比如类似 double.infinity 和 double.INFINITY,math 包里的 pi 和 PI 等……
    PopeyeLau
        21
    PopeyeLau  
    OP
       2018-07-31 07:21:10 +08:00
    @debuggerx #20 谢谢提醒,已经换成 json 了。我也切到 beta channel 跑一下。
    PopeyeLau
        22
    PopeyeLau  
    OP
       2018-07-31 07:29:28 +08:00
    @debuggerx #20
    beta channel 还没有 `ListView.separate` 这个 constructor。
    laincat
        23
    laincat  
       2018-07-31 08:33:58 +08:00
    这里特别想 @ 人人 官方。。。
    lyping
        24
    lyping  
       2018-07-31 08:42:52 +08:00
    还没有写过 APP,请教一下,他和 HTML5 写的有什么有时呢?比如国内的 Mui 框架
    dodo2012
        25
    dodo2012  
       2018-07-31 08:43:50 +08:00
    什么都好,就是那个嵌套看的头晕。
    e8c47a0d
        26
    e8c47a0d  
       2018-07-31 09:04:26 +08:00
    只要 dart 还需要写分号,就不用 Flutter。
    Aphsss
        27
    Aphsss  
       2018-07-31 09:14:01 +08:00
    我简单看了下 dart,为什么 String 的 S 要大写,同样是基础类型的 int 的 i 要小写?
    zmlu
        28
    zmlu  
       2018-07-31 09:21:18 +08:00
    @Aphsss Java 也一样不是吗
    Aphsss
        29
    Aphsss  
       2018-07-31 09:32:02 +08:00
    @zmlu

    我的参考链接:
    java https://www.cnblogs.com/future-liu1121/p/6556153.html
    dart https://www.jianshu.com/p/3d927a7bf020

    我的理解是 java 里面 String Integer 是包装类,所以要大写,char int 是基础类型,要小写
    但是 dart 里面,double String 都是对象,感觉 code style 不统一,有点怪怪的
    zhzer
        30
    zhzer  
       2018-07-31 09:43:42 +08:00
    前端要搞这个,上手学习曲线陡吗?想试试
    hayvane
        31
    hayvane  
       2018-07-31 09:45:01 +08:00 via iPhone
    @dodo2012 同感
    jimmy
        32
    jimmy  
       2018-07-31 09:50:41 +08:00
    ListView.separate 在稳定版中没有相关的方法,话说,使用这个项目的前提条件是什么?
    jimmy
        33
    jimmy  
       2018-07-31 09:54:29 +08:00
    我的环境
    >Doctor summary (to see all details, run flutter doctor -v):
    >[✓] Flutter (Channel beta, v0.5.1, on Mac OS X 10.13.6 17G65, locale en-CN)
    >[✓] Android toolchain - develop for Android devices (Android SDK 28.0.1)
    >[✓] iOS toolchain - develop for iOS devices (Xcode 9.4.1)
    >[✓] Android Studio (version 3.1)
    >[!] VS Code (version 1.25.1)
    >[✓] Connected devices (3 available)

    >! Doctor found issues in 1 category.

    报错为:
    >compiler message: lib/widgets/help_list_view.dart:12:23: Error: Method not found: 'ListView.separated'.
    501691899
        34
    501691899  
       2018-07-31 10:07:14 +08:00
    66666666666666666
    PopeyeLau
        35
    PopeyeLau  
    OP
       2018-07-31 10:18:45 +08:00
    @jimmy #32 先切到 dev 上去吧 `$flutter channel dev`
    mht
        36
    mht  
       2018-07-31 11:31:27 +08:00
    想问下 UI 轮播图这些 是 flutter 都会提供吗
    foolyf
        37
    foolyf  
       2018-07-31 15:00:06 +08:00
    我最近也正在看 flutter,投资下技术
    AaronXu
        38
    AaronXu  
       2018-07-31 15:55:18 +08:00
    为什么从我创建项目非常非常的慢,等半天了......
    ofblyt
        39
    ofblyt  
       2018-07-31 16:17:25 +08:00
    我没进来我就猜到是前端框架
    WildCat
        40
    WildCat  
       2018-07-31 19:35:57 +08:00
    @AaronXu 看中国区如何设置源
    PopeyeLau
        41
    PopeyeLau  
    OP
       2018-07-31 19:58:57 +08:00 via iPhone   ❤️ 1
    @mht 类似这种轮播 有提供 PageView 简单拼装一下就 OK 了
    其他组件同理。
    hyyou2010
        42
    hyyou2010  
       2018-08-01 08:36:00 +08:00
    刚看这个,请教:flutter 对于第三方 java 库 /socketio/各种推送 sdk 等等的支持怎样?无缝调用?
    AaronXu
        43
    AaronXu  
       2018-08-01 10:32:48 +08:00
    @WildCat
    export PUB_HOSTED_URL=https://pub.flutter-io.cn //国内用户需要设置
    export FLUTTER_STORAGE_BASE_URL=https://storage.flutter-io.cn //国内用户需要设置
    export PATH= PATH_TO_FLUTTER_GIT_DIRECTORY/flutter/bin:$PATH

    是这个吧!这个我也加了
    deathscythe
        44
    deathscythe  
       2018-08-01 16:34:48 +08:00
    跑在手机卡到飞起~~~~
    Mcatt
        45
    Mcatt  
       2018-08-01 18:00:12 +08:00
    star 一波
    Mogugugugu
        46
    Mogugugugu  
       2018-08-04 22:42:00 +08:00
    Android Studio 3.1 之后的版本貌似有没法 hot reload = = 很蛋疼,看 Issue 也没人解决 - -
    ericgui
        47
    ericgui  
       2018-09-27 13:38:15 +08:00
    大佬,你用的 api 是怎么拿到的啊?我尝试着抓包,奈何水平比较差。

    人人视频是有对外的 api 吗?
    BitBoX
        48
    BitBoX  
       2019-03-07 08:51:07 +08:00
    大佬求更新,现在 dart sdk 升级到 2.0 了。
    里面
    chewie
    open_iconic_flutter
    版本冲突不会解决。
    麻烦大佬更新一波。然后给编译个 apk 版本。
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   3512 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 32ms · UTC 10:48 · PVG 18:48 · LAX 03:48 · JFK 06:48
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.