0% found this document useful (0 votes)
26 views4 pages

CAE Notes

The document provides a comprehensive overview of Flutter, detailing its key features, advantages, and disadvantages, as well as the installation process on Windows and macOS. It explains the architecture of Flutter applications, the concept of State with Stateful and Stateless widgets, and the role of Widgets in app development. Additionally, it discusses programming constructs in Dart, the significance of MediaQuery for responsive design, and compares synchronous and asynchronous programming approaches.

Uploaded by

chiranjit.das
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
26 views4 pages

CAE Notes

The document provides a comprehensive overview of Flutter, detailing its key features, advantages, and disadvantages, as well as the installation process on Windows and macOS. It explains the architecture of Flutter applications, the concept of State with Stateful and Stateless widgets, and the role of Widgets in app development. Additionally, it discusses programming constructs in Dart, the significance of MediaQuery for responsive design, and compares synchronous and asynchronous programming approaches.

Uploaded by

chiranjit.das
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

Explain the key features of Flutter and discuss its advantages and disadvantages.

Describe the step-by-step installation process of Flutter on Windows and macOS.


Explain the architecture of a Flutter application and analyze how Flutter handles UI rendering.
Compare synchronous and asynchronous programming in Dart with examples. Which
approach is better for Flutter applications?

Explain the concept of State in Flutter and differentiate between Stateful and Stateless widgets.
Describe the role of Widgets in Flutter and categorize different types of widgets based on their
functionality.
Explain how decision-making constructs and loops work in Dart programming. Why are they
important in app development?
Discuss the significance of MediaQuery in Flutter and how it helps in responsive UI design.

UNIT I: Introduction to Flutter

Q1: Explain the key features of Flutter and discuss its advantages and disadvantages.

Flutter is an open-source UI toolkit developed by Google for building natively compiled applications
for mobile, web, and desktop from a single codebase.
Features of Flutter:
 Single Codebase: Write one code and deploy on multiple platforms.
 Fast Performance: Uses Dart and Skia rendering engine for high performance.
 Hot Reload: Instantly see changes during development.
 Customizable Widgets: Provides rich, pre-designed widgets.
 Direct Compilation: Compiles into native ARM code for speed.
Advantages of Flutter:
 Faster app development with Hot Reload.
 Cross-platform compatibility (iOS, Android, Web, Windows, macOS, Linux).
 High performance due to native compilation.
 A growing community and extensive documentation.
Disadvantages of Flutter:
 Large app size compared to native apps.
 Limited third-party libraries compared to native platforms.
 iOS development limitations, as Flutter relies on Google’s implementations.

Q2: Describe the step-by-step installation process of Flutter on Windows and macOS.

Installation on Windows:
1. Download Flutter SDK from the official website.
2. Extract the ZIP file to the desired location (e.g., C:\flutter).
3. Add Flutter to the system path:
o Open Environment Variables → Edit Path → Add C:\flutter\bin.
4. Install dependencies:
o Install Git, Android Studio, and the Flutter plugin.
5. Verify installation: Run flutter doctor in the command prompt.
Installation on macOS:
1. Download Flutter SDK for macOS.
2. Extract it and move it to /Users/<your-username>/flutter.
3. Add Flutter to the PATH by modifying .zshrc or .bashrc.
4. Install Xcode and Android Studio.
5. Run flutter doctor to check for missing dependencies.

Explain the architecture of a Flutter application and analyze how Flutter handles UI rendering.

Flutter applications follow a layered architecture, consisting of:


1. Framework Layer (Dart-based):
o UI Elements: Widgets, Material Design, Cupertino.
o Foundation libraries: Rendering, animation, gestures.
o Engine: Skia graphics, Dart VM, text rendering.
2. Engine Layer (C++):
o Skia for rendering.
o Dart runtime for executing Flutter code.
3. Embedder Layer (Platform-Specific):
o Bridges Flutter with native OS using platform channels.
UI Rendering in Flutter:
 Flutter does not use native UI components; instead, it renders its own widgets using the
Skia graphics engine.
 The rendering engine paints pixels directly, resulting in smooth animations.
 Uses Widgets tree → Element tree → RenderObject tree to manage UI.

Q 4 Define and explain the purpose of getters and setters in Dart with an example.

Getters and Setters in Dart are used to encapsulate data and control access to object properties.
 Getter: Retrieves the value of a property.
 Setter: Modifies a property while ensuring validation.

class Student {
String _name = '';

String get name => _name; // Getter


set name(String newName) { // Setter
if (newName.isNotEmpty) {
_name = newName;
} else {
print('Invalid Name');
}
}
}

void main() {
Student s = Student();
s.name = 'Alice'; // Using setter
print(s.name); // Using getter
}

O/p -- Alice

Q4: Compare synchronous and asynchronous programming in Dart with examples. Which
approach is better for Flutter applications?
In Dart, synchronous operations run sequentially, blocking execution, while asynchronous operations
execute independently without waiting.
Synchronous Programming Example:

void main() {
print('Start');
print('Processing...');
print('End');
}

Output: Start → Processing → End (sequential execution).

Asynchronous Programming Example:

void main() async {


print('Start');
await Future.delayed(Duration(seconds: 2), () => print('Processing...'));
print('End');
}
Output: Start → (waits 2 sec) → Processing → End.

Which is better for Flutter?


 Asynchronous programming is better as it prevents UI from freezing.
 Future, async, and await allow handling tasks like API calls smoothly.
 Streams enable real-time data updates, useful for chat apps or sensor data.

Unit - 2

1. Explain the concept of State in Flutter and differentiate between Stateful and Stateless
widgets.
In Flutter, the State refers to the data that can change during the lifetime of an application. It plays a
crucial role in building dynamic UI components that update based on user interactions or external
changes.
 Stateless Widgets: These widgets are immutable, meaning their properties cannot change
once created. They are used for UI components that do not need to update dynamically.
Examples include Text, Icon, and Container.
 Stateful Widgets: These widgets can change their state over time. They use a State object,
which allows modification without recreating the entire widget. Examples include TextField
(where user input changes the UI) and Checkbox (which toggles selection).
Flutter follows a declarative UI approach, meaning when a state changes, the framework rebuilds only
the necessary parts of the widget tree to reflect updates efficiently.

2. Describe the role of Widgets in Flutter and categorize different types of widgets based on
their functionality.

Widgets are the fundamental building blocks of Flutter applications, defining both structure and
behavior of UI components. Everything in Flutter is a widget, including text, buttons, layouts, and
even the entire application itself.
Widgets in Flutter can be broadly classified into:
1. Structural Widgets: Define the layout of the app, such as Scaffold, AppBar, Container, and
Column.
2. Interactive Widgets: Handle user interaction, such as GestureDetector, InkWell,
ElevatedButton, and TextField.
3. Styling and Theming Widgets: Control visual appearance, such as Padding, Margin, Align,
and DecoratedBox.
4. Stateful and Stateless Widgets: Manage state (StatefulWidget) or remain constant
(StatelessWidget).
5. Animation & Media Widgets: Help create animations and display media, such as Image,
VideoPlayer, and Hero.
The flexibility of widgets in Flutter enables developers to build complex UIs using a composition-
based approach, ensuring scalability and maintainability.

3. Explain how decision-making constructs and loops work in Dart programming. Why are they
important in app development?

Dart, the programming language used in Flutter, provides decision-making constructs and loops to
control program flow based on conditions and repeated executions.
Decision-Making Constructs:
 if, if-else: Used to execute a block of code based on a condition.
 else-if ladder: Allows multiple conditions to be checked sequentially.
 switch-case: Used for handling multiple specific cases efficiently.
Loops in Dart:
 For loop: Executes a block of code a fixed number of times.
 While loop: Executes a block as long as a condition remains true.
 Do-while loop: Similar to while, but guarantees at least one execution.
 For-in loop: Iterates over elements in a collection, such as lists or maps.
These constructs are crucial in app development as they enable efficient data processing, user
interactions, animations, and event handling. For example, loops are used in data pagination, and
conditional statements help in form validation.

4. Discuss the significance of MediaQuery in Flutter and how it helps in responsive UI design.

MediaQuery in Flutter is a powerful tool that provides information about the current device’s screen
dimensions, orientation, text scaling, and other layout-related properties. It is essential for creating
responsive and adaptive user interfaces that work seamlessly across different screen sizes.
MediaQuery provides details such as:
 Screen width and height: Helps adjust UI elements dynamically based on device size.
 Orientation: Determines whether the device is in portrait or landscape mode, enabling layout
changes accordingly.
 Text scale factor: Adjusts font sizes based on user preferences for better accessibility.
Using MediaQuery, developers can ensure that their applications provide a consistent experience
across mobile, tablet, and desktop devices by making UI components adapt dynamically rather than
using fixed pixel-based dimensions.

You might also like