3. What is Flutter?
â Framework for app and web development
â Code is structured into stateful and
stateless classes
â Apps are composed of widgets
â Language is called Dart
I love the Widget of the Week series!
4. Getting started
â Navigate to the following link: https://github.com/ceh-
2000/paint_drop.git
â Scroll down to the section called âPrerequisitesâ and follow
the steps to install a code editor and Flutter.
5. Flutter Doctor | Path Issues
C:> where flutter dart
Command Prompt â | Powershell đ
(1) Search for âenvâ and select âEdit
environment variables for your
accountâ
(2) User variables â click entry called
âPathâ â Append to the end with â;â:
C:path-to-flutterbin
â ïž Restart terminal after completion!
6. Creating your first app
â Navigate to the following link:
https://github.com/ceh-2000/paint_drop.git
â Scroll down to the section called âCreating
your first appâ and follow the steps to
install a code editor and Flutter.
Your default app should look like this â
8. Question
Suppose I have two phones. One can redraw a star on the screen
every 1 second. The second phone is older and can only redraw a
star on the screen every 2 seconds. We want to make the star look
like itâs moving left to right across the screen. How do we create one
set of logic that works for both phones?
9. Answer
new_position = old_position + speed * dt
Flame (a Flutter game package) gives us the elapsed time (dt)
between frames to compute where we need to put the heart for the
same movement across different devices.
11. Falling stars specifications
â Drop a variable number of spinning
stars from top of screen to bottom
â Stars are draggable horizontally
â Stars cannot be dragged off the screen
â Stars do not rotate when being
dragged
12. Flame inputs
â Drag Events (play around
with the demo in the docs)
â Gesture Input (mouse and
touch pointers)
â Keyboard Input
â Tap Events
â Other Inputs (supports
Joysticks and Gamepads) https://docs.flame-
engine.org/1.6.0/flame/inputs/drag_events.html#demo
13. Mixins â Use mixins to inject code into a
class (to make things draggable)
â Mixin class acts as parent class,
offering the child the desired
functionality
â Key difference between mixins and
inheritance: âchild class can still
inherit all the features of the parent
class, but, the semantics about the
child âbeing a kind ofâ the parent
need not be necessarily appliedâ
(mixin on Wikipedia)
16. Game logic
â Players drag the paint drops above the correct colored buckets.
â Scoring:
â Correct paint drop and bucket = +1
â Incorrect paint drop and bucket = -1
â Possible extensions:
â Make paint drops fall faster over time
â Power-ups that automatically move all paint drops to the
correct place or pause paint drops in the air