Flutter学习笔记3_网络

1:dio网络请求
采坑:dio.opeions.contenTepy
2: json解析
dio json解析
https://www.jianshu.com/p/51eb9dd8ca0c
https://www.jianshu.com/p/e010041f0ec0
https://caijinglong.github.io/json2dart/index_ch.html

https://blog.csdn.net/u014205247/article/details/80652350
3: SP保存

 _saveUser(Data data) async {
  SharedPreferences prefs = await SharedPreferences.getInstance();
  prefs.setString("userName", data.name);
  prefs.setString("token", data.token);
  prefs.setString("id", data.user_id);
}

4: TOAST
5: AppBar
6: TabBar{TabController TabBarView}
7: widget 的可见不可见 Offstage ( offstage)
8: 下划线 Divider
9: TextFile 去掉下划线

decoration: InputDecoration(
            border: InputBorder.none,
            contentPadding: EdgeInsets.fromLTRB(20, 10, 10, 10),
            labelText: mHint,
                    ),

10: appbar title 居中

 appBar: AppBar(
        leading: BackButton(),
        title: Text("忘记密码"),
        centerTitle: true,//title居中
    ),

11:关掉debug图标

    MaterialApp
      debugShowCheckedModeBanner= false

12 卡package get的时候可以
Windows

新增两个环境变量即可
PUB_HOSTED_URL ===== https://pub.flutter-io.cn
FLUTTER_STORAGE_BASE_URL ===== https://storage.flutter-io.cn

执行一下 flutter doctor命令
下载在 package get 应该就没有问题了。

13: TextField 带边框的

         TextField(
          style: hintTips,
          controller: controllerPassWord,
          decoration: new InputDecoration(
            filled: true,
            labelText: '请输入密码',
            border: new OutlineInputBorder(
                borderRadius:
                    const BorderRadius.all(const Radius.circular(6.0))),
          ),
          obscureText: true,
        ),

14:Toast
https://pub.dartlang.org/packages/fluttertoast#-readme-tab-

15:token验证 请求头
dio
16:圆角控件-带占位图的圆角图片

  child: CircleAvatar(
          backgroundImage: _getUserIcon(),
          )),

ImageProvider _getUserIcon() {
if (userInfo == null) {
  return new AssetImage("images/user_icon_default.png");
} else {
  return new NetworkImage(userInfo.data.portrait);
}
}

17 传参的路由

    Navigator.of(context).push(
    new MaterialPageRoute(builder: (context)=> new Main(user)));
    });

18 带缓存的image
https://pub.dartlang.org/packages/cached_network_image

你可能感兴趣的:(Flutter学习笔记3_网络)