Skip to main content

Flutter Interview Questions

 If I use counter not within a class & used in multiple screen then It will be part of app state or not give me ans

ChatGPT said:
ChatGPT

If you use a counter variable not within a class (i.e., as a global variable) and access it across multiple screens, it is not considered part of the app state in a formal sense, unless you are actively managing the state using a state management solution.

Comments

Popular posts from this blog

Referral & Deep linking

  Plugins :  app_links: android_play_install_referrer: Link to share :  https://play.google.com/store/apps/details?id=com.erer&referrer=referral_code%3DTEST123 Flutter Code :  import 'package:app_links/app_links.dart' ; import 'package:android_play_install_referrer/android_play_install_referrer.dart' ; import 'package:flutter/foundation.dart' ; import 'package:shared_preferences/shared_preferences.dart' ; class DeepLinkService {   static const String _referralKey = 'referral_code' ;   static final AppLinks _appLinks = AppLinks ();   static Future < void > initDeepLinks () async {     debugPrint ( 'Initializing deep links...' );     // 1️⃣ Handle real-time deep/link stream     try {       final Uri ? initialUri = await _appLinks . getInitialAppLink ();       if ( initialUri != null ) {         debugPrint ( 'Initial deep link: $initialUri'...

API security best practices

 API with a focus on security best practices : Key Security Practices Included: Input Validation and Sanitization : All inputs are validated and sanitized to prevent SQL injection and other attacks. Prepared Statements : All database queries use prepared statements to avoid SQL injection. Password Hashing : Passwords are hashed using password_hash() and verified using password_verify() . Token-Based Authentication : JSON Web Tokens (JWTs) are used for secure API authentication. Error Hiding : Error details are logged but not exposed to users in production. Strict Content-Type Header : Ensures only JSON payloads are processed. Rate Limiting and Throttling : Optional mechanisms to prevent abuse. Validation for IDs : Integer inputs (like user_id or exam_id ) are explicitly validated.

Native api call flutter in terminated state

Calling Native Android Code from Flutter (Step-by-Step for Beginners) When you need to run platform-specific features (like background services, Bluetooth, or sensors) that Flutter doesn’t handle out of the box, you can use MethodChannels to talk to native Android or iOS code. In this tutorial, we’ll: Create a MethodChannel in Flutter. Set up a foreground service in Android. Trigger that service from Flutter—even when the app is closed. 1. What Is a MethodChannel? Think of a MethodChannel as a telephone line between Flutter (Dart) and the platform’s native code (Java/Kotlin for Android, Swift/Objective-C for iOS). Flutter side: “📞 Hey Android, please start the service!” Android side: “✅ Got it, I’m starting it now.” 2. Create the Channel in Flutter Create a new file: lib/native_service.dart import 'package:flutter/services.dart' ; class NativeService {   // ✅ A generic channel name you can reuse in any project   static const _channel = MethodChanne...