1.命令行运行flutter run之后iOS报错:
Could not install build/ios/iphones/Runner.app on XXXXX. try lunching Xcode and
selecting "Project > Run" to fix the problem open ios/Runner.xworkspace.......

这个恶心的报错,我一直以为是我Xcode的问题,因为早上一直好的,代码未动.而下午什么都没做,就是Xcode升级了下.然后就不行了.可以使用Xcode直接运行.但是命令行不行.最后发现我手机在充电,于是拔了,然后再命令行运行flutter run之后,好了!!!fuck.这报错信息也忒能了....

2.今天在学Flutter时,写一个基本的push功能时,发现代码无误,但是报个错'package: XXXX:error:Unexpected tag 128(SepecialiedVariableGet) in ?,expected a procedure,a constructor or a function node',发现在test文件夹里面有个错误,修改好之后,再次r,还是不行.没办法只能重新R.再次重新运行就好了.和当时视频中有这点区别.记录一下.

3.开发中,有时候在flutter packeages get 或者 flutter create XXX等过程中,程序中断,再次打开时,会出现Waiting for another flutter command to relsease the startup lock...

此时打开 flutter的sdk安装目录,关闭ide, 删除文件 bin/cache/lockfile即可.如下:

 4.升级Flutter时,出现:Error: Unable to 'pub upgrade' flutter tool. Retrying in five seconds... (9 tries left)

 

重现: 在flutter1.0升级flutter1.2时,中途卡住.听网友的中断再升级,运行 flutter upgrade 之后就报这错误了.

解决: 删除 flutter SDK中 bin/cache 文件夹 再 flutter upgrade就好了

5.升级flutter后,之前好的项目就不行了.这时重新 flutter packages get 获取下三方库.然后再运行就好了. why???

6.在 flutter packages get时,pub get failed:

我的原因是:版本号前面未加一个空格.

 7.最近上传代码到github老是报错,Failed to connect to 127.0.0.1 port 1080: Connection refused .....
不管FQ与否,蓝☺灯不行,ss不行,Cla☺shX不行,V☺2☺ra☺yU也不行,还整天封端口fuck....按照网上的取消git代理也不行(git config --global --unset http.proxy)
实在烦得很,直接去gitconfig删除字段!!!

第一步

在终端输入

defaults write com.apple.finder AppleShowAllFiles -boolean true ; killall Finder

这行命令可以显示电脑的隐形文件

第二步

在Finder里面个人账号的文件夹里找到gitconfig这个隐藏文件,右击打开,然后把里面的代理proxy整行删掉

8.最近在写一个Flutter项目时,发现点击跳转详情页面,底部tabbar竟然还在?!这什么鬼,出现这个情况记得3年前写iOS原生代码出现过,但那个可以配置.两年前写RN也出现过,那个只是加载顺序问题,现在写Flutter又是什么毛病,其实只是我复制代码忘记删除MaterialApp....了.一个工程只能有一个MaterialApp.不过这个bug也让我知道了一个偏方,flutter怎么写push之后还有tabbar的效果....呵呵,年纪大了,就越会安慰自己.

9.出现类似 The argument type '_BottomContainerState' can't be assigned to the parameter type 'TickerProvider'.dart(argument_type_not_assignable)

如:

这是需要混入 with SingleTickerProviderStateMixin即可.

10. children 直接遍历返回一个数组Widget: 

如:

  // 视频标签
  Widget videoTag() {
    return Container(
      child: Wrap(
          spacing: 8.0, // 主轴(水平)方向间距
          runSpacing: 4.0, // 纵轴(垂直)方向间距
          children: tag()),
    );
  }

  List<Widget> tag() {
    List<Widget> list = [];
    infoData['videoTag'].forEach((val) {
      list.add(
        ClipRRect(
          borderRadius: BorderRadius.circular(100.0),
          child: Container(
            padding: EdgeInsets.symmetric(vertical: 5.0, horizontal: 15.0),
            color: Colors.black26,
            child: Text(val),
          ),
        ),
      );
    });
    return list;
  }

  

项目

 10.运行出现 

ideviceinfo returned an error:

ERROR: Could not connect to lockdownd, error code -8

连接着外接设备.移除即可

 11.add widget时,出现the method 'add' was called on null.Receiver: null.

我的错误是数组忘记初始化......

 

 11. Cannot provide both a color and adecoration.the color argument is just a shortthand for "decoration:new BoxDecoration(color: color)".

顾名思义, 意思就是这俩不能一起使用. 需要把color写入BoxDecoration里面.

 

 12.在json转model的各种工具上报格式错误........

平时使用vscode撸.使用https://javiercbk.github.io/json_to_dart/ 在线转换比较多,但是格式错误不提示...

   所以,都是先使用格式化工具格式(http://www.bejson.com/)  格式正确了在转.

   常见的错误有: 

a.

b.

 13.在拉取新库时,长时间拉取不了来.可以试试git的方式.

dependencies:
 fluro:
   git: git://github.com/theyakka/fluro.git

14.出现类似

flutter: The following assertion was thrown building SimpleDialogDemo(dirty, dependencies:

flutter: [_LocalizationsScope-[GlobalKey#61da8], _InheritedTheme], state: _SimpleDialogDemoState#4de71):

flutter: setState() or markNeedsBuild() called during build.

flutter: This Overlay widget cannot be marked as needing to build because the framework is already in the

......
如图:

错误只是在调用方法时,多写了一个()导致........果然996太久脑子容易死机.算了,记录一下.该休息一下了.

 

15.flutter的尺寸单位是dp.不是px 

16.放置2X,3X图片.

如:根目录下有images文件夹,里面有2.0x文件夹,3.0x文件夹.在images下存放1X图:xxx.png,然后在2.0x文件夹和3.0x文件夹里面也放置相应文件即可.
在pubspec.yaml直接引入 -images/xxx.png即可,flutter本身就自动识别使用2X,3X.

 

17.Android端出现:Android dependncy 'android.core:core' has different version for the compile (1.0.0) and runtime (1.0.1) classpath.You should manually set the same version.

我的解决办法是:

先在项目根目录下的build.gradle下把

classpath 'com.android.tools.build:gradle:3.2.1'

 改为

classpath 'com.android.tools.build:gradle:3.3.1'

然后删除
ext.kotlin_version = '1.3.31'

在grable.properties 下添加

android.useAndroidX=true
android.enableJetifier=true

之后sync 即可.

记得要FQ

文件如图所示:

 

 

 

 

其他方案: https://github.com/flutter/flutter/issues/27254 

 18.分别在iOS平台和Android平台各自添加启动图之后,启动会发生 启动图 --> 黑屏 --> 界面.

   试了好多方法均无效,最后试了下把debug改为release,好了.......艹,学艺不精就是坑

19.图片注册只需要注册到文件夹即可,不用注册到图片.如:

 20. android 模拟器出现 

Package install error: Failure [INSTALL_FAILED_INSUFFICIENT_STORAGE]
Error launching application on Android SDK built for x86.

最简单的方法就是删除几个模拟器上的app即可.

21.突然之间,Android模拟器死了.启动起来,点了点不动.flutter run -d all只有iOS起来,Android好像死了一样啥也不动,终端也不输出错误.....
之前是重新关闭,再重启模拟器就好了,最近重启模拟器也没有用,重启mac也是一样没反应.  无奈只能卸载,重新安装一个新的模拟器就好了...

22.使用输入框时,在对输入框长按操作,iOS报红,Android好的,这个恶心的问题是官方的bug,缺少对中文的支持.

我的解决办法是:

项目中添加下面这个dart文件.

common_localizations_delegate.dart

import 'package:flutter/cupertino.dart';
import 'package:flutter/foundation.dart';

///语言(主要解决cupertino控件不能显示中文的问题)
class CommonLocalizationsDelegate
    extends LocalizationsDelegate<CupertinoLocalizations> {
  const CommonLocalizationsDelegate();

  @override
  bool isSupported(Locale locale) =>
      <String>['zh', 'CN'].contains(locale.languageCode);

  @override
  SynchronousFuture<_DefaultCupertinoLocalizations> load(Locale locale) {
    return SynchronousFuture<_DefaultCupertinoLocalizations>(
        _DefaultCupertinoLocalizations(locale.languageCode));
  }

  @override
  bool shouldReload(CommonLocalizationsDelegate old) => false;
}

class _DefaultCupertinoLocalizations extends CupertinoLocalizations {
  _DefaultCupertinoLocalizations(this._languageCode)
      : assert(_languageCode != null);
  final String _languageCode;

  static const List<String> _shortWeekdays = <String>[
    '周一',
    '周二',
    '周三',
    '周四',
    '周五',
    '周六',
    '周日',
  ];

  static const List<String> _shortMonths = <String>[
    '一月',
    '二月',
    '三月',
    '四月',
    '五月',
    '六月',
    '七月',
    '八月',
    '九月',
    '十月',
    '十一月',
    '十二月',
  ];

  static const List<String> _months = <String>[
    '一月',
    '二月',
    '三月',
    '四月',
    '五月',
    '六月',
    '七月',
    '八月',
    '九月',
    '十月',
    '十一月',
    '十二月',
  ];

  @override
  String get alertDialogLabel => '提醒';

  @override
  String get anteMeridiemAbbreviation => "上午";

  @override
  String get postMeridiemAbbreviation => "下午";

  @override
  String get copyButtonLabel => "复制";

  @override
  String get cutButtonLabel => "剪切";

  @override
  String get pasteButtonLabel => "粘贴";

  @override
  String get selectAllButtonLabel => "全选";

  @override
  DatePickerDateOrder get datePickerDateOrder => DatePickerDateOrder.ymd;

  @override
  DatePickerDateTimeOrder get datePickerDateTimeOrder =>
      DatePickerDateTimeOrder.date_time_dayPeriod;

  @override
  String datePickerDayOfMonth(int dayIndex) => dayIndex.toString();

  @override
  String datePickerHour(int hour) => hour.toString();

  @override
  String datePickerHourSemanticsLabel(int hour) => hour.toString();

  @override
  String datePickerMediumDate(DateTime date) {
    return '${_shortWeekdays[date.weekday - DateTime.monday]} '
        '${_shortMonths[date.month - DateTime.january]} '
        '${date.day.toString().padRight(2)}';
  }

  @override
  String datePickerMinute(int minute) => minute.toString().padLeft(2, '0');

  @override
  String datePickerMinuteSemanticsLabel(int minute) {
    if (minute == 1) return '1 分钟';
    return minute.toString() + ' 分钟';
  }

  @override
  String datePickerMonth(int monthIndex) => _months[monthIndex - 1];

  @override
  String datePickerYear(int yearIndex) => yearIndex.toString();

  @override
  String timerPickerHour(int hour) => hour.toString();

  @override
  String timerPickerHourLabel(int hour) => '时';

  @override
  String timerPickerMinute(int minute) => minute.toString();

  @override
  String timerPickerMinuteLabel(int minute) => '分';

  @override
  String timerPickerSecond(int second) => second.toString();

  @override
  String timerPickerSecondLabel(int second) => '秒';

  @override
  // TODO: implement todayLabel
  String get todayLabel => "今天";
}

  然后,在main.dart文件中添加

主要是 添加 CommonLocalizationsDelegate(),

 其余代码是原来配置国际化的代码.
23.出现setState() or markNeedsBuild() called during build.This XXX widget cannot be marked as needing to build because the framework is already in the process of building widgets.A widget can be marked as needing to be build during the ........

我是在输入的时候操作setState导致的,需要加一个延时即可.如:

 24.之前使用vscode撸,最近卡到飞起来,比as,xcode还卡...换回as开发,但是反括号不显示了.....

如图所示,修改一下就好了

 25.https://github.com/GigaDroid/flutter_udid 的使用: 项目中需要使用到UDID,网上找了个库,但是该库完全没有使用说明.....
该库需要iOS集成SAMKeychain. 我通过pod集成了.之后会报错:

The following Swift pods cannot yet be integrated as static libraries:

The Swift pod `flutter_udid` depends upon `SAMKeychain`, which do not define modules. To opt into those targets generating module maps (which is necessary to import them from Swift when building as static libraries), you may set `use_modular_headers!` globally in your Podfile, or specify `:modular_headers => true` for particular dependencies.

这个错误需要在Podfile中,

添加  use_frameworks!

然后终端会显示版本警告,要求使用8.0.

添加 platform :ios, '8.0'

最后又会报swift version版本问题,我的是Xcode10.1(swift是4.2.1)

 

 

The target “flutter_udid” contains source code developed with Swift 2.x. This version of Xcode does not support building or migrating Swift 2.x targets.

 

 Use Xcode 8.x to migrate the code to Swift 3.

我根据我的Xcode版本添加了

config.build_settings['SWIFT_VERSION'] = '4.2.1' # added this

 

之前的终于好了.  但是又会出现一个问题.问题是啥忘了.只记得解决办法是听朋友的执行 pod update.之后好了.

贴一下podfile吧

# Uncomment this line to define a global platform for your project
 platform :ios, '8.0'

# CocoaPods analytics sends network stats synchronously affecting flutter build latency.
ENV['COCOAPODS_DISABLE_STATS'] = 'true'

project 'Runner', {
  'Debug' => :debug,
  'Profile' => :release,
  'Release' => :release,
}

def parse_KV_file(file, separator='=')
  file_abs_path = File.expand_path(file)
  if !File.exists? file_abs_path
    return [];
  end
  pods_ary = []
  skip_line_start_symbols = ["#", "/"]
  File.foreach(file_abs_path) { |line|
      next if skip_line_start_symbols.any? { |symbol| line =~ /^\s*#{symbol}/ }
      plugin = line.split(pattern=separator)
      if plugin.length == 2
        podname = plugin[0].strip()
        path = plugin[1].strip()
        podpath = File.expand_path("#{path}", file_abs_path)
        pods_ary.push({:name => podname, :path => podpath});
      else
        puts "Invalid plugin specification: #{line}"
      end
  }
  return pods_ary
end

target 'Runner' do
  use_frameworks!
  # Prepare symlinks folder. We use symlinks to avoid having Podfile.lock
  # referring to absolute paths on developers' machines.
  system('rm -rf .symlinks')
  system('mkdir -p .symlinks/plugins')

  # Flutter Pods
  generated_xcode_build_settings = parse_KV_file('./Flutter/Generated.xcconfig')
  if generated_xcode_build_settings.empty?
    puts "Generated.xcconfig must exist. If you're running pod install manually, make sure flutter packages get is executed first."
  end
  generated_xcode_build_settings.map { |p|
    if p[:name] == 'FLUTTER_FRAMEWORK_DIR'
      symlink = File.join('.symlinks', 'flutter')
      File.symlink(File.dirname(p[:path]), symlink)
      pod 'Flutter', :path => File.join(symlink, File.basename(p[:path]))
    end
  }
  pod 'SAMKeychain'

  # Plugin Pods
  plugin_pods = parse_KV_file('../.flutter-plugins')
  plugin_pods.map { |p|
    symlink = File.join('.symlinks', 'plugins', p[:name])
    File.symlink(p[:path], symlink)
    pod p[:name], :path => File.join(symlink, 'ios')
  }
end

post_install do |installer|
  installer.pods_project.targets.each do |target|
    target.build_configurations.each do |config|
      config.build_settings['ENABLE_BITCODE'] = 'NO'
      config.build_settings['SWIFT_VERSION'] = '4.2.1' # added this
    end
  end
end

 26.flutter: Another exception was thrown: setState() or markNeedsBuild() called during build.

我的解决方案是把setState稍微延迟一下子

Future.delayed(Duration(milliseconds: 200)).then((e) {
  setState(() {
    ...
  });
});

 27.iOS真机出现Could not launch engine with configuration

解决方案是 :    https://github.com/flutter/flutter/issues/21221

虽然感觉有点不对门,但是总之解决了就行.......

28.XXXXX is a SingleTickerProviderStateMixin but multiple tickers were created.

原因是多个地方调用setState请求重绘,但是state使用的是SingleTickerProviderStateMixin ,将其改成TickerProviderStateMixin即可。

 29.使用fluro管理路由时,在传输参数时出现传输特殊字符,会被自动截取.就像下面传输+12345过去,那边只能收到12345......

这个时候需要被传输的数据进行特殊处理,编码一下就可以

 30.

Error on line 52, column 4 of pubspec.yaml: Expected a key while parsing a block mapping.

 │ assets:
│ ^

 

这个问题就是一个智障问题了: 

assets前面多了个空格,去除就好....
31. Text的换行属性 :softWrap: true
在其他组件中,使用Text需要换行,其外面最好加一个Expanded

 

 32.想要在Column中使用ListView.

如果想要在Column中使用ListView.需要对ListView的外面包裹一层:Expanded
如:

Column(
     children: <Widget>[
        Text('3456789'),
        Expanded(
            child: ListView(
                children: <Widget>[ ],
         ),
     ),    
  ]
)

 33.返回 Future<bool>:

需要使用 Future.value(false); 如

 /*
   * Android 物理键返回 
   */
  Future<bool> _showToast() {
    if (_lastPressedAt == null ||
        DateTime.now().difference(_lastPressedAt) > Duration(seconds: 1)) {
      //两次点击间隔超过1秒则重新计时
      _lastPressedAt = DateTime.now();
      Fluttertoast.showToast(
        msg: "连续双击退出APP",
        toastLength: Toast.LENGTH_LONG,
      );
      return Future.value(false);
    }
    return Future.value(true);
  }

 34.设置Drawer的宽度.

直接在Drawer的外面包裹一层Container.然后设置Container的宽度即可.:


 

 35.使用Flutter自带的CircularProgressIndicator 绘制圆环进度时.出现一瞬间的错误UI.原因很小学知识.因为我的进度是两数相除所得.默认都是0.除数不能为0!!!!!!!!!!!! 

 

 36.网络请求有时放在 initState 太早了. 会发生异常:

如我的这个,需要先获取两个本地化的值,然后才能请求网络,但是常常太晚了.于是awiat 取值,网络请求. 不行!如警告所说放在 didChangeDependencies 里面.同时对所有需要等待的程序awiat即可.

 

 

 37.之前在上传TestFlight的时候,下载之后打开app发现黑屏了...

有时Xcode还输出: Failed to find snapshot: XXXX  Engline run configyation was inavalid.  Could not launch engine with configuration.

 

 

 

 

找了下,这样可以解决:

 

 38.Android添加启动页并全屏.

 39.AS之前取消了版本更新,现在需要更新下.但是检测不到版本.

如下所示,点击1处.删除其中的版本信息.然后点击2处即可.

 40. 手机只能竖屏.

 

 

import 'package:flutter/services.dart';
 
 // 强制只能竖屏
  SystemChrome.setPreferredOrientations(
      [DeviceOrientation.portraitUp, DeviceOrientation.portraitDown]);

41. A类 想要调用B类的方法:

import 'package:flutter/material.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(
        primarySwatch: Colors.blue,
      ),
      home: MyHomePage(),
    );
  }
}

class MyHomePage extends StatefulWidget {
  @override
  _MyHomePageState createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text('调用其他类的方法'),
      ),
      body: FlatButton(
        child: Text('调用其他类的方法'),
        onPressed: _btnAction,
      ),
    );
  }

  _btnAction() {
    Two two = Two();
    two.twoAction();

    Three three = Three();
    three.createState().threeAction();
  }
}

class Two extends StatelessWidget {
  twoAction() {
    print('twoActiontwoActiontwoAction');
  }

  @override
  Widget build(BuildContext context) {
    return Container();
  }
}

class Three extends StatefulWidget {
  @override
  _ThreeState createState() => _ThreeState();
}

class _ThreeState extends State<Three> {
  threeAction() {
    print('threeActionthreeActionthreeActionthreeAction');
  }

  @override
  Widget build(BuildContext context) {
    return Container();
  }
}

  

42.进入一家新公司,拉取代码后模拟器好的.真机会出现: 'ios/Runner/Runner.entitlements' could not be opened. Verify the value of the CODE_SIGN_ENTITLEMETS build setting for target 'RUNNER' and build configuration "Debug" is correct and that the file exists on the disk.(in taget 'Runner')

 

 

 我的问题是没有打开推送通知的开关.

 

43.上传app store或者Test Flight时.一直不显示版本包,出现: TMS-90338: Non-public API usage -The app references non-public symbols in Frameworks/Flutter.framework/Flutter: _ptrace 的邮件信息.

 

 

 

解决方案:  https://github.com/flutter/flutter/issues/37850   
               https://blog.csdn.net/xudailong_blog/article/details/101268214
 44.android 的AS 出现 Add Configuration....
我出现这个问题是因为导入一个库,但是这个库是用不了,我再次去除时,AS就变这样了.....尴尬.搞了一下午.最后发现只需要修改一下版本就好了,

 解决方案如下:

 https://blog.csdn.net/qq_36488374/article/details/80563633

 

45.卸载cocoapods之后再重新安装,运行pod setup无效,但是pod --version可以看到版本.flutter doctor报cocoapods压根不存在.pod install让我pod setup.pod setup又无效.....恶心死了.....百度一下午没有...老大说用谷00歌.答案一下子就出来了===> https://github.com/CocoaPods/CocoaPods/issues/9184
马丹.百度真恶心.政策真恶心.


46.iOS启动报错:VM snapshot invalid and could not be inferred form settings等字样

 

 解决方案是修改Edit Scheme...为release. 参考如下链接

https://github.com/flutter/flutter/issues/24641

47.跳转界面传值出现 :

flutter: The following ArgumentError was thrown while handling a gesture:

flutter: Invalid argument(s): Illegal percent encoding in URI

 

 原因是传的值不能包含中文. 需要转一下码:  Uri.encodeComponent("汉字")

 

 48.flutter build ios 出现 Using 'ARCHS' setting to build architectures of target 'Pods-Runner':('')

 

 

 

 看图识字,修改一下 iOS目录下的Podfile文件.添加一行 platform :ios, '9.0'

 

 即可.

 49. android打包出现 Could not resolve com.tencent.mm.opensdk:wechat-sdk-android-without-mta:+.

 

 解决方案:翻 00墙00
恶心00的00墙.恶00心的土 00匪

50.使用了Flutter json_serializable这个插件运行flutter packages pub run build_runner build:出现pub finished with exit code 78.

 

解决办法:运行 flutter packages pub run build_runner build --delete-conflicting-outputs  即可.

51. iOS在上传App Store时,出现GeoJSON无效:您的路由App覆盖地区文件失效......

 

 

 

 

原因: 图片文件或者路径包含了中文字符.修改即可.

 

52. iOS 打包在Archive的时候出现 could not find an option named "track-widget-creation"

 

 

 解决办法:  在Archive之前先执行 

flutter build ios --release

 参考: https://github.com/flutter/flutter/issues/26279

 

 53. Android真机出现NoSuchMethodError: The method 'tabLabel' was called on null.Receiver null Tried calling: tabLabel().

如图

 

 或者出现:

 

 

 出现这个问题,我这边是因为代码里面一开始使用了国际化,配置了

 

supportedLocales: [
//此处
const Locale('zh', 'CH'),
const Locale('en', 'US'),
],

后来没用国际化了.这个代码我就懒得删除......就是这个玩意造成的.iOS可以,Android就不行.  删除这个就好了...恶心我半个小时

 

54. 最近换电脑,一样的代码,一样的开发环境,但是新电脑就是运行不起来。旧电脑键盘还废了。。。。草

出现 

Using `ARCHS` setting to build architectures of target `Pods-Sample`: (``) 

同时 pod install也也不行,原因一样。。

1、看来是pod的问题,于是升级到最新1.8.4 不行,降级1.8.3不行。还是必须降级到1.7.5 。好了

又过了一年又出来了这个问题。

https://www.cnblogs.com/2yue/p/ruby_change_gem.html

 

1、去掉gem设置的源,恢复原本sources。

再执行

gem cleanup
brew uninstall cocoapods
sudo gem uninstall cocoapods
sudo gem install cocoapods -n /usr/local/bin
sudo gem install cocoapods-user-defined-build-types
pod install --repo-update

该死的墙

55. Android报 A proglem occured configuring root project 'android'

 

 

 

搞了好久。最后发现需要翻696墙。。。。。恶心的土匪。建你 妈妈 的 墙

56.在对项目flutter clean出现‘FileSystemException: Delation ,path = 'build' (OS Error: Permission denied,rrror =13)’....

 

 

 解决办法:可以 sudo flutter clean一下。但是感觉不严谨。容易出事。

应该在选中根目录文件夹 右键 显示简介 共享与权限 找到自己的当前账户 点击锁 输入密码解开 点击应用到包含的项目。稍等一下即可。

 57.  在使用 

_pageController.animateToPage(widget.index,
duration: const Duration(milliseconds: 2), curve: Curves.ease);时报错:

══╡ EXCEPTION CAUGHT BY WIDGETS LIBRARY ╞═══════════════════════════════════════════════════════════
flutter: The following assertion was thrown building Builder:
flutter: ScrollController not attached to any scroll views.
flutter: 'package:flutter/src/widgets/scroll_controller.dart':
flutter: Failed assertion: line 110 pos 12: '_positions.isNotEmpty'
flutter:
flutter: Either the assertion indicates an error in the framework itself, or we should provide substantially
flutter: more information in this error message to help you determine and fix the underlying cause.
flutter: In either case, please report this assertion by filing a bug on GitHub:

 

 

 

 其实,只需要延时一下而已,需要先等待界面初始化好再滑动.

 

 58.出现  setState() called after dispose()

 

 顾名思义,在dispose()之后调用了setState().解决办法:

if (mounted) {
          setState(() {
..........
          });
}

  

 59.TextField 需要加个背景色.filled必须为true

 

 60.需要在initstate里面使用context.

比如:需要在initstate方法里面获取到屏幕的高来做一个动画的话,可以像这样:

  @override
  void initState() {
    // TODO: implement initState
    super.initState();
    WidgetsBinding.instance.addPostFrameCallback((_) {
      _controller = new AnimationController(
          duration: const Duration(milliseconds: 300), vsync: this);
      _animation =
          new Tween(begin: 0.0, end: MediaQuery.of(context).size.height)
              .animate(_controller)
                ..addListener(() {
                  setState(() {});
                });
    });

  }

关键点就是使用

 

WidgetsBinding.instance.addPostFrameCallback((_) {
        .....这里可以获取到context
});

  

61.使用Center的注意点:

使用Center会对包裹Center的组件发生类似Expanded 的作用.

62.model的判断

可以直接?判断是否为空,不为空才会取后面的值.比如:

 

 63.在最近几日,flutter build ios时,经常被墙.翻了墙也不行,换手机网络也不行.报错:

error: RPC failed; curl 56 LibreSSL SSL_read: SSL_ERROR_SYSCALL, errno 60

 

 

 

 这个错误,当初在做iOS原生开发遇到过.都是翻下墙就好了.但是现在不行.只能换源了.还必须有两个源才行.一个默认自带的,一个天朝这边的....真是够了...

 如果这样还是不行.可以让终端也走代理设置. (或者Mac下载一个ITerm代替终端使用亦可)

 

 64.在使用fluwx分享时,因为分享有点慢,就加了个loading图,需要同时在微信回调和界面返回时,控制loading的显示与否.回调控制是好的,但是如果用户点击的是系统返回.就不行了.只能借助flutter官方的生命周期监听了.

 但是呢,只有在 AppLifecycleState.resumed 下才能修改state. 如果是其余状态修改的话,分享的剩余状态就会失败了....

 

这里的修改state最好是在外面加一层延时,延时之后再setState,保证万无一失. 

65.界面出现多次请求或者多次渲染情况.比如多次切换Tab,或者一个界面使用了其他封装的图片class.在上下滑动时,出现图片再次渲染现象.或者在写一个列表时,对其中的class小部件也做下保持状态,防止小部件为class的时候,上下滑动时,界面重置. 这个情况需要配置切换tab和混入其他类:AutomaticKeepAliveClientMixin.详见当初学习时写的项目.

 https://github.com/pheromone/flutter_shop
https://github.com/pheromone/flutter_video_audio_news

 66.showModalBottomSheet切圆角

https://blog.csdn.net/cpcpcp123/article/details/97660036

 67.点击空白缩回键盘.类似于原生的取消第一响应者功能.

https://segmentfault.com/a/1190000021314427

https://www.cnblogs.com/LiuPan2016/p/10347423.html

监听键盘弹出/缩回事件:https://segmentfault.com/a/1190000022495736

 

Flutter 解决App登录页面软键盘遮挡住登录按钮或顶起底部控件的问题:

 https://blog.csdn.net/ww897532167/article/details/125633146

68.  点击其他按钮弹出键盘,调起第一响应者.

// Initialise outside the build method
FocusNode nodeOne = FocusNode();
FocusNode nodeTwo = FocusNode();
// Do this inside the build method
TextField(
  focusNode: nodeOne,
),
TextField(
  focusNode: nodeTwo,
),
RaisedButton(
  onPressed: () {
    FocusScope.of(context).requestFocus(nodeTwo);
  },
  child: Text("Next Field"),
),

https://www.jianshu.com/p/f6b994fdb9fb

69.  ios   Undefined symbols for architecture armv7:

https://www.jianshu.com/p/c37831cef020

 

70.最近,代码被搞丢了.于是重新拉取库,build的时候iOS出现: flutter unable to open file (in project "Runner") (in target 'Runner')
 

 

 解决办法: 

1.  cd 根目录

2.  flutter clean

3.  flutter create . 

4.重新打开Xcode.clean即可

https://github.com/flutter/flutter/issues/22886

71.最近,代码被搞丢了.于是重新拉取库,build的时候Android出现:SSL peer shut down incorrectly

https://www.jianshu.com/p/194b57cf7162

 

ps:恶心的某个组织.艹

72. 修改TextField的高度,以及无边框圆角

https://www.cnblogs.com/ChengYing-Freedom/p/10304959.html

73. TextField提示语hintText不居中

 

https://blog.csdn.net/ly410726/article/details/102698351

 74.textField设置圆形边框并且改变边框颜色,如果不修改会显示主题颜色

https://blog.csdn.net/xiaoqi307/article/details/95169874

 75.BottomNavigationBar设置4个BottomNavigationBarItem无效问题

需要加一个  type: BottomNavigationBarType.fixed,

 

 https://www.jianshu.com/p/363b66358de1

76. iOS打包出现: WARNING ITMS-90725:“SDK Version issue”.this app was build the iOS 12.4 SDK.Starting April 2020.all iOS apps submitted to the APP store must be build with the ios 13SDK or later,inclured in Xcode 11 or later

 

 

 

 

 使用AS运行出现 Flutter Device doesn't support wireless sync

 因为我的是Xcode10.3. flutter v1.9.1+hotfix.2 .我这边的方案是: channel master
如果报错说需要git pull, 那就 执行  git pull.之后会升级到最新的master版本.

 

 记得翻个墙墙.避开土匪干扰.  
之后通常就好了.flutter clean 之后再flutter build ios试试看三方库是否需要升级.如果需要它会提示.升级之后就可以正常运行真机和打包了

77.命令flutter build apk  出现  AndroidX incompatibilities may have caused this build to fai
https://www.zhulou.net/post/2366.html

 78.为了适配iOS13+升级了flutter,使用AS运行真机项目会一直卡在 Installing and launching...导致无法调试??????

百度几条,屁都没有,谷歌几条.试了也没啥用....模拟器是好的,真机不行....只能先模拟器测试了
a.https://github.com/flutter/flutter/issues/43570

 

 没用....

b.https://github.com/flutter/flutter/issues/46705
.

 

没用.

c.https://github.com/flutter/flutter/issues/37699
c.

 

 只能热重启,无法看到日志输出.....鸡肋..
  最终,只能升级到最新才行.....ps:一般出现类似的情况,都是重新下载安装sdk即可

79. flutter packages get 之后长时间没有反应(饭墙也一样,AS也一样.到底为何???)
可以在.bash_profile文件中添加

export PUB_HOSTED_URL=https://pub.flutter-io.cn
export FLUTTER_STORAGE_BASE_URL=https://storage.flutter-io.cn

然后 

source ~/.bash_profile

然后打开饭墙,直接运行 flutter packages get 拉取

白天可以了.但是晚上还是会慢 

  80. ios 在pod install 时出现 [!] CDN: trunk Repo update failed - 12 error(s):

 

 a.在 Podfile文件中写入  source 'https://github.com/CocoaPods/Specs.git'

 

b.然后终端运行 pod repo remove trunk 即可

81.pod install出现 RPC failed; curl 56 LibreSSL SSL_read: SSL_ERROR_SYSCALL, errno 54

https://www.jianshu.com/p/dd996cdcc3f7

82.当在使用camera库自绘相机界面时,如果直接写取景框,会发现物体会拉伸变形。需要

Transform.scale处理下: 

 

 

 

https://stackoverflow.com/questions/49946153/flutter-camera-appears-stretched

如:


double rpx = MediaQuery.of(context).size.width / 750;
final size = MediaQuery.of(context).size;
final deviceRatio = size.width / size.height;
return Scaffold(
body: Stack(
children: <Widget>[
// 相机取景view
// CameraPreview(_cameraControlle), 取景框会出现变形。采用下面
Transform.scale(
scale: _cameraControlle.value.aspectRatio / deviceRatio,
child: Center(
child: AspectRatio(
aspectRatio: _cameraControlle.value.aspectRatio,
child: CameraPreview(_cameraControlle),
),
),
),
// 顶部导航
  

 

 

83.iOS 在pod install时出现‘[!] CDN: trunk Repo update failed’

https://www.jianshu.com/p/bf1cbe49cb5d

 84.cocoapds 取消代理

https://blog.csdn.net/GanSir_Auto/article/details/102297630

85.  Proxy Configuration ! NO_PROXY is not set 或者 This is taking an unexpectedly long time

环境变量中添加

 

export no_proxy="localhost,127.0.0.1"

 

export PUB_HOSTED_URL=https://pub.flutter-io.cn

export FLUTTER_STORAGE_BASE_URL=https://storage.flutter-io.cn

然后 source .bash_profile. 最好再重启下机子。

 

 86.去除Tabbar自带的点击阴影效果。

使用

Theme(
            data: ThemeData(
              splashColor: Colors.transparent,
              highlightColor: Colors.transparent,
            ),
 child:XXX
)

 如:

 @override
  Widget build(BuildContext context) {
    //初始化数据
    initData();
    return Scaffold(
        body: _pageList[_tabIndex],
        bottomNavigationBar: Theme(
            data: ThemeData(
              splashColor: Colors.transparent,
              highlightColor: Colors.transparent,
            ),
            child: BottomNavigationBar(
              items: <BottomNavigationBarItem>[
                new BottomNavigationBarItem(
                    icon: getTabIcon(0), title: getTabTitle(0)),
                new BottomNavigationBarItem(
                    icon: getTabIcon(1), title: getTabTitle(1)),
                new BottomNavigationBarItem(
                    icon: getTabIcon(2), title: getTabTitle(2)),
              ],
              type: BottomNavigationBarType.fixed,
              //默认选中首页
              currentIndex: _tabIndex,
              iconSize: 24.0,
              //点击事件
              onTap: (index) {
                setState(() {
                  _tabIndex = index;
                });
              },
            )));
  }

  

 

87. android出现‘could not determiner the dependencies of task ':video_palyer:compileDebugAidl'’..........

 其实是引入过多的库导致,删除相关的库再重新导入即可,连着本地的库也删除。

https://blog.csdn.net/wangyajuncsd/article/details/107070895 

 87.Could not find a file named "xxx/pubspec.yaml" in xxx.git xxx.

 

 

 

删除flutter/.pub-cache文件夹 然后运行flutter packages get就可以了

 88.获取某个widget的高度:使用 GlobalKey绑定组件:

globalKey.currentContext.size.width

https://www.jianshu.com/p/7914727000a5

89.更新ModalBottomSheet中的状态(state)

https://www.jianshu.com/p/949a638cd465

90.处理http请求返回302的问题:

https://www.it1352.com/1760169.html

91、巨大的坑:lib/ui/task_page/task_page.dart:1:8: Error: Not found: 'dart:html'

 

 

 原因竟然是引入了 import 'dart:html'这个

 

 关键这行并不是我特意写的,不知道怎么出现的,出现了也不报错,只是无法重新run,热重载可以的,只是无法build,无法重新run,删除这行就可以了。

 92.android出现这个:error:unepected element <queries> found in <mainfest>

 

 https://stackoverflow.com/questions/62969917/how-do-i-fix-unexpected-element-queries-found-in-manifest/62969918#62969918

 
9
3.修改单独界面的状态栏颜色:采用 外部 AnnotatedRegion 加 自写appBar 或者 外部AnnotatedRegion 加 自带Appbar的brightness

 如下所示:

http://www.45fan.com/article.php?aid=20043019428874854204929043

https://www.jianshu.com/p/b931c05b0df9?utm_campaign=maleskine

 

AnnotatedRegion<SystemUiOverlayStyle>(
          value: SystemUiOverlayStyle.light,
          child: MaterialApp(
            navigatorKey: navGK,
            localizationsDelegates: [
              GlobalMaterialLocalizations.delegate, // 指定本地化的字符串和一些其他的值
              GlobalWidgetsLocalizations.delegate // 指定默认的文本排列方向, 由左到右或由右到左
            ],
            supportedLocales: [
              Locale("zh"),
            ],
..... 。。。其他界面。。。。
/// 导航栏 PreferredSizeWidget _appBarWidget() { return AppBar( brightness: Brightness.light, elevation: 0, leading: InkWell( onTap: () => pop(), child: Container( height: ScreenUtil().setHeight(44), width: ScreenUtil().setHeight(44), child: Center( child: Image.asset('images/back.png'), ),
......

 

 

 

 94.RichText使用点击事件:使用recognizer:

/*
 登录界面
 */
import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:oktoast/oktoast.dart';
import 'package:wangyongzhinan_flutter/config/storage_manager.dart';
import 'package:wangyongzhinan_flutter/ui/main_page.dart';
import 'package:wangyongzhinan_flutter/view_model/user_view_model.dart';

class LoginPage extends StatefulWidget {
  @override
  _LoginPageState createState() => _LoginPageState();
}

class _LoginPageState extends State<LoginPage> {
  TextEditingController _accountController = TextEditingController();
  TextEditingController _pswController = TextEditingController();
  TapGestureRecognizer _tapGestureRecognizer;
  TapGestureRecognizer _tapGestureRecognizer1;

  @override
  void initState() {
    super.initState();
    _tapGestureRecognizer = TapGestureRecognizer();
    _tapGestureRecognizer1 = TapGestureRecognizer();
  }

  @override
  void dispose() {
    super.dispose();
    _tapGestureRecognizer.dispose();
    _tapGestureRecognizer1.dispose();
  }

  /*
   *  使用协议点击
   */
  _protocolOfUsageAction() {
    print('使用协议点击');
  }

  /*
   *  隐私政策点击
   */
  _privacyPollicyAction() {
    print('隐私政策点击');
  }

  /*
   * 点击确认按钮 
   */
  _commitAction() {
    String _accountValue = _accountController.text;
    String _pswValue = _pswController.text;
    if (_accountValue.trim().isEmpty) {
      showToast('用户名不能为空');
      return;
    }
    if (_pswValue.trim().isEmpty) {
      showToast('密码不能为空');
      return;
    }
    Map<String, dynamic> params = {};
    params['username'] = 'admin';
    params['password'] = '68cf63c62bc68d71fc41c028375e2f6e';
    UserViewModel userViewModel = UserViewModel();
    userViewModel.loginAction(params).then(
      (value) async {
        // print('111111');
        // print(value);

        if (value) {
          // print(userViewModel);
          await StorageManager.setString(kToken, userViewModel.model.token);
          Navigator.pushAndRemoveUntil(
            context,
            new MaterialPageRoute(builder: (context) => MainPage()),
            (route) => route == null,
          );
        }
      },
    );
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: SingleChildScrollView(
        child: Column(
          crossAxisAlignment: CrossAxisAlignment.start,
          children: [
            _titleWidget(),
            _accountWidget(),
            _pswWidget(),
            _btnWidget(),
            _explainWidget(),
            _serviceTelWidget(),
          ],
        ),
      ),
    );
  }

  /*
  * 登录title
  */
  Widget _titleWidget() {
    return Padding(
      padding: EdgeInsets.only(
        top: ScreenUtil().setHeight(100),
        left: ScreenUtil().setHeight(30),
      ),
      child: Text(
        '登录',
        style: TextStyle(
          fontSize: ScreenUtil().setSp(22),
          fontWeight: FontWeight.bold,
        ),
      ),
    );
  }

  /*
   * 用户名输入
   */
  Widget _accountWidget() {
    return Padding(
      padding: EdgeInsets.only(
        left: ScreenUtil().setWidth(30),
        right: ScreenUtil().setWidth(30),
        top: ScreenUtil().setWidth(31),
      ),
      child: Theme(
        data: Theme.of(context).copyWith(
          primaryColor: Color.fromRGBO(6, 193, 175, 1),
        ),
        child: TextField(
          keyboardType: TextInputType.text,
          controller: _accountController,
          decoration: InputDecoration(
            labelStyle: TextStyle(color: Colors.red),
            hintText: '请输入用户名',
            hintStyle: TextStyle(
              color: Color.fromRGBO(189, 189, 189, 1),
              fontSize: ScreenUtil().setSp(14),
            ),
          ),
        ),
      ),
    );
  }

  /*
   * 密码输入
   */
  Widget _pswWidget() {
    return Padding(
      padding: EdgeInsets.only(
        left: ScreenUtil().setWidth(30),
        right: ScreenUtil().setWidth(30),
        top: ScreenUtil().setWidth(31),
      ),
      child: Theme(
        data: Theme.of(context).copyWith(
          primaryColor: Color.fromRGBO(6, 193, 175, 1),
        ),
        child: TextField(
          obscureText: true,
          controller: _pswController,
          decoration: InputDecoration(
            labelStyle: TextStyle(color: Colors.red),
            hintText: '请输入密码',
            hintStyle: TextStyle(
              color: Color.fromRGBO(189, 189, 189, 1),
              fontSize: ScreenUtil().setSp(14),
            ),
          ),
        ),
      ),
    );
  }

  /*
   * 登录按钮
   */
  Widget _btnWidget() {
    return InkWell(
      onTap: _commitAction,
      child: Container(
        margin: EdgeInsets.only(top: 50, left: 30, right: 30),
        height: ScreenUtil().setHeight(44),
        decoration: BoxDecoration(
          borderRadius: BorderRadius.all(
            Radius.circular(4),
          ),
          color: Color.fromRGBO(6, 193, 175, 1),
        ),
        child: Center(
          child: Text(
            '登录',
            style: TextStyle(
              color: Colors.white,
              fontSize: ScreenUtil().setSp(16),
            ),
          ),
        ),
      ),
    );
  }

  /*
   * 文字说明 
   */
  Widget _explainWidget() {
    return Padding(
      padding: EdgeInsets.only(left: 34, top: 10),
      child: RichText(
        text: TextSpan(children: <TextSpan>[
          TextSpan(
            text: '继续代表您已阅读并同意',
            style: TextStyle(
              color: Color.fromRGBO(153, 153, 153, 1),
              fontSize: ScreenUtil().setSp(12),
            ),
          ),
          TextSpan(
            recognizer: _tapGestureRecognizer..onTap = _protocolOfUsageAction,
            text: '《使用协议》',
            style: TextStyle(
              color: Color.fromRGBO(6, 193, 175, 1),
              fontSize: ScreenUtil().setSp(12),
            ),
          ),
          TextSpan(
            recognizer: _tapGestureRecognizer1..onTap = _privacyPollicyAction,
            text: '&《隐私政策》',
            style: TextStyle(
              color: Color.fromRGBO(6, 193, 175, 1),
              fontSize: ScreenUtil().setSp(12),
            ),
          )
        ]),
      ),
    );
  }

  /*
   * 客服热线 
   */
  Widget _serviceTelWidget() {
    return Container(
      margin: EdgeInsets.only(
        top: ScreenUtil().setHeight(200),
      ),
      alignment: Alignment.center,
      child: Text(
        '-----客服热线: 0571-89069999-----',
        style: TextStyle(
          fontSize: ScreenUtil().setSp(12),
          color: Color.fromRGBO(189, 189, 189, 1),
        ),
      ),
    );
  }
}

 

95.随意修改 TabBar中indicator的宽度,不局限于label 和 tabel两种选择。

https://blog.csdn.net/xudailong_blog/article/details/98965866 

 

 

96. 写着代码,按了下快捷键还是咋滴,原本好的,出现报错:

 

 

原因只是多了 import 'dart:html';删除该行即可

 

97.NoSuchMethodError: The getter 'modalBarrierDismissLabel' was called on null

 https://www.cnblogs.com/yongfengnice/p/13738479.html

98. Flutter Incorrect use of ParentDataWidget

https://www.jianshu.com/p/14215a5ae8db 

99. flutter: type '_InternalLinkedHashMap<String, dynamic>' is not a subtype of type 'BaseResponseData'

 

 

 我的问题是 默认的请求被我设置为

dio.options.contentType = "application/x-www-form-urlencoded";
 单独的请求需要单独设置下:

 100. 

A界面--> B界面 --> (C界面:扫描二维码界面)取景框底部会多出一块白色物质
A界面--> (C界面:扫描二维码界面),这个时候就正常了。。。。
我的原因:是因为B界面多了个TextField,在跳转时需要先行放下键盘再跳转。放下键盘见 67.

 

101、map获取下标。
https://www.cnblogs.com/yiweiyihang/p/11719570.html

 102.今天修改下终端主题,不知为何,无法检测到flutter了,其余的可以,报错:.bash_profile:16: bad assignment。可是为何之前是好的?还是因为修改主题操作了flutter sdk路径?。。。。

 https://www.codenong.com/51819285/

103.Error Domain=NSCocoaErrorDomain Code=4099

https://www.jianshu.com/p/ffaf12b10ee1

104:Xcode中,在集成umeng_common_sdk 成功后因为移动了项目位置,再次运行项目就报错了: Command PhaseScriptExecution failed with a nonzero exit code。。。。。
按照网上的解决办法:1、修改钥匙串的锁定钥匙串 2、重新pod 3、修改Workspace Setting 4、修改Run Script 都对于我无效,无意之间在输出中看到路径错误了。。。无奈重新手动添加上正确路径,然后删除Pod文件夹,重新install,终于好了。

105.解决空安全和引入一些未适配空安全的库;

https://www.cnblogs.com/liuys635/p/14752694.html
1
06.最近,在写一个新项目的时候,出现pub get failed (66:Cannot open file,path='').....,起初百度无果,全是广告,接着谷歌,一样不行。搞了两个小时。。。。关键是从flutter工程可以运行,从Android就不行。。。。。什么鸡毛问题。

 一开始我先 flutter clean 再 flutter pub get 不行,按照谷歌的删除Android下的build文件夹再flutter pub cache repair不行,其他人的删除.pub-Cache再执行flutter pub get等还是不行。。。。

发现得先删除Android下的build文件夹,再注释该库,注释使用代码,然后再引入该库,再打开相关代码就好了,再打开Android Studio  clean 再 build,好了!!!
107.部分界面禁止右滑返回上一页。

使用WillPopScope包裹一下,如:

https://www.jianshu.com/p/051ae5180411
1
08.开发中,可以新建一个公共类,把很多类都需要使用的类都统一引入,然后只需要在任一文件中引入该统一的文件即可,无需再一一引入了。通过 export "xxx"

 109、最近在使用Getx库的时候,莫名出现个bug,就是Controller里面的生命周期一个都不走了!查了两个半个小时也查不出来。应该不关dokit的事情,但是却一直报这个警告。最后实在找不到哪里写错了。只能在每个类加载的时候,发起一FutureBuilder的future,然后生命周期就走了。。。。。什么玩意啊!

 

 

 

110、iOS上传app,出现ITMS-90338: Non-public API usage -。。。。

 

 百度、谷歌、GitHub 搜索一大堆。全是一样的解答方案,发现没啥用。。。
网上解答方案: 不行!!!

flutter clean
rm -rf ios/Flutter/Flutter.framework
flutter build ios --release
open xcode 

发现只有打开Xcode 的Scheme设置界面,把Archive调为release就可以了。

 111.Android Studio 4.1 Pligins列表无法加载。

https://www.cnblogs.com/modentime/p/13142000.html

 112. 华为无线调试
https://blog.csdn.net/luzhenyuxfcy/article/details/108384389

113.Android报错:no signature of method: build_erxyjeead8ddoyayphpfxm9m3.android() is applicable for argument types。。。。。


按照国际惯例,先百度后谷歌,都不行。问大佬,1分钟搞定。。。
原来这样子

 

 

 现在改这样:

 

ps:关键这是为何,原来是好的,就这周公司搬家,代码就委屈了。。。。。 

 

 114. 在showModalBottomSheet更改state,如:在showModalBottomSheet中使用radio.需要在showModalBottomSheet中嵌套一个StatefulBuilder,否则更改无效。

https://stackoverflow.com/questions/52414629/how-to-update-state-of-a-modalbottomsheet-in-flutter

showModalBottomSheet(
    context: context,
    builder: (context) {
      return StatefulBuilder(
          builder: (BuildContext context, StateSetter setState /*You can rename this!*/) {
        return Container(
          height: heightOfModalBottomSheet,
          child: RaisedButton(onPressed: () {
            setState(() {
              heightOfModalBottomSheet += 10;
            });
          }),
        );
      });
});

 115. Android出现 entry name 'assets/ag_sdk_cbg_root.cer' collided
直接把 ..../build/app/outputs/flutter-apk/app-debug.apk 下的debug app删除即可

 116、出现 The following assertion was thrown:

 

 The following assertion was thrown:
I/flutter (16387): Vertical viewport was given unbounded height.
I/flutter (16387): Viewports expand in the scrolling direction to fill their container. In this case, a vertical
I/flutter (16387): viewport was given an unlimited amount of vertical space in which to expand. This situation
I/flutter (16387): typically happens when a scrollable widget is nested inside another scrollable widget.
I/flutter (16387): If this widget is always nested in a scrollable widget there is no need to use a viewport because
I/flutter (16387): there will always be enough vertical space for the children. In this case, consider using a Column
I/flutter (16387): instead. Otherwise, consider using the "shrinkWrap" property (or a ShrinkWrappingViewport) to size
I/flutter (16387): the height of the viewport to the sum of the heights of its children.

 

 最简单的修改方式就是如它反馈的信息中那样添加shrinkWrap: true即可(ps:一开始我以为是数组的问题,改了半个小时。。。。。。)。

117、什么玩意啊,集成高德地图,一开始iOS老是报map相关组件找不到,模拟器和真机压根启动不了,隐约记得之前archive是好的,于是碰碰运气archive,没想到真的可以,甚至Testflight都是好的,也完全可以下载使用,然后下午就好了,模拟器和真机也可以安装了。。。。。。恶心死我了!!!!

118、最近需求有个要求,需要自定义一个弹框,我于是手写了个,使用showDialog来承载组件,其中需要一个context对象,于是为了方便,直接使用的 Get.context。一切OK,但是如果这个时候,该账户被其他用户登陆了,这个时候刚好有请求的话,APP就自动跳回到登录页面,同时这个自定义弹框还是存在的。这个问题改了一下午。最后在开站会时,被公司大佬教育了下。抱着试试看的态度试了下,果然呀。路由没搞透彻。。。。需要使用当前页面的路由!!!

 同时,需要再接口返回账号被顶的时候:

 119.使用Getx库在长列表中改变UI的办法:如在一个购物车中,增加物品的数量,需要UI也跟随改变,需要对数据源进行 refresh()下,如下

 120.No accounts with App Store Connect access have been found for the team "[My Team Name]". App Stor... 

解决办法竟然是删除账号,完全退出Xcode,再次登录账号。恶心到死的Xcode 
https://www.jianshu.com/p/a68d62116872

121.使用OverlayEntry的时候,发现使用Text样式怪怪的。
这是因为其上级树中缺少了DefalutTextStyle组件:

 

 

 

 

 

 可以为其添加上textThme或者外部包裹一个Material:

 

 

 

 overlayEntry位置可以由Position直接调整.

 122、需要再ShowDialog中使用热重载或者setstate功能时,可以采用两种方案:

①、把showDialog中的builder单独提出来,另建立statelessWidget或者statefulWidget
如:

 

 ②、也可以使用Build组件StatefulBuild组件

如:

 

123、error: RPC failed; curl 56 LibreSSL SSL_read: error:06FFF064:digital envelope routines:CRYPTO_internal:bad decrypt, errno 0

 最近打算升级下flutter sdk,因为公所周知的原因,在终端升级时出现上述问题,我这边是终端输入

git config  --globle   http.sslVerify "false"  

再升级。

124、android打包出现 java.lang.unsatisfiedlinkerror: dlopen failed: library "libflutter.so" not found 
https://cloud.tencent.com/developer/ask/sof/1392702

125、web上使用flutter dio出现 ⚠️ DioError [DioErrorType.response]: XMLHttpRequest error.

这个问题其实是web跨域的问题,对dio添加上 dio.options.contentType = Headers.formUrlEncodedContentType;

 

 

126、脱字号“^”开头的版本表示和当前版本接口保持兼容的最新版,^1.2.3 等效于 >=1.2.3 <2.0.0 而 ^0.1.2 等效于 >=0.1.2 <0.2.0

 127、在Android上,打出debug包可以正常显示,但是release却无法正常显示,只是一片灰色???

找了半天,在网上找到方案,原来是Stack的问题,需要再其外面包裹一层Column或者Row才行,不能直接放在外面那样。

 

127、今天突然无法启动iOS模拟器了。

 不明所以,使用万能重启法搞定。

128.mac 升级java 版本。

前去java官网下载sdk,安装后
显示设备上安装好的sdk版本:

cd /Library/Java/JavaVirtualMachines 
ls -al

打开open  ~/.zshrc,注释旧的路径,写入新的:

# java 
# export JAVA_HOME="/Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home"
# export PATH=${JAVA_HOME}/bin:$PATH
# export CLASSPATH=$JAVA_HOME/lib/tools.jar:$JAVA_HOME/lib/dt.jar:.
export JAVA_8_HOME="$(/usr/libexec/java_home -v 1.8)"
export JAVA_11_HOME="$(/usr/libexec/java_home -v 11)"
alias jdk8='export JAVA_HOME=$JAVA_8_HOME'
alias jdk11='export JAVA_HOME=$JAVA_11_HOME'
export JAVA_HOME=$JAVA_11_HOME

退出,source ~/.zshrc,然后就可以使用jdk8 和 jdk11更换java 的版本了。

其中,旧版本Mac使用的是  ~/.bash_profile  新版本Mac用的是  ~/.zshrc ,这个得注意下。

 129、最近使用showDialog出现No Material widget found的奇怪bug.。。。。。。
找了半天,发现是InkWell()问题,改为GestureDetector就可以了,莫名其妙~~~可能是项目既用了getx又用了provider,哪里配置有遗漏吧,也可能版本的问题。。。。

 

 

 

 

 

 

 130、使用了iconfont,打包出现 This application cannot tree shake icons fonts. It has non-constant instances of IconData
只需要在使用的时候加一个const即可。

https://blog.csdn.net/qq_42944436/article/details/108485730

 131、iOS 编译报Command CompileAssetCatalog failed with a nonzero exit code,reason: 'The tool closed the connection (AssetCatalogSimulatorAgent)

终端执行 :
sudo killall -9 com.apple.CoreSimulator.CoreSimulatorServicehttps://www.jianshu.com/p/928a888a9f49
132、android运行出现,如图

 


需要打开Android Studio的Edit Configurations配置上对应的build flavor.对应的值可以在.../.../../build中,如上图显示那样。

 

133、修改AppBar的高度,如:需要使用自定义的AppBar,但又需要自己控制当前界面的状态栏的颜色。

使用 PreferredSize 包在AppBar的外面,设置其的preferredSize即可。

 

 

 134.ERROR:  While executing gem ... (Gem::Ext::BuildError) ERROR: Failed to build gem native extension.

 执行 

rvm get stable 

后,然后再

source ~/.bash_profile
sudo gem pristine --all

我的用上面的可以
133、GestureDetector和 InkWell

InkWell 有水波纹
如果出现无水波纹的情况,通常是其子组件设置了背景色或者背景图导致,如果仍然想要水波纹,可以有两个方法:
1、包一层 Material,将背景色设置在 Material中的color里
Material(
  color: Colors.white,
  child: InkWell(),
)
2、使用Stack布局,将InkWell放置在上层。这种适用于给图片添加点击效果,比如Banner图的点击。
        Stack(
            children: <Widget>[
              Positioned.fill(
                child: Image(),
              ),
              Positioned.fill(
                child: Material(
                  color: Colors.transparent,
                  child: InkWell(
                    splashColor: Color(0X40FFFFFF),
                    highlightColor: Colors.transparent,
                    onTap: () {},
                  ),
                ),
              )
            ],
          )

如果不想要水波纹,有三种方法:
1、给子组件给个颜色或者背景图
2、使用全局Theme设置即可
MaterialApp(
    theme: ThemeData(
      highlightColor: Colors.transparent,
      splashFactory: NoSplash.splashFactory,
    ),
);
3、单独设置
 InkWell(
   onTap: () {},
   child: Text('InkWell 组件'),
      highlightColor: Colors.transparent, // 透明色
      splashColor: Colors.transparent, // 透明色
)
 GestureDetector 无水波纹
如果出现点击较慢的情况,可以换为inkwell

134、Android studio 出现 Connect to 127.0.0.1:[/127.0.0.1] failed: Connection refused

https://blog.csdn.net/qq_43377749/article/details/112981331
终端使用:

unset http_proxy
unset https_proxy

135、iOS 在 pod --version 时出现 Ignoring executable-hooks-1.6.1 because its extensions are not built. Try: gem pristine executable-hooks --version 1.6.1 1.12.1

 使用

 

rvm list
rvm use ruby-version
rvm remove ruby-useless-version
gem uninstall cocoapods
gem install cocoapods

 

https://stackoverflow.com/questions/38797458/ignoring-gem-because-its-extensions-are-not-built

  136、rvm -v 出现 Warning! PATH is not properly set up 。。。。。。

 使用 rvm reset

 137、pod install后出现 "[!] Oh no, an error occurred."如

 解决办法:

 https://github.com/CocoaPods/CocoaPods/issues/9484

138、输出日志显示不全。

import 'dart:developer';
  
log(response.body);

https://blog.csdn.net/mp624183768/article/details/116785937

 139、Flutter MaterialApp里的title到底是什么?

其实就是切到后台时,app上面的文字。

https://blog.csdn.net/u013297881/article/details/102741911

140、Xcode升级后,需要下载模拟器,但是老是失败。

 

 

 

https://www.jianshu.com/p/f47c024885c5
下载下来后,可以直接终端跑下下面两个命令即可:

sudo xcode-select -s /Applications/Xcode.app

xcrun simctl runtime add ~/Downloads/iOS_17.2_Simulator_Runtime.dmg