Шукаєте відповіді та рішення тестів для Mobile Device Programming (CS326/CSE5333/CS326n)? Перегляньте нашу велику колекцію перевірених відповідей для Mobile Device Programming (CS326/CSE5333/CS326n) в e-learning.msa.edu.eg.
Отримайте миттєвий доступ до точних відповідей та детальних пояснень для питань вашого курсу. Наша платформа, створена спільнотою, допомагає студентам досягати успіху!
(Code Examination)
Examine the following Flutter code for navigating between pages. Identify any issues and suggest improvements for managing data passed between pages.
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => SecondPage(data: 'Hello, Second Page!'),
),
);
// In SecondPage:
Navigator.pop(context, 'Hello, First Page!');
(Code Examination)
Evaluate the correctness of the following Flutter code for saving a user's details to Firestore. Does it handle error cases properly? Suggest improvements.
Future<void> saveUserDetails(Map<String, dynamic> userDetails) async {
final userCollection = FirebaseFirestore.instance.collection('users');
try {
await userCollection.doc(userDetails['id']).set(userDetails);
print('User details saved successfully');
} catch (e) {
print('Error saving user details: $e');
}
}
(Create)
Create a Flutter application that uses a ListView to display a list of items fetched from a REST API. Include a RefreshIndicator to reload the list.
(Design)
Design a Flutter interface with a TextField for entering a username and a Text widget to display the entered username in real-time below it.
(Create)
Create a Flutter UI that displays a map with the current user's location. Include a button that, when clicked, re-centers the map on the user's updated location.
Given the following code, identify the day that will be printed if day is 5.
void main() {
int day = 5;
switch (day) {
case 1:
print("Monday");
break;
case 2:
print("Tuesday");
break;
case 3:
print("Wednesday");
break;
case 4:
print("Thursday");
break;
case 5:
print("Friday");
break;
default:
print("Invalid day");
}
}
(Code Examination)
Analyze the following Flutter code snippet. What happens if the onPressed method is invoked multiple times? Is there a risk of overwriting data?
ElevatedButton(
onPressed: () async {
final file = File('/storage/emulated/0/notes.txt');
await file.writeAsString('This is a note.');
},
child: Text('Save Note'),
);
Write a function that calculates the sum of all even numbers in a list.
(Create)
Design a Flutter application that includes a toggle switch for enabling or disabling Bluetooth. When Bluetooth is enabled, display a list of paired devices.
Create a function that checks if a number is prime. Return true if it is prime, false otherwise.
bool isPrime(int num) {
if (num <= 1) return false;
for (int i = 2; i <= num ~/ 2; i++) {
if (num % i == 0) return false;
}
return true;
}
Example Usage:
void main() {
print(isPrime(7)); // Output: true
print(isPrime(10)); // Output: false
}