Let’s go step by step — you’ll understand BLoC (Business Logic Component) state management in Flutter clearly and practically with a real example . 🧠What is BLoC? BLoC helps separate your UI (presentation) from your business logic . It follows the principle: UI sends events → BLoC processes them → emits new states → UI rebuilds. So instead of writing logic inside your setState() , you handle logic inside the BLoC , and the UI just listens. ⚙️ Core Concepts Concept Role Example Event Represents what happened (user actions) IncrementEvent , FetchUserEvent State Represents the UI condition CounterInitial , CounterUpdated(5) Bloc Handles logic, maps Events → States CounterBloc BlocProvider Makes a Bloc available to widgets BlocProvider(create: (_) => CounterBloc()) BlocBuilder Rebuilds UI when state changes Updates counter display automatically 🧩 Example: Counter App using BLoC Let’s build a simple counter app using flutter_bloc package. 🪜 Step 1: Add Dependency In pu...
Set up Node.js . On Apple Silicon, the setup is almost the same as Intel, but some tools need ARM64 builds. I'll give you the main methods step by step: ✅ Method 1: Install Node.js with Homebrew (simple & recommended) Install Homebrew (if not already installed): /bin/bash -c " $(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh) " Install Node.js (includes npm): brew install node Verify installation : node -v npm -v You should see versions (e.g., v22.x.x for Node and 10.x.x for npm). ✅ Method 2: Install Node.js using Node Version Manager (nvm) (best for multiple versions) 👉 Recommended if you work on different projects needing different Node versions. Install nvm : curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bash Load nvm (add this to your ~/.zshrc or ~/.bashrc ): export NVM_DIR= " $HOME /.nvm" [ -s " $NVM_DIR /nvm.sh" ] && \. " $NVM_DIR...