Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fish-redux和annotation_route配合起来怎么用? #60

Closed
evelynEdison opened this issue Mar 13, 2019 · 3 comments
Closed

fish-redux和annotation_route配合起来怎么用? #60

evelynEdison opened this issue Mar 13, 2019 · 3 comments

Comments

@evelynEdison
Copy link

No description provided.

@voicewitness
Copy link

voicewitness commented Mar 13, 2019

fish-redux的page会产生一个widget,annotation_route可以接受一个widget上的注释,那么我们配合使用的时候,可以先建一个自己的widget类(如TestPageWidget),然后在build函数中填充page产生的widget,示例代码如下:

@ARoute(url: 'scheme://host')
class TestPageWidget extends StatefulWidget {
  MyRouterOption routerOption;
  TestPageWidget(this.routerOption) : super();
  @override
  State<StatefulWidget> createState() {
    return TestPageWidgetState(routerOption);
  }
}

class TestPageWidgetState extends State<TestPageWidget> {
  MyRouterOption routerOption;
  TestPageWidgetState(this.routerOption) : super();
  @override
  Widget build(BuildContext context) {
    return TestPageContainer().buildPage(routerOption);
  }
}
class TestPageContainer extends Page<TestPageContainerState, Object> {
  TestPageContainer()
      : super(
          initState: initState,
          view: buildTestView,
          reducer: TestReducerBuilder.build(),
        );
}

@evelynEdison
Copy link
Author

好的,非常感谢

@xiaobt
Copy link

xiaobt commented Apr 23, 2019

fish-redux的page会产生一个widget,annotation_route可以接受一个widget上的注释,那么我们配合使用的时候,可以先建一个自己的widget类(如TestPageWidget),然后在build函数中填充page产生的widget,示例代码如下:

@ARoute(url: 'scheme://host')
class TestPageWidget extends StatefulWidget {
  MyRouterOption routerOption;
  TestPageWidget(this.routerOption) : super();
  @override
  State<StatefulWidget> createState() {
    return TestPageWidgetState(routerOption);
  }
}

class TestPageWidgetState extends State<TestPageWidget> {
  MyRouterOption routerOption;
  TestPageWidgetState(this.routerOption) : super();
  @override
  Widget build(BuildContext context) {
    return TestPageContainer().buildPage(routerOption);
  }
}
class TestPageContainer extends Page<TestPageContainerState, Object> {
  TestPageContainer()
      : super(
          initState: initState,
          view: buildTestView,
          reducer: TestReducerBuilder.build(),
        );
}

这种在外面包一层壳的方式不太好吧,如果有很多跳转page的路由,那不是得创建很多类似的类,请问一下有没有更好的方式来解决annotation_route配合问题?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants