Skip to content

Saved Counter

You'll build a tally app with one button and one number, then make the number survive a force-quit, a restart and a rotation.

About

The counter is the smallest app that teaches the biggest lesson: the phone will kill your app whenever it feels like it, and anything that only lives in memory goes with it. Your first version will lose the count the moment you swipe it away, and seeing that happen is part of the badge. The fix is the platform's small key-value store (UserDefaults, SharedPreferences or DataStore, or shared_preferences in Flutter), written to every time the number changes. Then you use it to count something real for a week, which is how you find out whether your tap target is big enough for a thumb on a cold morning.

At a glance

Per requirement
15 XP
Completion bonus
75 XP
Requirements
5
Takes
One evening, then a week of use
Skill level
Beginner (done it a few times)
Cost
Free
Supplies
Nothing special
Where
At home
Other people
On your own

Requirements

  1. 1
    Build a counter with one plus button and one big number. Make the number readable from across the room, 60 points or bigger, and give the button a tap target of at least 48 by 48 points, which clears both platforms' minimums (44 on iOS, 48 on Android). Film three taps on your phone. Video
  2. 2
    Swipe the app away and show that the count is gone. Tap to five, open the app switcher, swipe your app off, and open it again. The number is zero. Don't skip this, because the whole badge is about seeing it. Film it. Video
  3. 3
    Save the count so it survives a force-quit. Write the number to the key-value store the moment it changes, not when the app closes, because the closing callback often never runs. Film tapping to seven, swiping the app away, reopening, and seeing seven. Video
  4. 4
    Rotate the phone and show that the number holds and the layout fits. On Android the screen is rebuilt on rotation and a naive counter resets to zero. On an iPhone it usually survives but the layout breaks. Fix whichever one you've got. Take a photo of the app in landscape with the count still showing. Photo
  5. 5
    Add a reset that asks first, then count something real for a week. A reset with no confirmation is how you lose a week's count, so make it ask. Then tally something honest: coffees, push-ups, times you checked the news. Take a photo of the app after seven days with a real number in it, and tell us what you counted. Photo