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

architecture same issues #112

Open
BelongsH opened this issue Nov 6, 2020 · 0 comments
Open

architecture same issues #112

BelongsH opened this issue Nov 6, 2020 · 0 comments

Comments

@BelongsH
Copy link

BelongsH commented Nov 6, 2020

Thank you for your valuable advice on the architecture。

I'm looking at your code, there are still many things I can't understand. Need to ask you。

    return BaseWidget<HomeViewModel>(
      viewModel: HomeViewModel(),
      onModelReady: (model) => model.initialise(),
      child: ScreenTypeLayout(
        mobile: OrientationLayout(
          //ioc view
          portrait: (context) => HomeMobilePortrait(),
          landscape: (context) => HomeMobileLandscape(),
        ),
        tablet: HomeViewTablet(),
      ),
    );

BaseWidget need provider ViewModel type . why not create instance according to this ViewModel type ? like java invoke.

abstract class BaseModelWidget<T> extends Widget {
  @protected
  Widget build(BuildContext context, T model);

  @override
  DataProviderElement<T> createElement() => DataProviderElement<T>(this);
}

//
class DataProviderElement<T> extends ComponentElement {
  DataProviderElement(BaseModelWidget widget) : super(widget);

  @override
  BaseModelWidget get widget => super.widget;

  @override
  Widget build() => widget.build(this, Provider.of<T>(this));

  @override
  void update(BaseModelWidget newWidget) {
    super.update(newWidget);
    assert(widget == newWidget);
    rebuild();
  }
}

BaseModelWidget Does it really have a meaning, more often, I think it just comes from provider .

Sometimes, I get confused by its name, whether this is a widget or a viewmodel or even a model .

Please forgive me, this bad English

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

1 participant