Create a flutter app to view and save reasonably priced nfts.
Code: https://dartpad.dev/617434e3c0cb99f255fb25a36474a26f?null_safety=true
- Create the Card Layout in the
_buildRow
method - Fix the
onTap
function inGestureDetector
. When the favorite icon is tapped, the icon should change color and the nft should be added/removed from the favourites page
Code: https://dartpad.dev/a5cf4b25be39d476f6fa5ba10be16e40?null_safety=true
- Fetch data using the
_fetchNfts
function
Code: https://dartpad.dev/359e9b3e6cdf145fabe2d7e216583472?null_safety=true
- Extract the code in the
_goToFavourites
method into aFavoritePage
StatelessWidget - Refactor to use the
routes
param for navigation
Flutter is a UI framework for developing cross-platform applications.
You build your UI out of widgets. Widgets describe what the UI should look like.
Code: https://dartpad.dev/cec5855b7ad491ec68368f7526044b90?null_safety=true
Widgets are subclasses of either StatelessWidget or StatefulWidget, depending on whether your widget manages any state. A widget’s main job is to implement a build()
function, which describes the widget in terms of other lower-level widgets.
All widgets fall in one of three categories:
- Layout - E.g.
Column
andRow
widgets which layout other widgets vertically or horizontally. - Painting - E.g.
Text
andImage
widgets allow us to display (‘paint’) some content onto the screen. - Hit-Testing - E.g.
GestureDetector
allows us to recognise different gestures such as tapping and dragging/swiping.
Code: https://dartpad.dev/4dd5c3ec602e6044cb042150c1596808?null_safety=true
These flex widgets let you create flexible layouts in both the horizontal (Row
) and vertical (Column
) directions. The design is based on the web’s flexbox layout model.
Docs: https://flutter.dev/docs/codelabs/layout-basics#axis-size-and-alignment
Row
and Column
first lay out widgets of a fixed size. Fixed size widgets are considered inflexible because they can’t resize themselves after they’ve been laid out.
The Flexible
widget wraps a widget, so the widget becomes resizable.
Docs: https://flutter.dev/docs/codelabs/layout-basics#flexible-widget
The Expanded
widget forces the widget to fill extra space.
Docs: https://flutter.dev/docs/codelabs/layout-basics#expanded-widget
Instead of laying out widgets horizontally or vertically, a Stack
widget lets you place widgets on top of each other.
You can then use the Positioned
widget on children of a Stack
to position them relative to the top, right, bottom, or left edge of the stack. Stacks are based on the web’s absolute positioning layout model.
Code: https://dartpad.dev/a001346f03867f2fa667e3b40af2c05a?null_safety=true
StatefulWidget
and State
are separate objects with different life cycles. Widgets are temporary objects, used to construct a presentation of the application in its current state.
State
objects, are persistent between calls to build()
, allowing them to remember information.
Stateful Widget lifecycle https://stackoverflow.com/questions/41479255/life-cycle-in-flutter
Encoding or serialization means turning a data structure into a string.
Decoding or deserialization means turning a string into a data structure.
Pages are called routes and they're managed by a Navigator
widget.
The navigator manages a stack of Route
objects with the most recently visited pages on top of the stack and the least recently visited page at the bottom of the stack.