Skip to main content

Posts

Showing posts from February, 2025

GetX State Management Interview Questions

GetX State Management Interview Questions GetX State Management Interview Questions and Answers 1. What is GetX in Flutter? GetX is a lightweight and efficient state management solution for Flutter that provides reactive state management, dependency injection, and routing. 2. How does GetX handle state management? GetX supports reactive state management using Obx and simple state management using GetBuilder . 3. What is the difference between Obx and GetBuilder? Obx is for automatic UI updates with .obs variables, while GetBuilder requires calling update() manually. class CounterController extends GetxController { var count = 0.obs; // Reactive state void increment() => count++; } 4. What are GetxController lifecycle methods? Key methods: onInit() - Called when the controller is created. onReady() - Called after widget is built. onClose...

Navigator 1.0 vs Navigator 2.0 in Flutter

Navigator 1.0 vs Navigator 2.0 in Flutter Navigator 1.0 vs Navigator 2.0 in Flutter 🚀 Introduction Flutter provides two approaches for navigation: Navigator 1.0 (imperative) and Navigator 2.0 (declarative). Let's compare them! 🔹 Navigator 1.0 (Imperative Navigation) Stack-based navigation (push/pop) Simpler API, great for small apps Uses MaterialPageRoute or CupertinoPageRoute Limited support for deep linking Navigator.push( context, MaterialPageRoute(builder: (context) => SecondScreen()), ); 🔹 Navigator 2.0 (Declarative Navigation) Declarative navigation using Router Better for web and deep linking Uses RouteInformationPar...

Implementing in-app turn-by-turn navigation in a Flutter application using Google Maps and the Directions API involves several steps

  1. Integrate Google Maps into Your Flutter App a. Add the  google_maps_flutter  Package: Include the  google_maps_flutter  package in your  pubspec.yaml  file to embed Google Maps into your Flutter application. yaml dependencies: google_maps_flutter: latest_version b. Obtain and Configure Your API Key: Generate an API Key:  Create a project in the  Google Cloud Console , enable the  Maps SDK for Android  and  Maps SDK for iOS , and generate an API key. Configure Android:  Add your API key to the  AndroidManifest.xml  file. Configure iOS:  Add your API key in the  AppDelegate.swift  file. c. Display the Map: Use the  GoogleMap  widget to display the map within your application. #dartcode import 'package:google_maps_flutter/google_maps_flutter.dart'; GoogleMap( initialCameraPosition: CameraPosition( target: LatLng(latitude, longitude), zoom: 14.0, ), onMapCreated: (Goo...

Higher-Order Functions in Dart

Higher-Order Functions in Dart Higher-Order Functions in Dart A Higher-Order Function is a function that either: Takes another function as a parameter. Returns a function. These functions help make code more concise and reusable. 1. Passing a Function as a Parameter You can pass a function as an argument to another function. void greet(String name, Function message) { print("Hello, $name!"); message(); } void sayGoodMorning() { print("Good morning! Have a great day."); } void main() { greet("Alice", sayGoodMorning); } Output: Hello, Alice! Good morning! Have a great day. 2. Returning a Function A function can also return another function. Function multiplier(int n) { return (int x) => x * n; } void main() { var doubleIt = multiplier(2); // Returns a function that multiplies by 2 print(doubleIt(5)); // Output: 10 } ...

Understanding break and continue in Dart

Understanding break and continue in Dart Understanding break and continue in Dart In Dart, break and continue are used within loops to control the flow of execution. Let's explore their use cases with examples. 1. break Statement (Exit the Loop) The break statement is used to immediately terminate a loop when a specific condition is met. Use Case: Exiting a Loop Early Example: Finding a specific number in a list and stopping the loop once found. void main() { List numbers = [1, 2, 3, 4, 5]; for (int num in numbers) { if (num == 3) { print('Found 3, stopping loop.'); break; // Exits the loop when num is 3 } print(num); } } Output: 1 2 Found 3, stopping loop. Use break when you want to exit a loop once a specific condition is met. 2. continue Statement (Skip an Iteration) The continue statement is used to skip the current i...

Comprehensive Dart Tutorial Guide

Comprehensive Dart Tutorial Guide Comprehensive Dart Tutorial Guide Dart is a modern, object-oriented programming language developed by Google, widely used for Flutter app development. This guide covers all essential topics to master Dart. 1. Introduction to Dart What is Dart? Features of Dart Setting up the Dart SDK Writing and running your first Dart program Dart tools (DartPad, CLI, IDE support) 2. Dart Basics Variables and Data Types Constants ( final vs. const ) String Interpolation Type Inference ( var , dynamic , Object? ) 3. Operators in Dart Arithmetic Operators Relational and Logical Operators Bitwise and Assignment Operators Conditional Operators 4. Control Flow Statements Conditional Statements ( if , switch-case ) Loops ( for , whil...

FVM vs Version Control in Flutter

FVM vs Version Control in Flutter FVM vs Version Control in Flutter: A Comprehensive Guide Introduction When working with Flutter, developers often need to manage different versions of Flutter SDKs and collaborate on projects with other developers. Two essential tools that can help in this process are **FVM (Flutter Version Manager)** and **Version Control Systems (VCS)** like **Git**. Though they serve different purposes, both tools are indispensable in managing Flutter projects effectively. 1. FVM (Flutter Version Manager) **FVM** is a tool designed specifically to manage different versions of Flutter SDK. It allows developers to easily switch between Flutter versions based on the project requirements, ensuring that there are no conflicts when using different versions of Flutter on different projects. ...