QUICK LINKS

FLUTTER AND DART

 

🔹 1. When to use main Axis Alignment and cross Axis Alignment?

Answer:

For Row:
mainAxisAlignment = Horizontal Axis
crossAxisAlignment = Vertical Axis

For Column:

mainAxisAlignment = Vertical Axis
crossAxisAlignment = Horizontal Axis

Image source

Source: stackoverflow.com   


🔹 2. What is Flutter?

Answer:

Flutter is an open-source UI toolkit from Google for crafting beautiful, natively compiled applications for desktop, web, and mobile from a single codebase. Flutter apps are built using the Dart programming language.

Source: flutter.dev   


🔹 3. What is the difference between Expanded and Flexible widgets?

Answer:

Expanded is just a shorthand for Flexible

Using expanded this way:

Expanded(
	child: Foo(),
);

is strictly equivalent to:

Flexible(
	fit: FlexFit.tight,
	child: Foo(),
);

You may want to use Flexible over Expanded when you want a different fit, useful in some responsive layouts.

The difference between FlexFit.tight and FlexFit.loose is that loose will allow its child to have a maximum size while tight forces that child to fill all the available space.

Source: stackoverflow.com   


🔹 4. What is the pubspec.yaml file and what does it do?

Answer:

  • The pubspec.yaml file allows you to define the packages your app relies on, declare your assets like images, audio, video, etc.
  • It allows you to set constraints for your app.
  • For Android developers, this is roughly similar to a build.gradle file.
Source: medium.com   


🔹 5. Does Flutter work like a browser? How is it different from a WebView based application?

Answer:

To answer this question simply: Code you write for a WebView or an app that runs similarly has to go through multiple layers to finally get executed. In essence, Flutter leapfrogs that by compiling down to native ARM code to execute on both platforms. “Hybrid” apps are slow, sluggish and look different from the platform they run on. Flutter apps run much, much faster than their hybrid counterparts. Also, it’s much easier to access native components and sensors using plugins rather than using WebViews which can’t take full use of their platform.

Source: medium.com   


🔹 6. When should you use WidgetsBindingObserver?

Answer:

WidgetsBindingObserver should be used when we want to listen to the AppLifecycleState and call stop/start on our services.

Source: www.filledstacks.com   


🔹 7. What is the difference between "main()" and "runApp()" functions in Flutter?

Answer:

  • main () function came from Java-like languages so it's where all program started, without it, you can't write any program on Flutter even without UI.
  • runApp() function should return Widget that would be attached to the screen as a root of the Widget Tree that will be rendered.
Source: stackoverflow.com   


🔹 8. What is an App state?

Answer:

  • State that is not ephemeral, that you want to share across many parts of your app, and that you want to keep between user sessions, is what we call application state (sometimes also called shared state).
  • Examples of application state: - User preferences - Login info - Notifications in a social networking app - The shopping cart in an e-commerce app - Read/unread state of articles in a news app
Source: flutter.dev   


🔹 9. What is the pubspec.yaml file and what does it do?

Answer:

The Pubspec.yaml allows you to define the packages your app relies on, declare your assets like images, audio, video, etc. It also allows you to set constraints for your app. For Android developers, this is roughly similar to a build.gradle file, but the differences between the two are also evident.

Source: medium.com   


🔹 10. What are the different build modes in Flutter?

Answer:

  • The Flutter tooling supports three modes when compiling your app, and a headless mode for testing.
  • You choose a compilation mode depending on where you are in the development cycle.
  • The modes are: - Debug - Profile - Release
Source: flutter.dev   


🔹 11. What is Dart and why does Flutter use it?

Answer:

Dart is an object-oriented, garbage-collected programming language that you use to develop Flutter apps. It was also created by Google, but is open-source, and has community inside and outside Google. Dart was chosen as the language of Flutter for the following reason:

  • Dart is AOT (Ahead Of Time) compiled to fast, predictable, native code, which allows almost all of Flutter to be written in Dart. This not only makes Flutter fast, virtually everything (including all the widgets) can be customized.
  • Dart can also be JIT (Just In Time) compiled for exceptionally fast development cycles and game-changing workflow (including Flutter’s popular sub-second stateful hot reload).
  • Dart allows Flutter to avoid the need for a separate declarative layout language like JSX or XML, or separate visual interface builders, because Dart’s declarative, programmatic layout is easy to read and visualize. And with all the layout in one language and in one place, it is easy for Flutter to provide advanced tooling that makes layout a snap.
Source: hackernoon.com   


🔹 12. How many types of widgets are there in Flutter?

Answer:

There are two types of widgets: 1. StatelessWidget : A widget that does not require mutable state. 2. StatefulWidget: A widget that has mutable state.

Source: proandroiddev.com   


🔹 13. How is Flutter different from a WebView based application?

Answer:

  • Code you write for a WebView or an app that runs similarly has to go through multiple layers to finally get executed (like Cordova for Ionic). In essence, Flutter leapfrogs that by compiling down to native ARM code to execute on both platforms.
  • “Hybrid” apps are slow, sluggish and look different from the platform they run on. Flutter apps run much, much faster than their hybrid counterparts.
  • It’s much easier to access native components and sensors using plugins rather than using WebView which can’t take full use of their platform.
Source: medium.com   


🔹 14. What is a "widget" and mention its importance in Flutter?

Answer:

  • Widgets are basically the UI components in Flutter.
  • It is a way to describe the configuration of an Element.
  • They are inspired from components in React.

Widgets are important in Flutter because everything within a Flutter application is a Widget , from a simple “Text” to “Buttons” to “Screen Layouts”.

Source: stackoverflow.com   


🔹 15. What is Fat Arrow Notation in Dart and when do you use it?

Answer:

The fat arrow syntax is simply a short hand for returning an expression and is similar to (){ return expression; }.

The fat arrow is for returning a single line, braces are for returning a code block.

Only an expression—not a statement—can appear between the arrow (=>) and the semicolon (;). For example, you can’t put an if statement there, but you can use a conditional expression

// Normal function
void function1(int a) {
  if (a == 3) {
    print('arg was 3');
  } else {
    print('arg was not 3');
  }
}

// Arrow Function void function2(int a) => print('arg was ${a == 3 ? '' : 'not '}3');

Source: stackoverflow.com   


🔹 16. Why do we pass functions to widgets?

👉🏼 Check all 68 answers


🔹 17. What is Streams in Flutter/Dart?

👉🏼 Check all 68 answers


🔹 18. What is release mode and when do you use it?

👉🏼 Check all 68 answers


🔹 19. Differentiate between named parameters and positional parameters in Dart?

👉🏼 Check all 68 answers


🔹 20. What is the difference between Scaffold and Container in Flutter?

👉🏼 Check all 68 answers


🔹 21. What is ScopedModel / BLoC Pattern?

👉🏼 Check all 68 answers


🔹 22. What are Null-aware operators?

👉🏼 Check all 68 answers


🔹 23. What is profile mode and when do you use it?

👉🏼 Check all 68 answers


🔹 24. What are packages and plugins in Flutter?

👉🏼 Check all 68 answers


🔹 25. Do you know what Ephemeral state means?

👉🏼 Check all 68 answers


🔹 26. Explain the different types of Streams?

👉🏼 Check all 68 answers


🔹 27. Explain Navigator Widget and its push pop functions in Flutter?

👉🏼 Check all 68 answers


🔹 28. How do you check if an async void method is completed in Dart?

👉🏼 Check all 68 answers


🔹 29. Where are the layout files? Why doesn’t Flutter have layout files?

👉🏼 Check all 68 answers


🔹 30. What are some pros of Flutter?

👉🏼 Check all 68 answers


🔹 31. Why is the build() method on State and not Stateful Widget?

👉🏼 Check all 68 answers


🔹 32. What are keys in Flutter and when to use it?

👉🏼 Check all 68 answers


🔹 33. Differentiate StatelessWidget and StatefulWidget?

👉🏼 Check all 68 answers


🔹 34. How is InheritedWidget different from Provider?

👉🏼 Check all 68 answers


🔹 35. Differentiate between required and optional parameters in Dart

👉🏼 Check all 68 answers


🔹 36. Differentiate between Hot Restart and Hot Reload?

👉🏼 Check all 68 answers


🔹 37. What is debug mode and when do you use it?

👉🏼 Check all 68 answers


🔹 38. When do we use double.INFINITY?

👉🏼 Check all 68 answers


🔹 39. How to declare async function as a variable in Dart?

👉🏼 Check all 68 answers


🔹 40. How is whenCompleted() different from then() in Future?

👉🏼 Check all 68 answers


🔹 41. Name some cons of using Flutter?

👉🏼 Check all 68 answers


🔹 42. How would you execute code only in debug mode?

👉🏼 Check all 68 answers


🔹 43. How to duplicate repeating items inside a Dart list?

👉🏼 Check all 68 answers


🔹 44. How to get difference of lists in Flutter/Dart?

👉🏼 Check all 68 answers


🔹 45. What does "non-nullable by default" mean in Dart?

👉🏼 Check all 68 answers


🔹 46. What is the difference between React Native and Flutter in-depth?

👉🏼 Check all 68 answers


🔹 47. Explain async, await in Flutter/Dart?

👉🏼 Check all 68 answers


🔹 48. What is the difference between double.INFINITY and MediaQuery?

👉🏼 Check all 68 answers


🔹 49. What is Future in Flutter/Dart?

👉🏼 Check all 68 answers


🔹 50. What is the purpose of SafeArea in Flutter?

👉🏼 Check all 68 answers


🔹 51. What does a class with a method named ._() mean in Dart/Flutter?

👉🏼 Check all 68 answers


🔹 52. When would you use App state or Ephemeral state over another?

👉🏼 Check all 68 answers


🔹 53. What is a difference between these operators "?? and ?."

👉🏼 Check all 68 answers


🔹 54. What is a MediaQuery in Flutter and when do we use it?

👉🏼 Check all 68 answers


🔹 55. Why is exit(0) not preferred for closing an app?

👉🏼 Check all 68 answers


🔹 56. What are Global Keys?

👉🏼 Check all 68 answers


🔹 57. How does Dart AOT work?

👉🏼 Check all 68 answers


🔹 58. What's the difference between async and async* in Dart?

👉🏼 Check all 68 answers


🔹 59. What are some pros and cons of Scoped Model vs BLoC and vice versa?

👉🏼 Check all 68 answers


🔹 60. What are the similarities and differences of Future and Stream?

👉🏼 Check all 68 answers


🔹 61. Why should you use kReleaseMode instead of assert?

👉🏼 Check all 68 answers


🔹 62. How to compare two dates that are constructed differently in Dart?

👉🏼 Check all 68 answers


🔹 63. How do you convert a List into a Map in Dart?

👉🏼 Check all 68 answers


🔹 64. Why Are StatefulWidget and State Separate Classes?

👉🏼 Check all 68 answers


🔹 65. What is the difference between debug mode and profile mode?

👉🏼 Check all 68 answers


🔹 66. Explain Stateful Widget Lifecycle in details

👉🏼 Check all 68 answers


🔹 67. How is AnimationController different from Timer?

👉🏼 Check all 68 answers


🔹 68. List some approaches for State management in Flutter

👉🏼 Check all 68 answers


No comments:

Post a Comment