早上开车等红绿灯时想到几个月前写的一个算法,应该可以更简单,今天重新写了一遍
寻找下一个数字,例如输入345,输出354
思路:从最右边位和上一位对比,如果大,就往前移,移动完,尾数排序,从小到大,保证次大
代码
1 | //字符串分成数组 |
使用:
1 | NSString *str = findNextLargerNum(@"8976"); |
早上开车等红绿灯时想到几个月前写的一个算法,应该可以更简单,今天重新写了一遍
寻找下一个数字,例如输入345,输出354
思路:从最右边位和上一位对比,如果大,就往前移,移动完,尾数排序,从小到大,保证次大
代码
1 | //字符串分成数组 |
1 | NSString *str = findNextLargerNum(@"8976"); |
抽取widget,尽量成为一个stateless widget
1 | class MainWidget extends StatelessWidget { |
更新属性值,用传值的方式
ChangeNotifier
1 | //------ ChangeNotifier class ----// |
ValueNotifier
1 | class _MyHomePageState extends State<MyHomePage> { |
使用const修饰stateless widget,set state不会重复刷新
1 | class BackgroundWidget extends StatelessWidget { |
生成列表的时候使用itemExtent属性告诉系统item高度,更高效的滑动
1 | class MyHomePage extends StatelessWidget { |
需要动画的子控件设置给AnimatedBuilder的child,避免重复绘制
1 | @override |
合理使用opacity属性,减少调用setlayer方法,触发离屏渲染
使用fadeTransition
1 | class _MyHomePageState extends State<MyHomePage> |
使用animatedOpacity
1 | const duration = const Duration(milliseconds: 600); |
完。
sources:
flutter工程打包apk文件后
1 | try { |
这段代码无法执行
经过咨询,安卓release包会代码混淆,使用反射会让代码无法精确匹配
2.https://blog.csdn.net/guohesheng/article/details/53696652
3.https://www.jianshu.com/p/b5b2a5dfaaf4
感谢王志浩同学提供帮助!
avoid costly work in build() since build() can be invoked frequently when ancestor Widgets rebuild
avoid calling setState() high up in the tree
Use the lazy methods, with callbacks,when building large grids or lists, that way only the visible portion of the screen is built at startup time
avoid invoke saveLayer(),including
Ways to avoid calls to saveLayer():
build and display frames in 16ms
build subtree widget once and pass it as a child to the AnimatedBuilder
pre-clip image before animating it
avoid using constructors with a concrete List of children if most of the children are not visible on screen
source:https://flutter.dev/docs/perf/rendering/best-practices
/ɡrɑːsp $ ɡræsp/
verb
1 | 1.I grasped his arm firmly and led him away |
/dəˈrektɪv/
noun
1 | 1.an official oeder or instruction |
proposals for implementing the EU directive on paternity leave
/əˈledʒ/
verb
1 | 1.to say that something is true,although it has not been proved |
The water is alleged to be pollutedted with mercury.
/ˈmiːdiəm/
noun
1 | 1.a way of communicating information and news to people,such as newspapers,television etc |
Advertising is a powerful medium
/ˈtenjə/
noun
1 | 1.the right to stay permanently in a teaching job |
It’s becoming increasingly difficult to acquire academic tenure
/redʒɪˈstreɪʃən/
noun
1 | 1.the act of recording names on an official list |
the registration of motor vehicles
[ˈrætɪfaɪ]
verb
1 | to make a written agreement official by signing it |
We hope that the republics will be willing to ratify the treaty.
/ˌɪnstənˈteɪniəs◂/
adj
1 | happening immediately |
modern methods of instantaneous communication
/eɪd/
noun
1 | something such as a machine or tool that helps someone do something |
A video is a useful aid in the classroom
/ˈriːleɪ/
verb
1 | to pass a message from one person to another |
relay something to somebody
/ˈseməfɔː $ -fɔːr/
noun
1 | a system of sending messages useing two flags,which you hold in different positions to represent letters and numbers |
/ˈsɜːkɪt/
noun
1 | a path that forms a circle around an area |
we did a circuit of the old city
/ˈmæɡnɪtɪzəm/
noun
1 | the physical force that makes two metal objects pull toward each other or push each other apart |
personal magnetism
/ˈskwɪɡəl/
noun
1 | a line with irregular curves |
Shorthand just looks like a series of funny squiggles to me
/ˈpærədaɪm/
noun
1 | a very clear example of something |
the basic paradigm of the family tree
/ˈpeɪtnt/
noun
1 | a special document that gives you the right to make or sell a new invention or product that no one else is allowed to copy |
The drugs are protected by patent
/rɪˈfɜː $ -ɜːr/
verb
1 | 1.to mention about something |
We agreed never to refer to the matter again.
错误描述:在A类访问B类里的static 变量,永远是初始值,即使已经设置过新值
解决办法:A类import B类头文件时使用绝对路径,不使用系统默认
1 | //错误 |
B类结构
1 | class AppHelper { |
新词:
1 | toy around |
错误描述: pod install时发生错误
1 | ### Error |
解决办法:在flutter目录运行以下命令
1 | flutter clean |
问题:在build的时候framework not found
解决:
1 | project.xcodeproj文件--->显示包内容--->project.pbxproj文件 全局查找删除 |
ps:版本对不上处理方法同理,修改版本号和实际pods下载过来一致
问题:
1 | fatal: unable to access 'https://github.com/xxx/xxx.github.io.git/': LibreSSL SSL_connect: SSL_ERROR_SYSCALL in connection to github.com:443 |
解决:在_config.yml文件里把deploy的地址从http换成git
1 | deploy: |
参考链接: