dart analyze warnings fixed

master
Rafael 2024-06-07 02:18:20 +02:00
parent 6d776874c7
commit a4aa0ed18f
8 changed files with 92 additions and 96 deletions

View File

@ -171,7 +171,7 @@ class LocationSelectorState extends State<LocationSelector> {
'Location permissions are permanently denied, we cannot request permissions.'); 'Location permissions are permanently denied, we cannot request permissions.');
} }
} catch (e) { } catch (e) {
print('Error getting location permission: $e'); debugPrint('Error getting location permission: $e');
} }
try { try {
@ -194,7 +194,7 @@ class LocationSelectorState extends State<LocationSelector> {
triggerCallback(); triggerCallback();
} }
} catch (e) { } catch (e) {
print('Error getting current location: $e'); debugPrint('Error getting current location: $e');
} }
} }
} }

View File

@ -121,7 +121,7 @@ class CultureValuesFormPageState extends State<CultureValuesFormPage> {
} }
// Handle the form submission logic here // Handle the form submission logic here
bool success = await _saveDataToFirebase(); bool success = await _saveDataToFirebase();
if (success) { if (success && mounted) {
if (widget.isRegProcess) { if (widget.isRegProcess) {
Navigator.push( Navigator.push(
context, context,

View File

@ -77,9 +77,9 @@ class RisksFormPageState extends State<RisksFormPage> {
} }
void _showSnackBar(String message) { void _showSnackBar(String message) {
ScaffoldMessenger.of(context).showSnackBar(SnackBar( ScaffoldMessenger.of(context).showSnackBar(
content: Text(message), SnackBar(content: Text(message)),
)); );
} }
Future<void> handleSubmit() async { Future<void> handleSubmit() async {
@ -98,6 +98,13 @@ class RisksFormPageState extends State<RisksFormPage> {
// Handle the form submission logic here // Handle the form submission logic here
bool success = await _saveDataToFirebase(); bool success = await _saveDataToFirebase();
if (success) { if (success) {
_navigate();
} else {
_showSnackBar('Failed to save data.');
}
}
void _navigate() {
if (widget.isRegProcess) { if (widget.isRegProcess) {
Navigator.push( Navigator.push(
context, context,
@ -119,13 +126,6 @@ class RisksFormPageState extends State<RisksFormPage> {
Navigator.pop(context); Navigator.pop(context);
} }
} }
} else {
ScaffoldMessenger.of(context).showSnackBar(
const SnackBar(
content: Text('Failed to save data.'),
),
);
}
} }
@override @override

View File

@ -66,7 +66,7 @@ class EditProfilePageState extends State<EditProfilePage> {
title: 'Cropper', title: 'Cropper',
minimumAspectRatio: 1.0, minimumAspectRatio: 1.0,
), ),
if (kIsWeb) if (kIsWeb && mounted)
WebUiSettings( WebUiSettings(
context: context, context: context,
presentStyle: CropperPresentStyle.page, presentStyle: CropperPresentStyle.page,
@ -227,7 +227,7 @@ class EditProfilePageState extends State<EditProfilePage> {
child: Stack( child: Stack(
children: [ children: [
CircleAvatar( CircleAvatar(
radius: 50, radius: 80,
backgroundImage: _profileImage != null backgroundImage: _profileImage != null
? FileImage(_profileImage!) ? FileImage(_profileImage!)
: (_webProfileImage != null : (_webProfileImage != null
@ -240,7 +240,7 @@ class EditProfilePageState extends State<EditProfilePage> {
child: _profileImage == null && child: _profileImage == null &&
_webProfileImage == null && _webProfileImage == null &&
widget.userData.profilePictureUrl == null widget.userData.profilePictureUrl == null
? const Icon(Icons.person, size: 50) ? const Icon(Icons.person, size: 80)
: null, : null,
), ),
), ),
@ -253,7 +253,7 @@ class EditProfilePageState extends State<EditProfilePage> {
color: Theme.of(context).colorScheme.primary, color: Theme.of(context).colorScheme.primary,
shape: const CircleBorder(), shape: const CircleBorder(),
), ),
child: const Icon(Icons.edit), child: const Icon(Icons.camera_alt),
), ),
onPressed: _pickImage, onPressed: _pickImage,
), ),

View File

@ -17,10 +17,8 @@ class HomePage extends StatelessWidget {
return Scaffold( return Scaffold(
appBar: AppBar( appBar: AppBar(
title: const Text('Home'), title: const Text('Home'),
// TODO appbar style: remove background and set elevation to 0 ? // different appbar style for homepage
backgroundColor: Colors.transparent, backgroundColor: Colors.transparent,
foregroundColor: Colors.grey.shade800,
elevation: 0,
), ),
drawer: const MyDrawer(), drawer: const MyDrawer(),
body: _buildUserList(), body: _buildUserList(),

View File

@ -608,13 +608,13 @@ class _UserProfilePageState extends State<UserProfilePage> {
), ),
), ),
CircleAvatar( CircleAvatar(
radius: 50, radius: 80,
backgroundImage: backgroundImage:
((profileImageUrl != null && profileImageUrl!.isNotEmpty)) ((profileImageUrl != null && profileImageUrl!.isNotEmpty))
? NetworkImage(profileImageUrl!) ? NetworkImage(profileImageUrl!)
: null, : null,
child: (profileImageUrl == null || profileImageUrl!.isEmpty) child: (profileImageUrl == null || profileImageUrl!.isEmpty)
? const Icon(Icons.person, size: 50) ? const Icon(Icons.person, size: 80)
: null, : null,
), ),
const SizedBox(height: 16), const SizedBox(height: 16),

View File

@ -26,7 +26,6 @@ class UserVisionPageState extends State<UserVisionPage> {
}; };
AvailabilityOption? availability; AvailabilityOption? availability;
// get instance of auth
final AuthService _authService = AuthService(); final AuthService _authService = AuthService();
@override @override
@ -43,11 +42,13 @@ class UserVisionPageState extends State<UserVisionPage> {
if (snapshot.exists) { if (snapshot.exists) {
final data = snapshot.data(); final data = snapshot.data();
setState(() { setState(
() {
// Load Vision options // Load Vision options
if (data?[Constants.dbFieldUsersVisions] != null) { if (data?[Constants.dbFieldUsersVisions] != null) {
for (var option in VisionOption.values) { for (var option in VisionOption.values) {
selectedVisionOptions[option] = data?[Constants.dbFieldUsersVisions] selectedVisionOptions[option] =
data?[Constants.dbFieldUsersVisions]
.contains(option.toString()); .contains(option.toString());
} }
} }
@ -57,7 +58,8 @@ class UserVisionPageState extends State<UserVisionPage> {
(e) => e.toString() == data?[Constants.dbFieldUsersAvailability], (e) => e.toString() == data?[Constants.dbFieldUsersAvailability],
); );
} }
}); },
);
} }
} }
@ -85,9 +87,9 @@ class UserVisionPageState extends State<UserVisionPage> {
} }
void _showSnackBar(String message) { void _showSnackBar(String message) {
ScaffoldMessenger.of(context).showSnackBar(SnackBar( ScaffoldMessenger.of(context).showSnackBar(
content: Text(message), SnackBar(content: Text(message)),
)); );
} }
bool isVisionSelected() { bool isVisionSelected() {
@ -96,20 +98,23 @@ class UserVisionPageState extends State<UserVisionPage> {
Future<void> handleSubmit() async { Future<void> handleSubmit() async {
if (!isVisionSelected()) { if (!isVisionSelected()) {
ScaffoldMessenger.of(context).showSnackBar(const SnackBar( _showSnackBar('Please select at least one long-term vision.');
content: Text('Please select at least one long-term vision.'),
));
return; return;
} }
if (availability == null) { if (availability == null) {
ScaffoldMessenger.of(context).showSnackBar(const SnackBar( _showSnackBar('Please select an availability option.');
content: Text('Please select an availability option.'),
));
return; return;
} }
// Handle the form submission logic here // Handle the form submission logic here
bool success = await _saveDataToFirebase(); bool success = await _saveDataToFirebase();
if (success) { if (success) {
_navigate();
} else {
_showSnackBar('Failed to save data.');
}
}
void _navigate() {
if (widget.isRegProcess) { if (widget.isRegProcess) {
Navigator.push( Navigator.push(
context, context,
@ -137,13 +142,6 @@ class UserVisionPageState extends State<UserVisionPage> {
Navigator.pop(context); Navigator.pop(context);
} }
} }
} else {
ScaffoldMessenger.of(context).showSnackBar(
const SnackBar(
content: Text('Failed to save data.'),
),
);
}
} }
@override @override

View File

@ -93,7 +93,7 @@ class AuthGate extends StatelessWidget {
Constants.dbFieldUsersEmail: email, Constants.dbFieldUsersEmail: email,
}); });
} catch (e) { } catch (e) {
print("Error creating user document: $e"); debugPrint("Error creating user document: $e");
} }
} }
@ -105,7 +105,7 @@ class AuthGate extends StatelessWidget {
await _checkUsersCollectionExists(Constants.dbCollectionLocations); await _checkUsersCollectionExists(Constants.dbCollectionLocations);
return languagesExist && locationsExist; return languagesExist && locationsExist;
} catch (e) { } catch (e) {
print(e.toString()); debugPrint(e.toString());
return false; return false;
} }
} }
@ -120,7 +120,7 @@ class AuthGate extends StatelessWidget {
final snapshot = await collection.limit(1).get(); final snapshot = await collection.limit(1).get();
return snapshot.docs.isNotEmpty; return snapshot.docs.isNotEmpty;
} catch (e) { } catch (e) {
print(e.toString()); debugPrint(e.toString());
return false; return false;
} }
} }