时间:2021-02-14 11:28:22 | 栏目:Android代码 | 点击:次
Flutter是Google使用Dart语言开发的移动应用开发框架,使用一套Dart代码就能构建高性能、高保真的iOS和Android应用程序,并且在排版、图标、滚动、点击等方面实现零差异。
2年前,RN刚出来时做了个仿拉钩的demo,react-native-lagou.
这次flutter来了,想感受一下,索性用目前flutter的版本写的一个仿boss直聘应用。
时间有限,没完全仿照,去掉了一些功能,但是界面风格一致,有参考价值。
github地址:flutter仿boss直聘.
感悟
先上效果
部署到手机
确保flutter正确安装之后,进入目录运行flutter run --release
环境问题
如果flutter环境有问题,在.bash_profile里加上如下内容
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], )
2.自定义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() ] ); }
3.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, ), ], ), ), )
4.解决了官方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
总结