flutter学习碰到的坑

macOS上配置教程

坑:

1.将Flutter代码的bin目录加入到系统环境变量中

打开bash_profile文件时需要用命令行打开,如果是用鼠标打开,那么配置会不生效

open .bash_profile

2.flutter doctor一直提示以下错误

✗ **libimobiledevice and ideviceinstaller are not installed. To install, run:
    brew install --HEAD libimobiledevice
    brew install ideviceinstaller**

解决方案

3.Error fetching https://gems.ruby-china.org/: bad response Not Found 404 报错解决办法

服务域名发生了变化,将org替换为com

3.FutureBuilder作为根widget会crash

  @override
  Widget build(BuildContext context) {
    return FutureBuilder(
          future: fetchPosts(),
          builder: _buildFuture,
    );
  }

  在写一个获取网络数据然后选肉listview的功能时,一直报这个错
  'package:flutter/src/painting/basic_types.dart': Failed assertion: line 222 pos 10: 'textDirection

改成下面这种就OK了,原因还没搞清楚,搞清楚再补充

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        body: FutureBuilder(
          future: fetchPosts(),
          builder: _buildFuture,
        ),
      ),
    );
  }

你可能感兴趣的:(flutter学习碰到的坑)