Mob App Uinit 3
Mob App Uinit 3
```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.
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.
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.
```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.
```dart
showTimePicker(
context: context,
initialTime: TimeOfDay.now(),
);
```
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.
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,
),
);
```
**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,
),
);
```