Basic Flutter Interview Questions

 1. What is Flutter?

Answer: Flutter is a UI toolkit created by Google that helps developers build high-performance, cross-platform mobile apps using a single codebase. It uses the Dart programming language and comes with a variety of widgets for creating beautiful and responsive user interfaces.

2. What are widgets in Flutter?

Answer: Widgets are the basic building blocks of Flutter apps. They represent UI elements like buttons, text fields, images, and more. Flutter’s widget-based structure makes it easy to create complex and customizable interfaces.

3. Explain the difference between Stateless and Stateful widgets.

Answer:

  • Stateless widgets: These widgets don’t change over time. They are fixed and used for simple UI elements that don’t need to update.
  • Stateful widgets: These widgets can change their state, allowing for dynamic updates and user interactions. They are used for more complex elements that need to respond to user input or changes in data.
4. How does Flutter differ from other mobile app frameworks like React Native?

Answer: Flutter differs from React Native in a few key ways:

  • Rendering engine: Flutter has its own rendering engine (Skia), while React Native uses the native platform’s engine.
  • Widget library: Flutter offers a more extensive and customizable widget library.
  • Performance: Flutter often has better performance because it directly renders to the platform.
5. What is the role of Dart in Flutter?

Answer: Dart is the programming language used for building Flutter apps. It is modern and object-oriented, featuring asynchronous programming, strong typing, and hot reload capabilities.

6. What are keys in Flutter?

Answer: Keys are used to uniquely identify widgets within a widget tree. They help Flutter efficiently update and reuse widgets when the UI changes.

7. Explain the main() function in Flutter.

Answer: The main() function is the starting point of a Flutter app. It creates a runApp() widget, which is the root widget of the app’s widget tree.

8. What is the purpose of pubspec.yaml?

Answer: The pubspec.yaml file is a configuration file that outlines the dependencies and metadata for a Flutter project. It specifies the project’s name, version, and the external packages used.

9. What is a Scaffold widget in Flutter?

Answer: A Scaffold widget provides a basic structure for a Flutter app, including an app bar, drawer, floating action button, and a body where other widgets can be placed.

10. What are hot reload and hot restart in Flutter?

    Answer:

    • Hot reload: This feature lets developers see changes in their app immediately without restarting the whole app. It speeds up development and debugging.
    • Hot restart: This feature restarts the app but keeps the current state. It’s helpful when you need to reload everything while retaining the current data.

    Intermediate Flutter Interview Questions

    1. Explain the Flutter build process.

    Answer: The Flutter build process involves these steps:

    • Compilation: Dart code is converted into machine code for the target platform (iOS, Android, or web).
    • Widget tree creation: Flutter builds a tree of widgets based on your app’s code.
    • Layout calculations: Flutter calculates where each widget will be placed on the screen.
    • Painting: The widgets are drawn on the screen using the Skia graphics library.
    2. What is a Future in Dart?

    Answer: A Future in Dart represents a value that will be available at some point. It’s commonly used for asynchronous tasks, like fetching data from the internet or reading files.

    3. What are Streams, and how do they work in Flutter?

    Answer: A Stream in Dart is a sequence of data that can be sent over time. It’s useful for handling real-time updates, like data from a server. In Flutter, you can use StreamBuilder widgets to listen to streams and update the UI as new data comes in.

    4. How do you manage state in Flutter?

    Answer: Flutter provides several ways to manage state:

    • Stateful widgets: For managing state within a single widget.
    • Provider: A popular solution that uses dependency injection to share data across the app
    • BLoC (Business Logic Component): A pattern that separates UI from business logic for cleaner code.
    • Riverpod: A newer solution that offers a simpler and type-safe approach to state management.
    5. What is Provider in Flutter, and how does it work?

    Answer: Provider is a state management library that makes data accessible throughout your app without needing to pass it down through each widget. It uses dependency injection to provide data to other widgets easily.

    6. Explain the difference between FutureBuilder and StreamBuilder.

    Answer:

    • FutureBuilder: Used to build UI based on a single future value.
    • StreamBuilder: Used to build UI based on a stream of data, allowing for real-time updates.
    7. How do you navigate between pages in Flutter?

    Answer: Flutter uses the Navigator widget for navigation. You can use methods like pushNamed() to go to a new page and pop() to return to the previous one.

    8. How do you create custom widgets in Flutter?

    Answer: To create a custom widget, extend either StatelessWidget or StatefulWidget, and override the build() method to define how the widget looks.

    9. What is the purpose of the ‘Navigator’ widget?

    Answer: The Navigator widget manages the navigation stack in your Flutter app. It keeps track of which page is currently displayed and allows you to switch between different pages.

    10. How do you handle user input in Flutter?

    Answer: Flutter provides various widgets for user input, such as:

    • TextField: For entering text.
    • Checkbox: For selecting true or false.
    • RadioListTile: For choosing one option from several.
    • DropdownButton: For selecting a value from a list.

    You can use event handlers like onChanged to capture user input and update the app’s state.

    Advanced Flutter Interview Questions

      1. How do you optimize the performance of a Flutter app?

      Answer: To optimize your Flutter app’s performance, you can:

      • Minimize widget rebuilds: Use const constructors for widgets that don’t change, and avoid unnecessary rebuilds.
      • Optimize layouts: Use efficient layout widgets and keep layouts simple.
      • Reduce image size: Compress images and choose the right formats.
      • Use async operations: Move heavy tasks to separate threads to keep the UI smooth.
      • Profile your app: Use Flutter’s tools to find and fix performance issues.
      2. What is the difference between runApp() and build() in Flutter?

      Answer:

      • runApp(): This function starts the Flutter app and creates the main widget tree.
      • build(): This method is called to render the widget’s UI. You override it in StatelessWidget and StatefulWidget to define how the widget looks.
      3. How does Flutter handle gestures?

      Answer: Flutter has gesture detectors that recognize different actions like taps, swipes, and drags. You can combine these detectors to create more complex interactions.

      4. What is the Flutter BLoC pattern?

      Answer: The BLoC (Business Logic Component) pattern is a way to separate the UI from the business logic in Flutter. It makes the code easier to maintain and test by keeping concerns separate.

      5. Explain the concept of ‘inherited widget’ in Flutter.

      Answer: Inherited widgets let you share data down the widget tree without passing it to each widget as an argument. This is useful for data that many widgets need access to.

      6. What is the role of the ‘BuildContext’?

      Answer: The BuildContext provides information about a widget’s position in the widget tree. It helps access themes, localization, and other important data.

      7. How do you implement animations in Flutter?

      Answer: Flutter offers a robust animation system that lets you create:

      • Tween animations: Animate values between two points.
      • Curve animations: Control how animations speed up or slow down.
      • Physics-based animations: Create realistic movements using physics.
      8. What are Slivers in Flutter?

      Answer: Slivers are special widgets for creating custom scrollable layouts. They help build flexible UI components like app bars, footers, and drawers.

      9. Explain platform channels in Flutter.


      Answer: Platform channels let Flutter communicate with native code on iOS or Android. They enable access to features that aren’t available in Flutter.

      10. How do you debug a Flutter application?


      Answer: Flutter offers several debugging tools:

      • Debugger: Step through code, set breakpoints, and check variables.
      • Hot reload: See changes instantly without restarting the app.
      • Performance profiling: Measure performance and find issues.
      • Logcat: View logs from the device.
      • Flutter Inspector: Visualize the widget tree and inspect widget properties.

        Behavioral and Problem-Solving Questions

        1. Describe a challenging Flutter project you worked on. How did you overcome the challenges?

        Answer: Talk about a specific project where you faced a major challenge. Explain the steps you took to overcome it, like doing research, collaborating with your team, or looking for help online. Focus on your problem-solving skills and how you remained determined.

        2. How do you stay updated with the latest trends and updates in Flutter?

        Answer: Share how you keep yourself informed, such as reading Flutter blogs, subscribing to newsletters, attending conferences, or working on open-source projects. Emphasize your commitment to continuous learning and adapting to new technologies.

        3. Can you explain a time when you optimized the performance of a Flutter app?

        Answer: Provide an example where you found a performance issue and improved the app’s speed or responsiveness. Describe the techniques you used, like reducing widget rebuilds or optimizing layouts, and how these changes enhanced the user experience.

        4. What are the most common mistakes developers make in Flutter, and how do you avoid them?

        Answer: Discuss common issues like performance problems, memory leaks, or poor state management. Explain how you avoid these mistakes by following best practices, using code analysis tools, and conducting regular code reviews.

        5. How do you approach debugging and fixing bugs in a Flutter app?

        Answer: Describe your step-by-step approach to debugging, which includes using debugging tools, checking logs, and isolating the root cause of the problem. Talk about how you break down complex issues into smaller parts and stay persistent in finding solutions.

        6. Have you contributed to any open-source Flutter projects?

        Answer: If you have, describe your experiences and the contributions you made. Highlight the benefits of open-source work, like learning from others, helping the community, and improving your skills.

        7. How do you prioritize feature development in a Flutter app?

        Answer: Explain how you prioritize features by considering user needs, business goals, and technical feasibility. Discuss how you balance the need for quick development with the importance of maintaining quality and ensuring long-term maintainability.

        8. Can you describe a time when you disagreed with a team member about an approach to solving a Flutter-related issue?

        Answer: Share a situation where you disagreed with a team member. Explain how you addressed the disagreement, communicated openly, and worked towards a solution that benefited the project. Highlight your ability to collaborate and find common ground.

        9. What’s your experience working with Firebase in Flutter apps?

        Answer: Discuss your experience with Firebase, mentioning specific features you’ve used, like authentication or databases. Share any challenges you faced and how you overcame them.

        10. How do you handle app performance when dealing with large amounts of data in Flutter?

        Answer: Explain your strategies for improving app performance with large datasets, such as using pagination, caching, or efficient data structures. Discuss your experience with performance testing and optimization tools.

          Scenario-Based Flutter Questions

          1. How would you implement lazy loading in Flutter?

          Answer: I would use the ListView.builder widget to create a list that loads items as the user scrolls. I’d fetch data in batches from a network or database and add it to the list as needed. This helps improve performance by avoiding loading all data at once.

          2. How would you integrate REST APIs into a Flutter app?

          Answer: I would use the http package to make requests to the REST API. I’d handle different response codes and errors properly. For authentication, I could use methods like OAuth or API keys. To manage the data, I might use a state management solution like Provider or BLoC.

          3. What would you do if an animation wasn’t working as expected in Flutter?

          Answer: First, I would check the animation code for issues, such as incorrect timing or settings. I would use debugging tools to visualize the animation and go through the code step-by-step. If problems continued, I would simplify the animation or look for troubleshooting tips online.

          4. How would you handle network connectivity issues in a Flutter app?


          Answer: I would use the Connectivity plugin to monitor the network status and show messages or loading indicators as needed. I’d implement retry logic for failed network requests and add offline capabilities if required.

          5. How do you deal with app crashes or unexpected behavior in Flutter?

          Answer: I would use Flutter’s error handling features, like try-catch blocks and ErrorWidgets. I’d also enable crash reporting tools to gather information about errors and spot patterns. For debugging, I would use the Flutter debugger and log messages.

          6. What steps would you take to internationalize a Flutter app?

          Answer: I would use Flutter’s MaterialLocalizations and Globalizations classes to manage different languages. I would create specific files for strings, images, and resources for each language. Additionally, I’d handle date and number formatting based on different cultures.

          7. How would you implement dark mode in a Flutter application?

          Answer: I would use the ThemeData class to define themes for both light and dark modes. I’d use the Theme widget to apply the correct theme based on the user’s preferences or system settings, ensuring that the app’s UI elements are easy to see in both modes.

          8. How would you secure a Flutter app?

          Answer: I would follow security best practices like:

          • Using HTTPS for secure network communication.
          • Validating user input to avoid attacks.
          • Storing sensitive data securely with encryption.
          • Implementing strong authentication and authorization.
          • Regularly updating dependencies to fix security issues.
          9. How would you use platform-specific features in a Flutter app?

          Answer: I would use platform channels to communicate with native code and access features like the camera or GPS. I’d carefully consider the balance between using cross-platform features and needing specific native functionality.

          10. How do you handle version control and code review when working on a Flutter team?

          Answer: I would use a version control system like Git to track changes and work with my team. I’d follow set strategies for branching and merging. I would also take part in code reviews to maintain code quality and consistency.

          Top 50 Flutter Interview Questions and Answers for Freshers

          1. What is Flutter?

          Flutter is an open-source UI toolkit developed by Google that allows you to build natively compiled applications for mobile, web, and desktop from a single codebase. It uses the Dart programming language and provides a rich set of pre-designed widgets to create beautiful and responsive user interfaces.

          Key Points:

          • Single codebase for multiple platforms.
          • Uses Dart language.
          • Provides a large collection of ready-to-use widgets. 
          • Supports hot reload for faster development.

          Example:

          2. What is Dart in Flutter?

          Dart is the programming language used by Flutter. It is object-oriented, strongly typed, and optimized for building user interfaces. Dart supports both Just-In-Time (JIT) compilation, which allows hot reload during development, and Ahead-Of-Time (AOT) compilation, which produces high-performance native code for release builds.

          Key Points:

          • Developed by Google.
             
          • Used for Flutter app development.
             
          • Supports hot reload for faster development.
             
          • Provides features like async-await, null safety, and strong typing.
             

          Example:

          void main() {

            String name = "Rajan";

            print("Hello, $name!");

          }

          3. What are widgets in Flutter?

          Widgets are the basic building blocks of a Flutter app. Everything in Flutter, including text, buttons, images, layouts, and containers, is a widget. Widgets define the structure, layout, and appearance of the user interface. They can be Stateless (do not change over time) or Stateful (can change when the app state changes).

          Key Points:

          • Everything in Flutter is a widget.
             
          • Widgets define the UI and behavior.
             
          • StatelessWidget: Displays static content.
             
          • StatefulWidget: Can update dynamically using setState().
             

          Example:

          4. Difference between StatefulWidget and StatelessWidget

          StatelessWidget:

          • Cannot change its state once built.
             
          • Ideal for static UI elements like text, icons, or images.
             
          • Does not use setState().
             

          StatefulWidget:

          • Can change its state dynamically.
             
          • Ideal for interactive UI elements like forms, buttons, or animations.
             
          • Uses setState() to update the UI when data changes.

          5. What is the difference between hot reload and hot restart?

          Hot Reload:

          • Updates the app’s UI instantly without losing the current state.
             
          • Very fast and useful during development.
             
          • Only updates changed code.
             

          Hot Restart:

          • Restarts the app completely from the beginning.
          • Resets all states to initial values.
          • Slower than hot reload.

          6. What is the difference between mainAxisAlignment and crossAxisAlignment?

          • mainAxisAlignment: Aligns widgets along the main axis (row → horizontal, column → vertical).
             
          • crossAxisAlignment: Aligns widgets along the cross axis (opposite of main axis).
             

          Example:

          7. What is the difference between Expanded and Flexible?

          Expanded:

          • Takes up all the available space.
             
          • Child widget expands fully to fill the parent.
             
          • Ideal when you want the widget to occupy remaining space.
             

          Flexible:

          • Takes up space based on flex factor.
             
          • Child widget can be smaller than available space if needed.
             
          • Provides more control than Expanded.

          8. What is the difference between Container and SizedBox?

          Container:

          • A versatile widget used for layout, styling, padding, margin, and decoration.
             
          • Can contain child widgets.
             
          • Can have background color, borders, shadows, and more.
             
          • Slightly heavier because of extra properties.
             

          SizedBox:

          • A lightweight widget used to give fixed width and height.
             
          • Can contain a child widget, but mainly used for spacing.
             
          • Does not have decoration or padding.

          9. What is a Flutter package?

          A Flutter package is a reusable library that provides additional functionality for your app. Packages can include widgets, tools, APIs, or utilities that help you save time and avoid writing code from scratch. Flutter packages are managed through pub.dev and added to your project via the pubspec.yaml file.

          Key Points:

          • Packages provide ready-to-use functionality.
             
          • Can be official Flutter packages or community packages.
             
          • Managed using pubspec.yaml and pub get command.
             

          Example: Adding the http package for API calls:

          10. How do you navigate between screens in Flutter?

          In Flutter, navigation between screens (pages) is done using the Navigator widget. The Navigator manages a stack of routes, where you can push a new screen onto the stack or pop back to the previous screen.

          Example: Navigate to a new screen

          Example: Go back to previous screen

          11. What is Flutter’s build method?

          The build() method in Flutter is used to describe how to display a widget in the user interface. It is called every time the widget needs to be rendered or updated, such as after calling setState() in a StatefulWidget. The method returns a widget tree, which Flutter uses to render the UI on the screen.

          12. What is initState() in StatefulWidget?

          initState() is called once when a StatefulWidget is inserted in the widget tree. It is used to initialize data, fetch APIs, or set up listeners.

          Example:

          @override

          void initState() {

            super.initState();

            fetchData();

          }

          13. What is setState()?

          In Flutter, setState() is a method used in a StatefulWidget to update the state of the widget and rebuild the UI. When the state changes, calling setState() tells Flutter that it needs to re-render the widget with the new data.

          14. What is the difference between hot reload and rebuild?

          Hot Reload:

          • Updates the app’s UI instantly without losing the current state.
             
          • Only updates the changed code.
             
          • Very fast and useful during development.
             

          Rebuild:

          • Happens when setState() is called in a StatefulWidget.
             
          • Only the specific widget where state changes is rebuilt.
             
          • Preserves other parts of the UI that did not change.

          15. What is the difference between const and final?

          const:

          • Value is known at compile-time.
             
          • Cannot change anywhere in the program.
             
          • Must be assigned immediately.
             

          final:

          • Value is set only once at runtime.
             
          • Can be assigned dynamically but cannot be changed afterward.
             

          16. What is Flutter’s widget tree?

          In Flutter, the widget tree is a hierarchical structure of widgets that represents the app’s user interface. Every widget in Flutter is a node in this tree, and widgets can have child widgets, forming a nested structure. Flutter uses this tree to render the UI efficiently and handle updates when the state changes.

          17. What is MaterialApp in Flutter?

          MaterialApp is the root widget for a Flutter application that follows Material Design guidelines. It provides important functionalities like navigation, theming, localization, and app structure. Almost every Flutter app uses MaterialApp as the top-level widget.

          Key Points:

          • Sets up Material Design theme for the app.
             
          • Provides navigation and routing using Navigator.
             
          • Supports localization and debug settings.
             
          • Acts as the entry point for most Flutter apps.

          Example:

          MaterialApp(

            title: "My App",

            home: HomeScreen(),

          )

          18. What is Scaffold in Flutter?

          Scaffold is a layout structure widget in Flutter that provides a basic visual framework for building an app. It helps you add common Material Design elements like AppBar, Drawer, FloatingActionButton, BottomNavigationBar, and more.

          Key Points:

          • Provides a basic structure for the app screen.
             
          • Supports AppBar, Body, Drawer, FloatingActionButton, and BottomNavigationBar.
             
          • Makes it easy to create a consistent UI across screens.

          19. What is the difference between main.dart and lib folder?

          main.dart:

          • It is the entry point of the Flutter app.
             
          • Contains the main() function, where the app starts running.
             
          • Typically initializes MaterialApp or CupertinoApp.
             

          lib folder:

          • Contains all Dart code and widgets for the app.
             
          • You can organize your app into multiple Dart files here.
             
          • Helps keep code modular and maintainable.

          20. What is a Stream in Flutter?

          A Stream in Flutter is a sequence of asynchronous events. It is used to receive data over time, such as updates from a server, user input, or real-time database changes. Streams are especially useful when you want to listen to data that changes continuously.

          Example:

          21. What is Future in Flutter?

          A Future in Flutter represents a single asynchronous result that will be available later. It is commonly used for operations like API calls, reading files, or database queries where the result is not available immediately.

          Example:

          22. What is the difference between FutureBuilder and StreamBuilder?

          FutureBuilder:

          • Handles a single asynchronous value that will be available once.
             
          • Commonly used for API calls or one-time database queries.
             
          • Rebuilds the widget when the Future completes.
             

          StreamBuilder:

          • Handles multiple asynchronous values over time.
             
          • Ideal for real-time data like live feeds, notifications, or Firebase streams.
             
          • Rebuilds the widget every time new data is emitted from the stream.

          23. What is Provider in Flutter?

          Provider is a state management solution in Flutter that allows you to share data across widgets efficiently without passing it manually through constructors. It makes managing app state simpler and helps build scalable applications.

          24. What is Bloc in Flutter?

          Bloc (Business Logic Component) is a state management pattern in Flutter that helps separate business logic from the UI layer. It uses streams to manage state changes and ensures a reactive and predictable application.

          Key Points:

          • Helps separate UI and business logic.
             
          • Uses events to trigger changes and states to update the UI.
             
          • Works with Stream to make apps reactive.
             
          • Ideal for large and complex applications.
             

          Example:

          25. What is GetX in Flutter?

          GetX is a lightweight and powerful state management, dependency injection, and route management solution in Flutter. It helps developers manage state, navigation, and dependencies easily without boilerplate code.

          Key Points:

          • Provides reactive state management.
             
          • Simplifies navigation and routing.
             
          • Supports dependency injection for better code organization.
             
          • Very lightweight and easy to use for small and large apps.
             

          Example:

          26. What is the difference between hot reload and hot restart in Flutter?

          Hot Reload:

          • Updates the app’s UI instantly without losing the current state.
             
          • Only updates the changed code.
             
          • Very fast and useful for quick UI changes during development.
             

          Hot Restart:

          • Restarts the app completely from the beginning.
             
          • Resets all states to initial values.
             
          • Slower than hot reload but useful when state or app initialization changes.

          27. What is the difference between ListView and GridView?

          ListView:

          • Displays items in a single column (vertical) or row (horizontal).
             
          • Ideal for simple linear lists.
             
          • Supports scrolling, separators, and dynamic item building.
             

          GridView:

          • Displays items in a grid layout (rows and columns).
             
          • Ideal for photo galleries, product lists, or dashboards.
             
          • Supports fixed or dynamic column count.
             

          28. What is the difference between SingleChildScrollView and ListView?

          SingleChildScrollView:

          • Can have only one child widget.
             
          • Useful for scrollable content that does not have many items.
             
          • Does not support lazy loading (renders all content at once).
             

          ListView:

          • Can have multiple child widgets.
             
          • Designed for long lists and supports lazy loading with ListView.builder.
             
          • More efficient for large or dynamic data.
             

          29. What is SafeArea in Flutter?

          SafeArea is a widget in Flutter that adds padding to your app content to avoid system UI elements like the status bar, notch, or navigation bar. It ensures that important UI elements are not hidden or overlapped on different devices.

          Example:

          30. What is Hero animation in Flutter?

          Hero animation in Flutter is a pre-built animation that allows a widget to transition smoothly between two screens. It creates a shared element animation, where a widget “flies” from one screen to another during navigation.

          Example:

          31. What is the difference between Stack and Positioned?

          Stack:

          • A widget that allows children to overlap each other.
             
          • Useful for layered UI designs like banners or cards.
             
          • Children are stacked in order.
             

          Positioned:

          • Used inside a Stack to position a child at a specific location.
             
          • Supports top, bottom, left, right properties.
             
          • Cannot be used outside a Stack.

          32. What is the difference between Column and Row?

          Column:

          • Arranges children vertically (top to bottom).
             
          • Main axis is vertical, cross axis is horizontal.
             
          • Useful for stacking widgets vertically.
             

          Row:

          • Arranges children horizontally (left to right).
             
          • Main axis is horizontal, cross axis is vertical.
             
          • Useful for placing widgets side by side.

          33. What is a Theme in Flutter?

          A Theme in Flutter is used to define the visual appearance of an app, including colors, fonts, and styles. It helps to maintain consistency across all screens and widgets.

          Key Points:

          • Centralizes colors, text styles, and widget appearances.
             
          • Can be applied globally using ThemeData in MaterialApp.
             
          • Supports light and dark themes.
             

          Example:

          34. How do you make responsive UI in Flutter?

          Responsive UI can be made using:

          • MediaQuery for screen width/height.
             
          • LayoutBuilder for adaptive layouts.
             
          • Flexible and Expanded widgets.
             

          35. What is the difference between hot reload and state restoration?

          Hot Reload:

          • Updates the app’s UI instantly during development.
             
          • Keeps the current state of the app unchanged.
             
          • Only available while running the app in debug mode.
             

          State Restoration:

          • A feature that saves and restores app state even after the app is terminated or restarted.
             
          • Ensures users return to the same screen or data when reopening the app.
             
          • Useful for production apps to improve user experience.

          36. What is the difference between pubspec.yaml and packages?

          pubspec.yaml:

          • A configuration file in a Flutter project.
             
          • Specifies project metadata like name, version, dependencies, assets, and fonts.
             
          • Required for managing packages and project settings.
             

          Packages:

          • Reusable libraries or plugins that add functionality to your app.
             
          • Can be official Flutter packages or community packages from pub.dev.
             
          • Added in pubspec.yaml under dependencies.

          37. What is the difference between async and await in Dart?

          In Dart, async and await are used for asynchronous programming, allowing you to run tasks without blocking the UI.

          async:

          • Marks a function as asynchronous, meaning it can perform time-consuming operations like API calls.
             
          • Returns a Future.
             

          await:

          • Pauses the execution of an async function until the Future completes.
             
          • Used inside an async function.

          38. What is Flutter’s rendering process?

          Flutter’s rendering process is how the framework draws widgets on the screen. It involves several steps, starting from widgets and ending with pixels on the screen.

          Key Steps:

          1. Widget Layer: Developers create widgets (Stateless or Stateful) that describe the UI.
             
          2. Element Layer: Each widget creates an element that connects the widget to the render tree.
             
          3. Render Object Layer: The render objects calculate layout and painting of each widget.
             
          4. Painting & Compositing: Flutter paints pixels on the screen using the Skia graphics engine.

          39. What is the difference between hot reload and hot restart?

          Hot Reload:

          • Updates the UI instantly while the app is running in debug mode.
             
          • Keeps the current state of the app intact.
             
          • Useful for quick UI changes during development.
             

          Hot Restart:

          • Restarts the entire app from the beginning.
             
          • Resets all state and variables to their initial values.
             
          • Useful when state or initialization logic changes.

          40. What is the difference between Navigator.push and Navigator.pushReplacement?

          In Flutter, Navigator is used for screen navigation. Both push and pushReplacement navigate to a new screen, but they behave differently in terms of the navigation stack.

          Navigator.push:

          • Adds a new screen on top of the current screen.
             
          • You can go back to the previous screen using Navigator.pop().
             
          • Keeps the previous screen in the stack.
             

          Navigator.pushReplacement:

          • Replaces the current screen with a new one.
             
          • You cannot go back to the previous screen.
             
          • Removes the current screen from the stack.

          41. What is the difference between Positioned.fill and Align?

          Both Positioned.fill and Align are used to position widgets, but they work differently:

          Positioned.fill:

          • Used inside a Stack to make a widget fill the entire Stack or match its parent’s size.
             
          • Can be combined with padding to adjust edges.
             
          • Only works inside Stack.
             

          Align:

          • Positions a widget within its parent using an alignment property like Alignment.center or Alignment.topRight.
             
          • Works outside Stack and doesn’t require filling the parent.
             
          • Adjusts the widget’s position without stretching it.

          42. What is flutter doctor?

          flutter doctor is a command-line tool in Flutter that helps you check the setup and environment of your Flutter development system. It identifies missing dependencies, SDKs, or tools required to run Flutter apps.

          Key Points:

          • Checks for Flutter SDK, Dart SDK, IDEs, and connected devices.
             
          • Provides a summary of issues and suggestions to fix them.
             
          • Helps ensure your development environment is ready.

          43. What is Flutter’s render tree?

          The render tree in Flutter is the internal structure that Flutter uses to draw widgets on the screen. It is created from the widget tree and contains RenderObjects that handle layout, painting, and compositing.

          44. What is the difference between GestureDetector and InkWell?

          GestureDetector:

          • Detects gestures like tap, double tap, long press, swipe, and more.
             
          • Does not provide visual feedback when tapped.
             
          • Can be used anywhere, including custom widgets.
             

          InkWell:

          • Detects tap gestures and provides ripple effect as visual feedback.
             
          • Must be used inside Material widgets.
             
          • Ideal for buttons and clickable cards.

          45. What is the difference between Future and Stream in Flutter?

          Future:

          • Represents a single asynchronous value.
             
          • Completes once and then returns the result or error.
             
          • Commonly used for API calls or one-time data fetching.
             

          Stream:

          • Represents multiple asynchronous values over time.
             
          • Can emit data continuously, like a live feed or notifications.
             
          • Used with StreamBuilder to update UI automatically.

             

          46. How to call APIs in Flutter?

          In Flutter, APIs are called using HTTP requests to fetch or send data from a server. The http package is commonly used for making API calls.

          Key Points:

          Use the http package for GET, POST, PUT, DELETE requests.
          Handle asynchronous requests using async and await.
          Parse the response, usually in JSON format, to use in your app.
          Example:

          47. How to handle JSON in Flutter?

          Use dart:convert to decode and encode JSON

          In Flutter, JSON data is commonly used when receiving or sending data to APIs. Flutter handles JSON using Dart’s built-in dart:convert library to convert JSON into Dart objects and vice versa.

          Key Points:

          • JSON is handled using jsonDecode() and jsonEncode().
             
          • API responses are usually converted into Dart maps or model classes.
             
          • Model classes make data easier to manage and type-safe.
             

          Example (Decoding JSON):

          48. What is difference between hot reload and rebuild in Flutter?


          Hot Reload:

          • Updates the UI instantly during development.
             
          • Keeps the current app state (like counters or form data).
             
          • Injects updated code into the running app without restarting it.
             
          • Used mainly for fast development and testing.
             

          Rebuild:

          • Happens when Flutter re-runs the build() method of widgets.
             
          • Can occur due to setState(), parent widget changes, or hot reload.
             
          • Updates the UI based on the current state values.

          49. What is difference between async and Future?

          • async: Marks a function asynchronous.
             
          • Future: Represents the result returned in future.
             

          50. How to handle local storage in Flutter?

          In Flutter, local storage is used to save data on the device so it can be accessed later, even after the app is closed. Flutter provides different ways to store data depending on the use case.

          Key Points:

          SharedPreferences: Used for storing small key–value data like login status or theme settings.
          SQLite (sqflite): Used for storing structured and large data in tables.
          Local files: Used for storing text or JSON files on the device.

          How to extract filename from Uri?

          Now, we can extract filename with and without extension :) You will convert your bitmap to uri and get the real path of your file. Now w...