Comments (24)
Maybe
basic.dart Context.stfState
could help you.
In Context:
/// In general, we should not need this field.
/// When we have to use this field, it means that we have encountered difficulties.
/// This is a contradiction between presentation & logical separation, and Flutter's Widgets system.
///
/// How to use ?
/// For example, we want to use SingleTickerProviderStateMixin
/// We should
/// 1. Define a new ComponentState
/// class CustomStfState extends ComponentState<T> with SingleTickerProviderStateMixin {}
/// 2. Override the createState method of the Component with the newly defined CustomStfState.
/// @override
/// CustomStfState createState() => CustomStfState();
/// 3. Get the CustomStfState via context.stfState in Effect.
/// AnimationController controller = AnimationController(vsync: context.stfState);
/// context.dispatch(ActionCreator.createController(controller));
State get stfState;
from fish-redux.
0.1.2 has been published, which includes the getter of stfState feature.
from fish-redux.
class KeepAliveWidget extends StatefulWidget {
final Widget child;
const KeepAliveWidget(this.child);
@override
State<StatefulWidget> createState() => KeepAliveState();
}
class KeepAliveState extends State<KeepAliveWidget>
with AutomaticKeepAliveClientMixin {
@override
bool get wantKeepAlive => true;
@override
Widget build(BuildContext context) {
return widget.child;
}
}
Widget keepAliveWrapper(Widget child) {
return KeepAliveWidget(child);
}
from fish-redux.
@zjuwjf 这个特性什么时候能放到pub上
from fish-redux.
@zjuwjf
我照着例子写这边报错,是什么原因呢
from fish-redux.
@zjuwjf
我照着例子写这边报错,是什么原因呢
final TickerProvider tickerProvider = ctx.stfState;
...
from fish-redux.
Same here. (type can not be assigned to ...)
from fish-redux.
it worked as: final TickerProvider tickerProvider = ctx.stfState as CustomStfState;
from fish-redux.
Maybe
basic.dart Context.stfState
could help you.In Context:
/// In general, we should not need this field. /// When we have to use this field, it means that we have encountered difficulties. /// This is a contradiction between presentation & logical separation, and Flutter's Widgets system. /// /// How to use ? /// For example, we want to use SingleTickerProviderStateMixin /// We should /// 1. Define a new ComponentState /// class CustomStfState extends ComponentState<T> with SingleTickerProviderStateMixin {} /// 2. Override the createState method of the Component with the newly defined CustomStfState. /// @override /// CustomStfState createState() => CustomStfState(); /// 3. Get the CustomStfState via context.stfState in Effect. /// AnimationController controller = AnimationController(vsync: context.stfState); /// context.dispatch(ActionCreator.createController(controller)); State get stfState;
@zjuwjf
我照着例子写这边报错,是什么原因呢final TickerProvider tickerProvider = ctx.stfState; ...
`
// state.dart
class IndexState extends StatefulWidget implements Cloneable {
Orders orders;
@OverRide
IndexState clone() {
return IndexState()..orders = orders;
}
@OverRide
_IndexStateState createState() => _IndexStateState();
}
class _IndexStateState extends State
with SingleTickerProviderStateMixin {
@OverRide
Widget build(BuildContext context) {
return Container();
}
}
`
// effect.dart
ctx.stfState 返回的类型,不是tickerProvider,而是state
from fish-redux.
参考说明应该是这样
component.dart
class _IndexComponentState extends ComponentState<IndexState> with SingleTickerProviderStateMixin {}
class IndexComponent extends Component<IndexState> {
@override
_IndexComponentState createState() => _IndexComponentState();
}
Effect.dart
final TickerProvider tickerProvider = ctx.stfState;
from fish-redux.
请问下按照如上方式做了tabcontroller 想要添加keepalive功能应该如何配置呢,我这样配置了以后会报错
from fish-redux.
如何可以, 把上下文的代码都贴下。
from fish-redux.
page的state
with SingleTickerProviderStateMixin的新state
page
effect
view
这样操作以后tabcontroller可以正常使用,然后我想加keepalive功能
于是将新state改为如下
运行后报错
from fish-redux.
page的state
with SingleTickerProviderStateMixin的新state
page
effect
view
这样操作以后tabcontroller可以正常使用,然后我想加keepalive功能
于是将新state改为如下
运行后报错
What’s the lifecycle that calling _init function in effect? If it is Lifecycle.build my case the problem above.
from fish-redux.
My problem is that once I add AutomaticKeepAliveClientMixin in newstate, the program doesn't work properly.
@zjuwjf @jkyeo
from fish-redux.
嗯,看了下 是 AutomaticKeepAliveClientMixin 内部实现的问题, 它覆盖了ComponentState的build方法,导致返回了null。 你可以通过在page上添加一个wraper(widget => widget) 可以达到你的需求。
from fish-redux.
第二个图不会操作了,能不能指点下要如何配置,网上找不到相关配置 @zjuwjf
from fish-redux.
第二个图不会操作了,能不能指点下要如何配置,网上找不到相关配置 @zjuwjf
所以 楼主,后面实现AutomaticKeepAliveClientMixin效果了吗?我使用你们的方式,依旧没有实现
from fish-redux.
看上去可能和fish-redux无关 flutter/flutter#28345
from fish-redux.
第二个图不会操作了,能不能指点下要如何配置,网上找不到相关配置 @zjuwjf所以 楼主,后面实现AutomaticKeepAliveClientMixin效果了吗?我使用你们的方式,依旧没有实现
其实可以的,创建一个dart内容如下
class KeepAliveWidget extends StatefulWidget {
final Widget child;
const KeepAliveWidget(this.child);
@OverRide
State createState() => KeepAliveState();
}
class KeepAliveState extends State
with AutomaticKeepAliveClientMixin {
@OverRide
bool get wantKeepAlive => true;
@OverRide
Widget build(BuildContext context) {
return widget.child;
}
}
Widget keepAliveWrapper(Widget child) {
return KeepAliveWidget(child);
}
然后这样包裹,原理都一样,框架没问题
from fish-redux.
能把实现的demo开源吗?
from fish-redux.
#385 在fish-redux中,直接提供这些mixin。
from fish-redux.
第二个图不会操作了,能不能指点下要如何配置,网上找不到相关配置 @zjuwjf所以 楼主,后面实现AutomaticKeepAliveClientMixin效果了吗?我使用你们的方式,依旧没有实现
其实可以的,创建一个dart内容如下
class KeepAliveWidget extends StatefulWidget {
final Widget child;const KeepAliveWidget(this.child);
@OverRide
State createState() => KeepAliveState();
}class KeepAliveState extends State
with AutomaticKeepAliveClientMixin {
@OverRide
bool get wantKeepAlive => true;@OverRide
Widget build(BuildContext context) {
return widget.child;
}
}Widget keepAliveWrapper(Widget child) {
return KeepAliveWidget(child);
}
然后这样包裹,原理都一样,框架没问题
谢谢
from fish-redux.
我也遇到了类似的问题
#534
from fish-redux.
Related Issues (20)
- 对 阿里 的项目很是失望, 以后一定要慎用 慎用 慎用 HOT 11
- 是否有源码的说明文档
- SourceFlowAdapter+VisibleChangeMixin
- Fish-Redux有没有跨页面传输的方案
- 什么时候可以支持Flutter2的空安全 HOT 4
- Flutter 都出2.5 了,你们还不适配空安全吗? HOT 8
- 请问可以支持flutter 2.0以上空安全吗? HOT 3
- RecycleContext是否有意义?
- FlowAdapter的功能什么时候能发布一下? HOT 2
- 关于InheritedWidget注册绑定不兼容问题
- 好蛋疼啊,发邮件问又说更新维护,但是这么久了,就是不更新,如果停止维护了,请发个声明出来行吗,这么大个公司了 HOT 6
- ExpansionPanelList 传值
- 啥时候升到 2.0 的空安全啊 HOT 3
- 不建议再引用此项目,学习它移除它花费了不少精力 HOT 5
- Support null safety and latest flutter upgrade HOT 6
- Русские вперёд!
- 欢迎大家 加入MyFlutter中文社区 http://my.flutter.zone,一起讨论Flutter技术,qq群号 188651997 HOT 1
- 停止维护了吗? HOT 3
- 基于fishredux重构并支持flutter3.x的flying-redux,请有兴趣的同学指教和支持 HOT 1
- 一个fish-redux,还有一个flutter-boost。这个两个关于Flutter的库慎用!!! HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from fish-redux.