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

Exception AppState' is not a subtype of type 'Reducer<AppState>' when creating a store. #27

Closed
arturstaszczyk opened this issue Apr 9, 2018 · 6 comments

Comments

@arturstaszczyk
Copy link

Hi, after creating a simple application I get following exception:

type '(AppState, dynamic) => AppState' is not a subtype of type 'Reducer' of 'reducer'.

Here's my setup:

dependencies:
  flutter_redux: "^0.5.0"
  redux: "^3.0.0"

@immutable
class AppState {
  final List<double> history;
  final bool screen;

  AppState(this.history, this.screen) {}

  factory AppState.initial() => new AppState(new List.unmodifiable([]), false);
}

AppState appReducer(AppState state, action) {
  return new AppState.initial();
}

final store = new Store<AppState>(
		appReducer,
		initialState: new AppState.initial(),
	);

If I change 'AppState' to 'int' in the reducer, the app runs OK.
Is there something wrong with my code?

Cheers,
Artur

@bgetsug
Copy link

bgetsug commented Apr 10, 2018

I ran into this issue while studying the examples in https://github.com/brianegan/flutter_architecture_samples, after I upgraded from Flutter 0.2.3 to 0.2.8. Downgrading Flutter back to 0.2.3 resolves it for me.

@bgetsug
Copy link

bgetsug commented Apr 10, 2018

I upgraded back to Flutter 0.2.8, then followed the directions here...

...making changes to https://github.com/brianegan/flutter_architecture_samples/tree/master/example/redux accordingly.

Then I ran flutter clean and re-installed the app, and it worked :)

I'm guessing that the most recent versions of Flutter default to Dart 2.

@brianegan
Copy link
Collaborator

Thanks for the report! Yep, they just released the new beta with Dart 2 on by default. I'll be updating the arch samples shortly :)

@brianegan
Copy link
Collaborator

brianegan commented Apr 10, 2018

@arturstaszczyk Hrm, this is an odd one... If I copy / paste your code directly into a new Flutter project, everything seems to work for me :(

Do you happen to have duplicate AppState classes defined in your project or anything like that?

Could you please tell me which version of Flutter you're on (master, beta, etc)? I'm rocking the latest Beta for these tests.

@brianegan brianegan reopened this Apr 10, 2018
@brianegan
Copy link
Collaborator

@arturstaszczyk Hey there, any update on this one? Did ya get it working or need more help?

@brianegan
Copy link
Collaborator

Gonna close this out due to inactivity, but happy to help if ya need anything else :)

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