Flutter37,androidui开发

});},);},//分割线separatorBuilder: (context, index) {return Divider();},itemCount: menuTitles.length + 1);}_login() async {final result = await Navigator.of(context).push(MaterialPageRoute(builder: (context) => LoginWebPage()));if (result !=
摘要由CSDN通过智能技术生成

});

},

);

},

//分割线

separatorBuilder: (context, index) {

return Divider();

},

itemCount: menuTitles.length + 1

);

}

_login() async {

final result = await Navigator.of(context)

.push(MaterialPageRoute(builder: (context) => LoginWebPage()));

if (result != null && result == ‘refresh’) {

print(‘Debug profile page LoginEvent’);

//登录成功

eventBus.fire(LoginEvent());

}

}

Container _buildHeader() {

return Container(

height: 150.0,

color: Color(AppColors.APP_THEME),

//头像的布局填充

child: Center(

child: Column(

mainAxisAlignment: MainAxisAlignment.center,

children: [

GestureDetector(

//先判断网路图片是否为空

child: userAvatar != null

? Container(

width: 60.0,

height: 60.0,

decoration: BoxDecoration(

shape: BoxShape.circle,

border: Border.all(

color: Color(0xffffffff),

width: 2.0,

),

image: DecorationImage(

//加载网路图片

image: NetworkImage(userAvatar),

fit: BoxFit.cover,

),

),

)

//加载网路图片
Image.asset(‘assets/images/ic_avatar_default.png’,

width: 60.0,

height: 60.0,

),

onTap: () {

//执行登录

DataUtils.isLogin().then((isLogin){

if(isLogin){

//点击以后跳转到详情

Navigator.of(context).push(MaterialPageRoute(

builder: (context) => ProfileDetailPage()));

}else{

//执行登录

_login();

}

});

},

),

SizedBox(

),

Text(

userName ??= ‘点击头像登录’,

style: TextStyle(color: Color(0xffffffff)),

),

],

),

),

);

}

}

profile_detail_page.dart

import ‘dart:convert’;

import ‘package:flutter/cupertino.dart’;

import ‘package:flutter/material.dart’;

import ‘package:flutterapp2/constants/Constants.dart’;

import ‘package:flutterapp2/models/user_info.dart’;

import ‘package:flutterapp2/utils/data_utils.dart’;

import ‘package:flutterapp2/utils/net_utils.dart’;

/**

  • 用户详情界面

*/

class ProfileDetailPage extends StatefulWidget {

@override

_ProfileDetailPageState createState() => _ProfileDetailPageState();

}

class _ProfileDetailPageState extends State {

UserInfo _userInfo;

//获取用户信息

_getDetailInfo() {

DataUtils.getAccessToken().then((accessToken) {

//Debug accessToken: 21b8d7d0-6bef-469f-ba64-033d47387d50

print(‘Debug accessToken: $accessToken’);

//拼装请求

Map<String, dynamic> params = Map<String, dynamic>();

params[‘dataType’] = ‘json’;

params[‘access_token’] = accessToken;

NetUtils.get(AppUrls.MY_INFORMATION, params).then((data) {

// {“gender”:1,“joinTime”:“2014-09-03 10:01:47”,“city”:“长沙”,“fansCount”:0,“portrait”:“https://www.oschina.net/img/portrait.gif”,“expertise”:[“手机软件开发”,“软件开发管理”],“platforms”:[“Android”,“C/C++”],“uid”:2006874,“lastLoginTime”:“2019-04-09 22:33:03”,“province”:“湖南”,“name”:“Damon2019”,“followersCount”:0,“favoriteCount”:0,“notice”:{“referCount”:0,“replyCount”:0,“msgCount”:0,“fansCount”:0}}

//Debug MY_INFORMATION: {“gender”:1,“joinTime”:“2020-06-30 01:45:04”,“city”:“深圳”,“fansCount”:0,“portrait”:“https://static.oschina.net/uploads/user/2285/4571926_50.jpg?t=1593452705000”,“expertise”:[],“platforms”:[],“uid”:4571926,“lastLoginTime”:“2020-10-09 01:43:08”,“province”:“广东”,“name”:“Augfun”,“followersCount”:0,“favoriteCount”:0,“notice”:{“referCount”:0,“replyCount”:0,“msgCount”:1,“fansCount”:0}

print(‘Debug MY_INFORMATION: $data’);

if (data != null && data.isNotEmpty) {

Map<String, dynamic> map = json.decode(data);

UserInfo userInfo = UserInfo();

userInfo.uid = map[‘uid’];

userInfo.name = map[‘name’];

userInfo.gender = map[‘gender’];

userInfo.province = map[‘province’];

userInfo.city = map[‘city’];

userInfo.platforms = map[‘platforms’];

userInfo.expertise = map[‘expertise’];

userInfo.joinTime = map[‘joinTime’];

userInfo.lastLoginTime = map[‘lastLoginTime’];

userInfo.portrait = map[‘portrait’];

userInfo.fansCount = map[‘fansCount’];

userInfo.favoriteCount = map[‘favoriteCount’];

userInfo.followersCount = map[‘followersCount’];

userInfo.notice = map[‘notice’];

//刷新用户信息

setState(() {

_userInfo = userInfo;

});

}

});

});

}

@override

void initState() {

super.initState();

_getDetailInfo();

}

@override

Widget build(BuildContext context) {

return Scaffold(

appBar: AppBar(

elevation: 0.0,

title: Text(

‘我的资料’,

style: TextStyle(

color: Color(AppColors.APPBAR),

),

),

iconTheme: IconThemeData(color: Color(AppColors.APPBAR)),

),

body: buildSingleChildScrollView(),

);

}

Widget buildSingleChildScrollView() {

return SingleChildScrollView(

child: _userInfo == null

? Center(

child: CupertinoActivityIndicator(),

)
Column(

children: [

InkWell(

onTap: () {

//TODO

},

child: Container(

margin: const EdgeInsets.only(left: 20.0),

padding: const EdgeInsets.only(

top: 10.0, bottom: 10.0, right: 20.0),

child: Row(

crossAxisAlignment: CrossAxisAlignment.center,

mainAxisAlignment: MainAxisAlignment.spaceBetween,

children: [

Text(

‘头像’,

style: TextStyle(fontSize: 20.0),

),

Container(

width: 60.0,

height: 60.0,

decoration: BoxDecoration(

shape: BoxShape.circle,

border: Border.all(

color: Colors.white,

width: 2.0,

),

image: DecorationImage(

image: NetworkImage(_userInfo.portrait),

fit: BoxFit.cover,

),

),

)

],

),

),

),

Divider(),

InkWell(

onTap: () {

//TODO

},

child: Container(

margin: const EdgeInsets.only(left: 20.0),

padding: const EdgeInsets.only(

top: 10.0, bottom: 10.0, right: 20.0),

child: Row(

crossAxisAlignment: CrossAxisAlignment.center,

mainAxisAlignment: MainAxisAlignment.spaceBetween,

children: [

Text(

‘昵称’,

style: TextStyle(fontSize: 20.0),

),

Text(

_userInfo.name,

style: TextStyle(fontSize: 20.0),

),

],

),

),

),

Divider(),

Container(

margin: const EdgeInsets.only(left: 20.0),

padding: const EdgeInsets.only(

top: 10.0, bottom: 10.0, right: 20.0),

child: Row(

crossAxisAlignment: CrossAxisAlignment.center,

mainAxisAlignment: MainAxisAlignment.spaceBetween,

children: [

Text(

‘加入时间’,

style: TextStyle(fontSize: 20.0),

),

Text(

_userInfo.joinTime,

// _userInfo.joinTime.split(’ ')[0],

style: TextStyle(fontSize: 20.0),

),

],

),

),

Divider(),

InkWell(

onTap: () {

//TODO

},

child: Container(

margin: const EdgeInsets.only(left: 20.0),

padding: const EdgeInsets.only(

top: 10.0, bottom: 10.0, right: 20.0),

child: Row(

crossAxisAlignment: CrossAxisAlignment.center,

mainAxisAlignment: MainAxisAlignment.spaceBetween,

children: [

Text(

‘所在地区’,

style: TextStyle(fontSize: 20.0),

),

Text(

_userInfo.city,

style: TextStyle(fontSize: 20.0),

),

],

),

),

),

Divider(),

InkWell(

onTap: () {

//TODO

},

child: Container(

margin: const EdgeInsets.only(left: 20.0),

padding: const EdgeInsets.only(

top: 10.0, bottom: 10.0, right: 20.0),

child: Row(

crossAxisAlignment: CrossAxisAlignment.center,

mainAxisAlignment: MainAxisAlignment.spaceBetween,

children: [

Padding(

padding: const EdgeInsets.only(right: 20.0),

child: Text(

‘开发平台’,

style: TextStyle(fontSize: 20.0),

),

),

Expanded(

child: Text(

// ‘Android,C/C++,J2ME/K-Java,Python,.NET/C#’,

_userInfo.platforms.toString(),

style: TextStyle(fontSize: 20.0),

textAlign: TextAlign.right,

),

),

],

),

),

),

Divider(),

InkWell(

onTap: () {

//TODO

},

child: Container(

margin: const EdgeInsets.only(left: 20.0),

padding: const EdgeInsets.only(

top: 10.0, bottom: 10.0, right: 20.0),

child: Row(

crossAxisAlignment: CrossAxisAlignment.center,

mainAxisAlignment: MainAxisAlignment.spaceBetween,

children: [

Padding(

总结

现在新技术层出不穷,如果每次出新的技术,我们都深入的研究的话,很容易分散精力。新的技术可能很久之后我们才会在工作中用得上,当学的新技术无法学以致用,很容易被我们遗忘,到最后真的需要使用的时候,又要从头来过(虽然上手会更快)。

我觉得身为技术人,针对新技术应该是持拥抱态度的,入了这一行你就应该知道这是一个活到老学到老的行业,所以面对新技术,不要抵触,拥抱变化就好了。

Flutter 明显是一种全新的技术,而对于这个新技术在发布之初,花一个月的时间学习它,成本确实过高。但是周末花一天时间体验一下它的开发流程,了解一下它的优缺点、能干什么或者不能干什么。这个时间,并不是我们不能接受的。

如果有时间,其实通读一遍 Flutter 的文档,是最全面的一次对 Flutter 的了解过程。但是如果我们只有 8 小时的时间,我希望能关注一些最值得关注的点。

Android学习PDF+架构视频+面试文档+源码笔记

(跨平台开发(Flutter)、java基础与原理,自定义view、NDK、架构设计、性能优化、完整商业项目开发等)

新技术无法学以致用,很容易被我们遗忘,到最后真的需要使用的时候,又要从头来过(虽然上手会更快)。

我觉得身为技术人,针对新技术应该是持拥抱态度的,入了这一行你就应该知道这是一个活到老学到老的行业,所以面对新技术,不要抵触,拥抱变化就好了。

Flutter 明显是一种全新的技术,而对于这个新技术在发布之初,花一个月的时间学习它,成本确实过高。但是周末花一天时间体验一下它的开发流程,了解一下它的优缺点、能干什么或者不能干什么。这个时间,并不是我们不能接受的。

如果有时间,其实通读一遍 Flutter 的文档,是最全面的一次对 Flutter 的了解过程。但是如果我们只有 8 小时的时间,我希望能关注一些最值得关注的点。

Android学习PDF+架构视频+面试文档+源码笔记

(跨平台开发(Flutter)、java基础与原理,自定义view、NDK、架构设计、性能优化、完整商业项目开发等)

[外链图片转存中…(img-TXbiOJdo-1646230849745)]

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值