Hi,
I have a list in which list items can be selected and not selected. The list is the bloc itself as a global variable. I tap on the list item to toggle the selection and dispatch an event to the bloc.
Then in the bloc I toggle the selected state of the tapped item and update the list. After that I yield a the state only the yield doesn't work.
I was able to debug and see that the currentState was always equal to newState. How can I update my list in this scenario? It always considers this as a duplicate and never yields.
Hi @Sourabhlpu π
My guess is you aren't returning a new instance of your state along with a new instance of your list. If you check out the todos tutorial you'll see an example of this:
final List<Todo> updatedTodos =
List.from((currentState as TodosLoaded).todos)..add(event.todo);
yield TodosLoaded(updatedTodos);
If that doesn't help, then it would be great if you could share your bloc as well as your state implementation.
Thanks π
Hi @felangel ,
Thank you for your response. Here is the logic that I am using to update my list:
`if (event is EventTypePressed) {
List<EventTypes> newEventTypes = List.from(_eventTypes);
String eventTypeName = newEventTypes[event.index].interestName;
bool isSelected = newEventTypes[event.index].isSelected;
EventTypes eventType =
EventTypes(interestName: eventTypeName, isSelected: !isSelected); //toggle the selection
newEventTypes.insert(event.index, eventType);
newEventTypes.removeAt(event.index + 1);
yield EventTypeToggled(eventType: newEventTypes);
_updateEventTypeList(event.index, eventType);
}`
When I debug and see check the currentState and newState, both states have the list in them as expected. CurrentState has the list with last selection state of that item and the newState has the correct selection state. But while comparing it still treats those lists equal? I used a hack where I fired up another dummy event just after yeilding EventTypeToggled state and it worked but I don't think that's the right way to go.
Thanks
Hey @sourabhlpu!
Can you please include your implementation for your EventType states? Thanks!
`abstract class CreateEventStates extends Equatable{
CreateEventStates([List props = const[]]) : super(props);
}
class CreateEventInitial extends CreateEventStates{
@override
String toString() => "createEventInitial";
}
class CreateEventLoading extends CreateEventStates{
@override
String toString() => "loading";
}
class CreateEventSuccess extends CreateEventStates{
@override
String toString() => "createEventSuccess";
}
class CreateEventFailure extends CreateEventStates{
final String error;
CreateEventFailure({@required this.error}) : super([error]);
@override
String toString() => "CreateEventFailure {error : $error}";
}
class ListFetched extends CreateEventStates{
final List
ListFetched({@required this.eventType}):super([eventType]);
@override
String toString() => "List fetched {$eventType}";
}
class UploadingImage extends CreateEventStates{
final double percent;
UploadingImage({@required this.percent}):super([percent]);
@override
String toString() => "uploading image";
}
class ImageUploaded extends CreateEventStates{
final String fileName;
ImageUploaded({@required this.fileName}):super([fileName]);
@override
String toString() => "image uploaded";
}
class ImageUploadFailed extends CreateEventStates{
@override
String toString() => "upload image failed";
}
class EventTypeToggled extends CreateEventStates{
final List
EventTypeToggled({this.eventType}):super([eventType]);
@override
String toString() => "event type selected";
}
class EventTypeTapped extends CreateEventStates{
@override
String toString() => "Event type tapped";
}
class LocationSelected extends CreateEventStates{
final String location;
LocationSelected({@required this.location}):super([location]);
@override
String toString() => "event location: $location";
}`
Hmm everything seems okay. Are you able to share a link to the repository so I can run the code on my computer and debug it?
Please look for create event section. If you can successfully log into the app. From home screen:
bottom nav > profile > organise event > create event screen.
On this screen there is the horizontally scrolling list, which is causing the problem.
Create event page is the only page where I have implemented the bloc library. The rest of the code is not refactored on which I am currently working.
Sounds good! Iβll take a look in the next few hours
Thanksπ
On Sun, Apr 7, 2019, 10:13 PM Felix Angelov <[email protected] wrote:
Sounds good! Iβll take a look in the next few hours
β
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/felangel/bloc/issues/202#issuecomment-480608544, or mute
the thread
https://github.com/notifications/unsubscribe-auth/AQ2Hyc4Sosx98bdftvd-v_vjRog9iiwbks5veiAcgaJpZM4cgZIP
.
@Sourabhlpu I tried taking a look but I was having lots of problems because of Firestore and the Google-Services plist not being configured properly. Would it be possible for you to just share a simple sample app which consists of just the create-event bloc and form so that I can more easily debug the issue?
Thanks! π
Yes Sure I will do that
On Mon, Apr 8, 2019, 11:30 AM Felix Angelov <[email protected] wrote:
@Sourabhlpu https://github.com/Sourabhlpu I tried taking a look but I
was having lots of problems because of Firestore and the Google-Services
plist not being configured properly. Would it be possible for you to just
share a simple sample app which consists of just the create-event bloc and
form so that I can more easily debug the issue?Thanks! π
β
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/felangel/bloc/issues/202#issuecomment-480694640, or mute
the thread
https://github.com/notifications/unsubscribe-auth/AQ2HyUrha8XSP4cwkyZdLSlwV0vEBGVzks5vetsTgaJpZM4cgZIP
.
Hi,
Did you use an Android device to run the app? Also the issue you were facing was in signup api?
Thanks
On Mon, Apr 8, 2019, 11:51 AM Sourabh Pal
Hi,
If possible, can you please share the issues you are facing? I will try to
resolve them. Otherwise I will make a demo app.Thanks
On Mon, Apr 8, 2019, 11:32 AM Sourabh Pal[email protected] wrote: Yes Sure I will do that
On Mon, Apr 8, 2019, 11:30 AM Felix Angelov <[email protected]
wrote:@Sourabhlpu https://github.com/Sourabhlpu I tried taking a look but I
was having lots of problems because of Firestore and the Google-Services
plist not being configured properly. Would it be possible for you to just
share a simple sample app which consists of just the create-event bloc and
form so that I can more easily debug the issue?Thanks! π
β
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/felangel/bloc/issues/202#issuecomment-480694640,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AQ2HyUrha8XSP4cwkyZdLSlwV0vEBGVzks5vetsTgaJpZM4cgZIP
.
@Sourabhlpu no I tried running on iOS. I can try on Android as well later today.
Well i never ran it on an ios deviceπ But then I just downloaded it from
my github again and opened the project and there is actually an issue with
sign in and sign up. I have posted an issue on stack overflow for the same.
Can you please check and see if you can help answer it. I have sent you an
email for the stackoverflow link.
Thanks
On Mon, Apr 8, 2019, 9:31 PM Felix Angelov <[email protected] wrote:
@Sourabhlpu https://github.com/Sourabhlpu no I tried running on iOS. I
can try on Android as well later today.β
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/felangel/bloc/issues/202#issuecomment-480893856, or mute
the thread
https://github.com/notifications/unsubscribe-auth/AQ2HySLMGqY4_lW5i7hi03SLxFEyz5uhks5ve2fKgaJpZM4cgZIP
.
@Sourabhlpu I saw the stackoverflow post and I'm not sure what the problem is but it happened to me as well.
You might want to try downgrading your firebase_auth version and see if that helps. Are you able to share a simplified version of your app that just has the create-event bloc and form or is it too much of a pain?
Well I was trying to avoid making a sample app due to time constraints.
Later tonight I will try to downgrade the auth version n see if that works.
Otherwise I will try to make a demo app.
Thanks
On Tue, Apr 9, 2019, 10:30 AM Felix Angelov <[email protected] wrote:
@Sourabhlpu https://github.com/Sourabhlpu I saw the stackoverflow post
and I'm not sure what the problem is but it happened to me as well.You might want to try downgrading your firebase_auth version and see if
that helps. Are you able to share a simplified version of your app that
just has the create-event bloc and form or is it too much of a pain?β
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/felangel/bloc/issues/202#issuecomment-481102614, or mute
the thread
https://github.com/notifications/unsubscribe-auth/AQ2HyQQvPRMS8BmQoxGjBnQSousDnXsAks5vfB52gaJpZM4cgZIP
.
Okay if it's too much work let me know and I will try to remove the authentication from the current implementation so that I can debug the bloc. π
Thanks i will look into it after 8-9 hours n let u know
On Tue, Apr 9, 2019, 10:35 AM Felix Angelov <[email protected] wrote:
Okay if it's too much work let me know and I will try to remove the
authentication from the current implementation so that I can debug the
bloc. πβ
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/felangel/bloc/issues/202#issuecomment-481103388, or mute
the thread
https://github.com/notifications/unsubscribe-auth/AQ2HyRnrVjqy6110VwbJ6SHDXmkLGLIqks5vfB-FgaJpZM4cgZIP
.
Hi,
I fixed the issue with the login. I just had to change the restrictions on
my api key from google developers console.
You should be able to login now. You don't have to create a new account. I
will just email u my credentials.
Thanksπ
On Tue, Apr 9, 2019, 10:37 AM Sourabh Pal
Thanks i will look into it after 8-9 hours n let u know
On Tue, Apr 9, 2019, 10:35 AM Felix Angelov <[email protected]
wrote:Okay if it's too much work let me know and I will try to remove the
authentication from the current implementation so that I can debug the
bloc. πβ
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/felangel/bloc/issues/202#issuecomment-481103388, or mute
the thread
https://github.com/notifications/unsubscribe-auth/AQ2HyRnrVjqy6110VwbJ6SHDXmkLGLIqks5vfB-FgaJpZM4cgZIP
.
@Sourabhlpu I just tried running your app on Android and now I'm getting an error:
Failure
[INSTALL_FAILED_INSUFFICIENT_STORAGE]
Error launching application on Android SDK built for x86.
Have you been able to put together a sample app? It would make it much easier for me to help. Let me know π
Thanks!
Well this is frustrating. I will make the demo app later tonight.
Thanks
On Wed, Apr 10, 2019, 8:11 AM Felix Angelov <[email protected] wrote:
@Sourabhlpu https://github.com/Sourabhlpu I just tried running your app
on Android and now I'm getting an error:Failure
[INSTALL_FAILED_INSUFFICIENT_STORAGE]
Error launching application on Android SDK built for x86.
Have you been able to put together a sample app? It would make it much
easier for me to help. Let me know πThanks!
β
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/felangel/bloc/issues/202#issuecomment-481511242, or mute
the thread
https://github.com/notifications/unsubscribe-auth/AQ2HyXDaQnhwMUQ4mOEVeHk0nrx1irXhks5vfU9GgaJpZM4cgZIP
.
Yeah I'm not sure what's going on. Sorry I haven't had more time to try to make your current app work but I really appreciate you taking the time to make a demo app π
Hopefully it doesn't take up too much of your time.
Thanks!
Please clear the cache or clear some data from your emulator and it should work.
Thanks
I tried on multiple emulators but I will try to clear the cache and let you know if it works.π
Thanks!
Hi Felangel,
You can just replace the _handleHomeScreen method in the main dart file
with the code in the below link replace with this code
https://gist.github.com/Sourabhlpu/cea06b9cf97f3f8310f2f10d0358c9b4
This will take you to the form and you can debug easily.
Thanks
On Wed, Apr 10, 2019, 6:18 PM Felix Angelov <[email protected] wrote:
I tried on multiple emulators but I will try to clear the cache and let
you know if it works.πThanks!
β
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/felangel/bloc/issues/202#issuecomment-481676517, or mute
the thread
https://github.com/notifications/unsubscribe-auth/AQ2HydBKGbjg221kc-SXIh5CN0jHDAJAks5vfd2ngaJpZM4cgZIP
.
@Sourabhlpu I finally was able to run it!
The issue is you're not passing the props to the superclass in EventTypes.
You need to call super and pass the props otherwise Equatable won't work properly. π
EventTypes({@required this.interestName, @required this.isSelected})
: super([interestName, isSelected]);
Well finally!! Thank you so much time for this. I really appreciate you taking out your time and looking into my code. Just one question, we cannot use built value instead of equatable?
No problem! Sorry it took so long and yeah you can totally use built value. Check out this tutorial for an example π
Most helpful comment
Yes Sure I will do that
On Mon, Apr 8, 2019, 11:30 AM Felix Angelov <[email protected] wrote: