Messio icon indicating copy to clipboard operation
Messio copied to clipboard

AuthenticationEvent build error with Equatable

Open pazhut opened this issue 6 years ago • 3 comments

seems that Equatable API had changed and the code at the events part do not build any longer, i have the following code:

import 'dart:io'; import 'package:equatable/equatable.dart'; import 'package:meta/meta.dart';

@immutable abstract class AuthenticationEvent extends Equatable { const AuthenticationEvent([List props = const []]) : super(); }

class ScreenEntered extends AuthenticationEvent { @override String toSring() => "ScreenEntered"; }

and getting an error that i am missing a getter for Equatable.props, i think this is related to API change

pazhut avatar Nov 19 '19 04:11 pazhut

seems that Equatable API had changed and the code at the events part do not build any longer, i have the following code:

import 'dart:io'; import 'package:equatable/equatable.dart'; import 'package:meta/meta.dart';

@immutable abstract class AuthenticationEvent extends Equatable { const AuthenticationEvent([List props = const []]) : super(); }

class ScreenEntered extends AuthenticationEvent { @override String toSring() => "ScreenEntered"; }

and getting an error that i am missing a getter for Equatable.props, i think this is related to API change

Yes. The newer API needs you to override the get props method instead of passing the class fields to super class. I'll update the code with the latest version of both equatable and flutter_bloc soon. Thanks.

adityadroid avatar Nov 19 '19 05:11 adityadroid

thanks for your update, any chance you can provide me with short code snippet for my current issue?

pazhut avatar Nov 19 '19 15:11 pazhut

thanks for your update, any chance you can provide me with short code snippet for my current issue? Sure. This is the new way of doing things in equatable. You need to declare your variables in the props override now.

abstract class AuthenticationEvent extends Equatable {
  @override
  List<Object> get props => [];
}
class ScreenEntered extends AuthenticationEvent {
@override
String toSring() => "ScreenEntered";
}

adityadroid avatar Nov 19 '19 19:11 adityadroid