📱

Flutter Beginner Course - Lecture Notes

Jul 26, 2024

Flutter Beginner Course

Introduction

  • Instructor: Mitch
  • Objective: Teach absolute beginners how to create beautiful apps with Flutter.
  • Prerequisites: No prior programming experience needed, but Flutter should be installed on your computer.
  • Course Outline:
    1. Basics of programming fundamentals
    2. Essential Flutter widgets
    3. Navigation between screens
    4. Stateless vs Stateful widgets
    5. Handling user input
    6. Building a to-do app
    7. Saving data in local storage
    8. Building an e-commerce app with advanced UI functionality

General Tips

  1. Utilize the internet for learning and problem-solving.
  2. Practice coding consistently to understand nuances.

Basics of Programming Fundamentals

  • Main Function: The entry point of any application.
  • Variables:
    • String: Holds text (e.g. String name = "Mitch").
    • Int: Holds whole numbers (e.g. int age = 27).
    • Double: Holds numbers with decimals (e.g. double pi = 3.14).
    • Boolean: Represents true/false values (e.g. bool isBeginner = true).
  • Basic Operators:
    • Math: +, -, *, /, %
    • Comparison: ==, !=, >, <, >=, <=
    • Logical: && (and), || (or), ! (not)
  • Control Flow:
    • If Statements: Execute code based on a condition.
    • Loops:
      • For Loop: Iterate a set number of times.
      • While Loop: Continue iterating based on a condition.
  • Functions/Methods:
    • Void: Does not return a value.
    • Return Types: Functions that return a value (e.g. int add(int a, int b)).*

Important Data Structures

  • List: Ordered collection, allows duplicates (e.g. List<int> numbers = [1, 2, 3]).
  • Set: Unordered collection of unique elements (e.g. Set<String> names = {'Mitch', 'Sharon'}).
  • Map: Key-value pairs (e.g. Map<String, int> user = {'age': 27, 'height': 180}).

Introduction to Widgets in Flutter

  • MaterialApp: The main widget starting point.
  • Scaffold: Provides a framework to implement the basic visual layout structure.
  • Container: Basic building block for UI layout.
  • Text: For displaying text.
  • Icon: For displaying icons.
  • Column & Row: For vertical and horizontal layouts respectively.
  • ListView: Scrollable list of widgets.
  • GridView: Grid layout.
  • Stack: Positions widgets on top of each other.
  • GestureDetector: Detects gestures like taps.

Navigation in Flutter

  • Navigator: Manages routes and pages.
    • Push Named: Navigate using named routes.
    • Drawer: Sidebar for navigation.
    • Bottom Navigation Bar: Navigation bar at the bottom of the app.

Building a Counter App

  • Stateful vs Stateless Widgets: Stateful widgets can change state (data displayed), stateless widgets cannot.
  • Increment Counter Example: Basic app to increment a counter using StatefulWidget.

Building a To-Do App

  • TextField: For user input.
  • Text Editing Controller: Accesses text from the TextField.
  • ListView.builder: Dynamically generates a list of to-do items.
  • Checkbox: For indicating task completion.
  • State Management: Set state to refresh UI.
  • Hive: Local database for data persistence.

Building an E-commerce App

  • Introduction Page: Initial landing page with logo and start button.
  • Home Page: Shop and cart navigation using GoogleNavBar.
  • Models: Shoes and cart defined as data models.
  • Provider: State management package for handling data state across the app.
  • Cart functionality: Adding/removing items from the cart.

Final Thoughts

  • Practice Consistently: Code daily to develop your skills.
  • Start Small, Build Up: Collect small wins, aim for achievable challenges.
  • Effective Learning: Be self-motivated, use the internet and AI for problem-solving.
  • Continue Learning: Follow related content and stay curious.