builder: (BuildContext context, AsyncSnapshot snapshot) { switch (snapshot.connectionState) { case ConnectionState.none: return Text(‘Press button to start.’); case ConnectionState.active: case ConnectionState.waiting: return Text(‘Awaiting result…’); case ConnectionState.done: if (snapshot.hasError) return Text(‘Error: ${snapshot.error}’); return Text(‘Result: ${snapshot.data}’); } return null; // unreachable }, )

3.实现思路,布局方式

网络请求:利用Dio库来请求玩Android的知识体系列表,api:www.wanandroid.com/tree/json 序列化json:利用json_serializable来解析返回的json数据 布局:加载过程显示CircularProgressIndicator,加载完成把数据显示到ListView中, 加载为空或者加载出错的话,显示相应的提示页面,并可以进行重试请求 一般。我们的列表页面都是有下拉刷新的功能,所以这里就用RefreshIndicator来实现。

4.代码实现

import ‘package:flutter/material.dart’; import ‘package:dio/dio.dart’; import ‘entity.dart’;

void main() => runApp(MyApp());

class MyApp extends StatelessWidget { // This widget is the root of your application. @override Widget build(BuildContext context) { return MaterialApp( title: ‘Flutter Demo’, theme: ThemeData( // This is the theme of your application. // // Try running your application with “flutter run”. You’ll see the // application has a blue toolbar. Then, without quitting the app, try // changing the primarySwatch below to Colors.green and then invoke // “hot reload” (press “r” in the console where you ran “flutter run”, // or simply save your changes to “hot reload” in a Flutter IDE). // Notice that the counter didn’t reset back to zero; the application // is not restarted. primarySwatch: Colors.blue, ), home: FutureBuilderPage(), ); } }

class FutureBuilderPage extends StatefulWidget { @override _FutureBuilderPageState createState() => _FutureBuilderPageState(); }

class _FutureBuilderPageState extends State { Future future;

@override void initState() { // TODO: implement initState super.initState(); future = getdata(); }

@override Widget build(BuildContext context) { return new Scaffold( appBar: new AppBar( title: new Text(“知识体系”), actions: [ new IconButton( icon: Icon( Icons.search, color: Colors.white, ), onPressed: null) ], ), body: buildFutureBuilder(), floatingActionButton: new FloatingActionButton(onPressed: () { setState(() { //测试futurebuilder是否进行没必要的重绘操作 }); }), ); }

FutureBuilder buildFutureBuilder() { return new FutureBuilder( builder: (context, AsyncSnapshot async) { //在这里根据快照的状态,返回相应的widget if (async.connectionState == ConnectionState.active || async.connectionState == ConnectionState.waiting) { return new Center( child: new CircularProgressIndicator(), ); } if (async.connectionState == ConnectionState.done) { debugPrint(“done”); if (async.hasError) { return new Center( child: new Text(“ERROR”), ); } else if (async.hasData) { List list = async.data; return new RefreshIndicator( child: buildListView(context, list), onRefresh: refresh); } } }, future: future, ); }

buildListView(BuildContext context, List list) { return new ListView.builder( itemBuilder: (context, index) { Data bean = list[index]; StringBuffer str = new StringBuffer(); for (Children children in bean.children) { str.write(children.name + " "); } return new ListTile( title: new Text(bean.name), subtitle: new Text(str.toString()), trailing: new IconButton( icon: new Icon( Icons.navigate_next, color: Colors.grey, ), onPressed: () {}), ); }, 自我介绍一下,小编13年上海交大毕业,曾经在小公司待过,也去过华为、OPPO等大厂,18年进入阿里一直到现在。

深知大多数初中级Android工程师,想要提升技能,往往是自己摸索成长或者是报班学习,但对于培训机构动则近万的学费,着实压力不小。自己不成体系的自学效果低效又漫长,而且极易碰到天花板技术停滞不前!

因此收集整理了一份《2024年Android移动开发全套学习资料》,初衷也很简单,就是希望能够帮助到想自学提升又不知道该从何学起的朋友,同时减轻大家的负担。

既有适合小白学习的零基础资料,也有适合3年以上经验的小伙伴深入学习提升的进阶课程,基本涵盖了95%以上Android开发知识点,真正体系化!

由于文件比较大,这里只是将部分目录截图出来,每个节点里面都包含大厂面经、学习笔记、源码讲义、实战项目、讲解视频,并且会持续更新!

如果你觉得这些内容对你有帮助,可以扫码获取!!(备注:Android)

关于面试的充分准备

一些基础知识和理论肯定是要背的,要理解的背,用自己的语言总结一下背下来。

虽然 Android 没有前几年火热了,已经过去了会四大组件就能找到高薪职位的时代了。这只能说明 Android 中级以下的岗位饱和了,现在高级工程师还是比较缺少的,我能明显感觉到国庆后多了很多高级职位,所以努力让自己成为高级工程师才是最重要的。

好了,希望对大家有所帮助。

接下来是整理的一些Android学习资料,有兴趣的朋友们可以关注下我免费领取方式。

①Android开发核心知识点笔记

②对标“阿里 P7” 40W+年薪企业资深架构师成长学习路线图

③面试精品集锦汇总

④全套体系化高级架构视频

**Android精讲视频领取学习后更加是如虎添翼!**进军BATJ大厂等(备战)!现在都说互联网寒冬,其实无非就是你上错了车,且穿的少(技能),要是你上对车,自身技术能力够强,公司换掉的代价大,怎么可能会被裁掉,都是淘汰末端的业务Curd而已!现如今市场上初级程序员泛滥,这套教程针对Android开发工程师1-6年的人员、正处于瓶颈期,想要年后突破自己涨薪的,进阶Android中高级、架构师对你更是如鱼得水!

《互联网大厂面试真题解析、进阶开发核心学习笔记、全套讲解视频、实战项目源码讲义》点击传送门即可获取!

涨薪的,进阶Android中高级、架构师对你更是如鱼得水!

[外链图片转存中…(img-IMjGiodv-1712619847452)]

《互联网大厂面试真题解析、进阶开发核心学习笔记、全套讲解视频、实战项目源码讲义》点击传送门即可获取!

精彩链接

评论可见,请评论后查看内容,谢谢!!!
 您阅读本篇文章共花了: