4

Flutter开发个人经验收集整理

 2 years ago
source link: https://www.pkslow.com/archives/flutter-development
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

无聊学一下Flutter开发,过程中还是遇到许多问题的,在这里权当整理一下,方便以后查收吧。

网络请求库dio

经过比较,选择这个不错的请求库dio - GitHub

使用示例如下:

import 'package:dio/dio.dart';
import 'package:pkslow_formula/domain/blog.dart';

void main() {
  var dio = Dio();
  dio
      .get('https://inshortsapi.vercel.app/news?category=world')
      .asStream()
      .map((event) => event.data)
      .map((event) => event['data'])
      .map((event) => event[0])
      .map((event) => Blog.fromMap(event))
      .forEach((element) {
    print(element.toString());
  });

}
class Blog {
  String author;
  String content;
  String imageUrl;
  String readMoreUrl;
  String url;
  String title;

  Blog(this.author, this.content, this.imageUrl, this.readMoreUrl, this.url,
      this.title);


  @override
  String toString() {
    return 'Blog{author: $author, content: $content, imageUrl: $imageUrl, readMoreUrl: $readMoreUrl, url: $url, title: $title}';
  }

  factory Blog.fromMap(Map<String, dynamic> map) {
    return Blog(map['author'], map['content'], map['imageUrl'], map['readMoreUrl'], map['url'], map['title']);

  }
}

Web模式下访问Network Image报错

当无法在Web模式下访问Image.network时,通过添加启动参数--web-renderer html

References:Stackoverflow

启动ios模式器报错cocoapods not installed

用以下命令安装即可:

brew reinstall cocoapods

Reference

无法在IDEA上找到ios设备

执行以下命令:

sudo xcode-select --switch /Applications/Xcode.app/Contents/Developer

如果还不行就重启一下IDEA。

Reference

ListView

ListView Class in Flutter

Flutter ListView and ScrollPhysics: A Detailed Look

Fetching Data in Flutter and Displaying in ListView

Latex

LaTeX在线公式编辑式 LaTex live

Latex Live帮助文档

Flutter中使用Latex

LaTeX公式手册 全网最全

Web需要在index.html添加依赖,参考:https://github.com/shah-xad/flutter_tex/tree/master/example/web

ios也要添加配置,同样参考上面的例子即可。

awesome-flutter

Flutter实战 第二版


Code for all: GitHub

欢迎关注微信公众号<南瓜慢说>,将持续为你更新...

Recommendations:
Cloud Native
Terraform
Container: Docker/Kubernetes
Spring Boot / Spring Cloud
Https
如何制定切实可行的计划并好好执行


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK