0% found this document useful (0 votes)
12 views6 pages

Mob App Uinit 3

Mobile application development

Uploaded by

rameshtambadi8
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)
12 views6 pages

Mob App Uinit 3

Mobile application development

Uploaded by

rameshtambadi8
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/ 6

### Two Marks Questions

1. **What is a gesture in Flutter?**


A gesture in Flutter refers to user interactions like taps, swipes, or pinches. These
gestures can be detected and handled to perform specific actions.

2. **Which widget is used to detect gestures in Flutter?**


The `GestureDetector` widget is used to detect and respond to gestures in Flutter.

3. **What is the use case of the `onTap` event in Flutter?**


The `onTap` event is used to handle user taps on a widget, commonly used in
buttons, list items, or any interactive elements to trigger actions.

4. **What is a dialog in Flutter used for?**


A dialog in Flutter is used to display transient information or prompt users for input.
It often appears over the current screen and requires user interaction.

5. **Name the three key properties of an AlertDialog in Flutter.**


- `title`: The title of the dialog.
- `content`: The main content of the dialog.
- `actions`: The buttons or actions at the bottom of the dialog.

6. **What is the state of Flutter?**


In Flutter, state refers to the data or properties that affect how a widget behaves or
appears. The state can be mutable and change over time.

7. **Define ephemeral state in Flutter.**


Ephemeral state refers to temporary state that is specific to a single widget and
does not need to be shared with other parts of the app. It is managed within the
widget itself using `State` objects.

8. **What is the role of the createState() method in a StatefulWidget?**


The `createState()` method creates an instance of the `State` object associated with
the `StatefulWidget`. This `State` object manages the widget’s mutable state.

9. **How does setState() function in Flutter?**


The `setState()` method is used to notify Flutter that the internal state of a
`StatefulWidget` has changed. It triggers a rebuild of the widget to reflect the updated
state.

10. **What is the application state in Flutter?**


The application state encompasses all data and properties that affect the entire
app’s behavior and UI, potentially shared across different widgets and screens.

11. **What does the ScopedModel widget do?**


The `ScopedModel` widget provides a way to pass a model down the widget tree
and allows child widgets to access and modify the model.
12. **How does notifyListeners() function in a model class?**
The `notifyListeners()` method notifies all listeners of the model that the data has
changed, prompting them to rebuild or react to the updated data.

13. **What is navigation in Flutter?**


Navigation in Flutter refers to moving between different screens or routes in the
app, allowing users to interact with various parts of the application.

14. **What widget manages a stack of route objects in Flutter?**


The `Navigator` widget manages a stack of route objects and handles navigation
between different screens.

15. **How do you define named routes in a Flutter app?**


Named routes are defined in the `MaterialApp` widget’s `routes` property, mapping
route names to their corresponding widget builders.

```dart
MaterialApp(
routes: {
'/home': (context) => HomeScreen(),
'/details': (context) => DetailsScreen(),
},
);
```

16. **What method do you use to navigate back to the previous screen?**
Use the `Navigator.pop(context)` method to navigate back to the previous screen.

17. **What is the purpose of the TextField widget in Flutter?**


The `TextField` widget allows users to input text into the app, supporting various
text entry functionalities.

18. **How do you hide the text being entered in a TextField widget (e.g., for
passwords)?**
Set the `obscureText` property to `true` to hide the text being entered, suitable for
password fields.

```dart
TextField(
obscureText: true,
);
```

19. **What does the TextEditingController class allow you to do with a TextField?**
`TextEditingController` allows you to control and listen to changes in the text field’s
content, and programmatically update the text.
20. **What is the key property of the Checkbox widget that determines its checked
state?**
The `value` property of the `Checkbox` widget determines whether the checkbox is
checked.

21. **What does the onChanged callback of the Checkbox widget do?**
The `onChanged` callback is triggered when the checkbox state changes, allowing
you to respond to user interactions.

22. **How does the Radio widget ensure only one option is selected at a time?**
The `Radio` widget uses a `GroupValue` to ensure only one radio button is selected
within a group. The selected value is managed by a shared state.

23. **What are the key properties of the Radio widget?**


- `value`: The value associated with the radio button.
- `groupValue`: The value of the currently selected radio button in the group.
- `onChanged`: Callback function to handle state changes.

24. **What is the key property of the DatePicker widget that determines the initially
selected date?**
The `initialDate` property determines the initially selected date in the `DatePicker`
widget.

25. **How do you show a date picker in Flutter?**


Use the `showDatePicker` function to display a date picker dialog.

```dart
showDatePicker(
context: context,
initialDate: DateTime.now(),
firstDate: DateTime(2000),
lastDate: DateTime(2101),
);
```

26. **What is the key property of the TimePicker widget that determines the initially
selected time?**
The `initialTime` property determines the initially selected time in the `TimePicker`
widget.

27. **How do you show a time picker in Flutter?**


Use the `showTimePicker` function to display a time picker dialog.

```dart
showTimePicker(
context: context,
initialTime: TimeOfDay.now(),
);
```

28. **What is the purpose of the ListView widget in Flutter?**


The `ListView` widget displays a scrolling list of widgets, ideal for showing a large
or dynamic list of items.

29. **Describe the key properties of the ListTile widget.**


- `title`: The primary content of the list tile, typically a `Text` widget.
- `subtitle`: Additional information displayed below the title.
- `leading`: A widget displayed before the title, often an icon or image.
- `trailing`: A widget displayed after the title, such as an icon or action button.

30. **When would you use ListView without ListView.builder?**


Use `ListView` without `ListView.builder` for simple lists with a fixed number of
items or when the list is not expected to be large.

31. **What does the itemCount property specify in ListView.builder?**


The `itemCount` property specifies the number of items in the list.

32. **What is the main advantage of using ListView.builder over ListView without
builder?**
`ListView.builder` is more efficient for long or dynamic lists as it builds items on
demand, reducing memory usage and improving performance.

### Five Marks Questions

1. **Describe the `onDoubleTap` event and provide an example of its use case in
Flutter.**
The `onDoubleTap` event detects when a user double-taps on a widget. It is useful
for actions like zooming or triggering a specific action with a double tap.

**Example**:
```dart
GestureDetector(
onDoubleTap: () {
// Handle double tap
print('Double tapped!');
},
child: Container(
color: Colors.blue,
width: 100,
height: 100,
),
);
```

2. **Explain the `onVerticalDragUpdate` event with an example of when it might be


used.**
The `onVerticalDragUpdate` event is triggered when a vertical drag gesture is
detected. It provides updates as the user drags vertically, useful for custom scrolling
or dragging interactions.

**Example**:
```dart
GestureDetector(
onVerticalDragUpdate: (details) {
// Handle vertical drag updates
print('Dragging vertically: ${details.primaryDelta}');
},
child: Container(
color: Colors.red,
width: 100,
height: 100,
),
);
```

3. **What is the purpose of the `GestureDetector` widget in Flutter, and how is it used
in handling the `onPanUpdate` event?**
The `GestureDetector` widget detects various gestures and allows you to respond to
them. The `onPanUpdate` event provides continuous updates during a pan gesture,
useful for drag-and-drop functionality.

**Example**:
```dart
GestureDetector(
onPanUpdate: (details) {
// Handle pan updates
print('Pan position: ${details.localPosition}');
},
child: Container(
color: Colors.green,
width: 100,
height: 100,
),
);
```

4. **Compare and contrast the `onHorizontalDragUpdate` and `onVerticalDragUpdate`


events with examples.**

- **`onHorizontalDragUpdate`**: Detects and provides updates for horizontal drag


gestures.
```dart
GestureDetector(
onHorizontalDragUpdate: (details) {
// Handle horizontal drag updates
print('Dragging horizontally: ${details.primaryDelta}');
},
child

You might also like