flutter仿boss直聘,一個比較完整的例子(一)

基於Flutter1.0的最新版原本了,請前往查看flutter仿BOSS直聘(二),大前端技術實現.

簡介:2年前,RN剛出來時作了個仿拉鉤的demo,react-native-lagou. 此次flutter來了,想感覺一下,索性用目前flutter的版本寫的一個仿boss直聘應用。 時間有限,沒徹底仿照,去掉了一些功能,可是界面風格一致,有參考價值。前端

感悟

  1. 與一些文章裏介紹的很是類似,若是會RN,那麼學起來會很快,flutter借鑑了RN的組件化思想,路由機制,狀態機等。
  2. Dart語法有些奇葩,但掌握以後,開發效率會很快,整個demo加起來開發了2天不到。
  3. 能夠同時在android和ios運行。
  4. 性能很快,超過RN,由於沒有bridge層。
  5. 仍是要多看官方文檔和源碼,才能碰到問題解決。
  6. IDE還不是很友好,hot reload有時無效。
  7. 仍是比RN要複雜一些的。

先上效果

img

部署到手機

確保flutter正確安裝以後,進入目錄運行flutter run --releasereact

環境問題

若是flutter環境有問題,在.bash_profile里加上以下內容android

export PUB_HOSTED_URL=https://pub.flutter-io.cn
export FLUTTER_STORAGE_BASE_URL=https://storage.flutter-io.cn
export PATH=`pwd`/flutter/bin:$PATH
複製代碼

涉及技術點

  1. Theme主題設置
theme: new ThemeData(
        primaryIconTheme: const IconThemeData(color: Colors.white),
        brightness: Brightness.light,
        primaryColor: new Color.fromARGB(255, 0, 215, 198),
        accentColor: Colors.cyan[300],
      )
複製代碼
  1. 自定義TabBar
@override
      Widget build(BuildContext context) {
        assert(debugCheckHasMaterial(context));
    
        double height = _kTextAndIconTabHeight;
        Widget label = new Column(
            mainAxisAlignment: MainAxisAlignment.center,
            crossAxisAlignment: CrossAxisAlignment.center,
            children: <Widget>[
              new Container(
                child: new Image(
                  image: new AssetImage(this.icon),
                  height: 30.0,
                  width: 30.0,
                ),
                margin: const EdgeInsets.only(bottom: _kMarginBottom),
              ),
              _buildLabelText()
            ]
        );
      }
複製代碼
  1. MD風格及一些組件應用
new SliverAppBar(
      expandedHeight: _appBarHeight,
      pinned: _appBarBehavior == AppBarBehavior.pinned,
      floating: _appBarBehavior == AppBarBehavior.floating ||
          _appBarBehavior == AppBarBehavior.snapping,
      snap: _appBarBehavior == AppBarBehavior.snapping,
      flexibleSpace: new FlexibleSpaceBar(
        title: new Text(_company.name,
            style: new TextStyle(color: Colors.white)),
        background: new Stack(
          fit: StackFit.expand,
          children: <Widget>[
            new Image.network(
              'https://img.bosszhipin.com/beijin/mcs/chatphoto/20170725/861159df793857d6cb984b52db4d4c9c.jpg',
              fit: BoxFit.cover,
              height: _appBarHeight,
            ),
          ],
        ),
      ),
    )
複製代碼
  1. 解決了官方demo里路由跳轉效果卡頓的問題
Navigator.of(context).push(new PageRouteBuilder(
        opaque: false,
        pageBuilder: (BuildContext context, _, __) {
          return new CompanyDetail(company);
        },
        transitionsBuilder: (_, Animation<double> animation, __, Widget child) {
          return new FadeTransition(
            opacity: animation,
            child: new SlideTransition(position: new Tween<Offset>(
              begin: const Offset(0.0, 1.0),
              end: Offset.zero,
            ).animate(animation), child: child),
          );
        }
    ));
複製代碼

TODO

  1. 下拉篩選組件
  2. mock server,模擬真實請求
  3. 分頁
  4. 目錄結構調整,更符合生產環境
  5. viewpager輪播圖
  6. 路由機制封裝

聯繫方式

微信:heruijun2258,註明來意。ios

相關文章
相關標籤/搜索