Topic Wise Questions and Answers-Flutter
Topic Wise Questions and Answers-Flutter
A widget is the basic building block of a Flutter UI. Everything in Flutter is a widget, including layout
models and UI elements.
StatelessWidget does not store any state; it builds once. StatefulWidget can store and update state
over its lifecycle.
Scaffold provides a high-level structure for Material apps, including AppBar, Drawer,
BottomNavigationBar, etc.
For StatefulWidget: createState() -> initState() -> build() -> setState() -> dispose(). StatelessWidget
only uses build().
main() -> runApp() -> MaterialApp() -> home or routes -> widgets tree.
Material Design is Google’s design system used to create visually rich, responsive UIs with widgets
like AppBar, FAB, etc.
Cupertino is Apple’s iOS-style UI design. Yes, Cupertino widgets can be used on Android too.
SafeArea prevents UI elements from being drawn in unsafe areas like notches and status bars.
State Management
12. What is the difference between local and global state management?
Local state is managed within a widget; global state is accessible across multiple widgets.
setState() notifies the framework to rebuild a widget with updated data. Used in StatefulWidget.
Provider offers a simple and scalable way to manage and share state efficiently.
Riverpod is an improved version of Provider with better testability, no context dependency, and
compile-time safety.
It allows data to be efficiently passed down the widget tree and is the basis for packages like Provider.
These are named route methods for navigation with different route stack behaviors.
A routing package simplifying navigation with declarative syntax and deep linking support.
Animation
Implicit: automatic animations using Animated widgets. Explicit: full control using
AnimationController.
Static files like images, fonts, and JSON used in the app. Declared in pubspec.yaml.
while: checks condition first. do-while: executes first, checks condition after.
Used for decision-making. E.g., if(x > 10) print('Hi'); else print('Bye');