0

I am creating a Habit Tracker app in flutter and there two screens in App

Home Screen

In this there is a Horizontal list of dates, a tab bar to add different kind of tasks and a floating button that will navigate to another screen where we will define the Name, Description/Note, and Recurrence of habit

Habit Adding Screen

There we can add habit by giving it the name, description and recurrence (when/On which dates it should be displayed) the Recurrence options that i have given to it are: Once (the habit will show once on the date that the user selected) EveryDay (the habit will show Everday from the date created) Select In Week (the Habit will show every week on the days that the user selected) Select In Month (the habit will show every month on the dates that the user selected) Select In Year (the habit will show every year on the dates that user selected) Select In Range (the user will select a range of dates on which the habit will be displayed)

I have also created an Sqflite database service that stores the habit and sends it to Home screen

Problem

Now the Problem is that when i add habit it is showing in the console (i have added print statements to show it) but the Home screen doesn't show any habit?

I asked ChatGPT and also look some websites and youtube videos but didn't find any solution to this, i just want My app to work with this Recurrence functionality, if you have any other idea of how i can add this type of functionality, You can tell me also

Console Output for the problem added and set to show only once:

Performing hot restart...
Syncing files to device TECNO LD7...
Restarted application in 2,939ms.
I/flutter (31388): Selected Date: 2024年08月20日 00:00:00.000
I/flutter (31388): Items Map: {2024年08月20日 09:55:27.613067: []}
I/flutter (31388): Fetched map: {id: 1724128708944, name: My Habit, description: This is my first Habit, recurrence: Once, dates: ["2024年08月20日T00:00:00.000"]}
I/flutter (31388): Map in fromMap: {id: 1724128708944, name: My Habit, description: This is my first Habit, recurrence: Once, dates: ["2024年08月20日T00:00:00.000"]}
I/flutter (31388): Loaded habits: [Instance of 'Habit']
I/flutter (31388): Selected Date: 2024年08月20日 00:00:00.000
I/flutter (31388): Items Map: {2024年08月20日 00:00:00.000: [Instance of 'Habit']}
I/flutter (31388): Selected Date: 2024年08月20日 00:00:00.000
I/flutter (31388): Items Map: {2024年08月20日 00:00:00.000: [Instance of 'Habit']}

You can clearly see the problem is added to the console but its not showing on the screen

Nipul Rathod
7781 gold badge12 silver badges32 bronze badges
asked Aug 20, 2024 at 5:10
2
  • After you update your state, are you calling setState? Commented Aug 20, 2024 at 5:17
  • Please provide enough code so others can better understand or reproduce the problem. Commented Aug 22, 2024 at 7:49

1 Answer 1

0

I can't go further than guessing the issue without reading the code block, but it seems likely that the issue is related to not updating the state after the fetch is completed.

If so, I highly recommend Interactivity blog post provided by Flutter team.

answered Aug 20, 2024 at 5:21
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.