Skip to content

Commit

Permalink
fix: resolve flutter static analysis issues (beta)
Browse files Browse the repository at this point in the history
  • Loading branch information
srieteja committed May 27, 2024
1 parent 3afc6db commit eadcbef
Show file tree
Hide file tree
Showing 41 changed files with 176 additions and 257 deletions.
5 changes: 2 additions & 3 deletions packages/at_backupkey_flutter/example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import 'package:at_client_mobile/at_client_mobile.dart';
import 'package:at_onboarding_flutter/at_onboarding_flutter.dart'
show AtOnboardingConfig, AtOnboardingResultStatus, BackupKeyWidget;

// import 'package:at_utils/at_logger.dart' show AtSignLogger;
import 'package:path_provider/path_provider.dart'
show getApplicationSupportDirectory;
import 'package:at_app_flutter/at_app_flutter.dart' show AtEnv;
Expand Down Expand Up @@ -54,7 +53,7 @@ class _MyAppState extends State<MyApp> {
primaryColor: const Color(0xFFf4533d),
colorScheme: ThemeData.light().colorScheme.copyWith(
primary: const Color(0xFFf4533d),
background: Colors.white,
surface: Colors.white,
),
scaffoldBackgroundColor: Colors.white,
),
Expand All @@ -63,7 +62,7 @@ class _MyAppState extends State<MyApp> {
primaryColor: Colors.blue,
colorScheme: ThemeData.dark().colorScheme.copyWith(
primary: Colors.blue,
background: Colors.grey[850],
surface: Colors.grey[850],
),
scaffoldBackgroundColor: Colors.grey[850],
),
Expand Down
4 changes: 2 additions & 2 deletions packages/at_chat_flutter/example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ class _MyAppState extends State<MyApp> {
setState(() {
atClientPreference = preference;
});
if (mounted) {
if (context.mounted) {
final result = await AtOnboarding.onboard(
context: context,
config: AtOnboardingConfig(
Expand Down Expand Up @@ -127,7 +127,7 @@ class _MyAppState extends State<MyApp> {
child: TextButton(
style: ButtonStyle(
backgroundColor:
MaterialStateProperty.all<Color>(Colors.black12),
WidgetStateProperty.all<Color>(Colors.black12),
),
onPressed: () {
FlutterKeychain.remove(key: '@atsign');
Expand Down
2 changes: 1 addition & 1 deletion packages/at_chat_flutter/example/lib/second_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ class _SecondScreenState extends State<SecondScreen> {
const SizedBox(height: 10),
TextButton(
style: ButtonStyle(
backgroundColor: MaterialStateProperty.all<Color>(Colors.black),
backgroundColor: WidgetStateProperty.all<Color>(Colors.black),
),
onPressed: () {
setGroupToChatWith(context);
Expand Down
2 changes: 1 addition & 1 deletion packages/at_chat_flutter/example/lib/third_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class _ThirdScreenState extends State<ThirdScreen> {

var result = await deleteMessages();
var message = result ? 'Messages are deleted' : 'Failed to delete';
if (mounted) {
if (context.mounted) {
ScaffoldMessenger.of(context)
.showSnackBar(SnackBar(content: Text(message)));
}
Expand Down
4 changes: 2 additions & 2 deletions packages/at_chat_flutter/lib/screens/chat_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -174,14 +174,14 @@ class _ChatScreenState extends State<ChatScreen> {
(id) async {
var result = await _chatService
.deleteSelectedMessage(id);
if (mounted) {
if (context.mounted) {
Navigator.of(context).pop();
}

var message = result
? 'Message is deleted'
: 'Failed to delete';
if (mounted) {
if (context.mounted) {
ScaffoldMessenger.of(context)
.showSnackBar(SnackBar(
content:
Expand Down
53 changes: 30 additions & 23 deletions packages/at_contacts_flutter/example/lib/main.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import 'dart:async';
import 'package:at_contacts_flutter_example/second_screen.dart';
import 'package:at_onboarding_flutter/at_onboarding_result.dart';
import 'package:flutter/material.dart';
import 'package:at_client_mobile/at_client_mobile.dart';
import 'package:at_onboarding_flutter/at_onboarding_flutter.dart'
Expand Down Expand Up @@ -33,10 +34,10 @@ class MyApp extends StatefulWidget {
const MyApp({Key? key}) : super(key: key);

@override
_MyAppState createState() => _MyAppState();
MyAppState createState() => MyAppState();
}

class _MyAppState extends State<MyApp> {
class MyAppState extends State<MyApp> {
// * load the AtClientPreference in the background
Future<AtClientPreference> futurePreference = loadAtClientPreference();
AtClientPreference? atClientPreference;
Expand All @@ -55,7 +56,7 @@ class _MyAppState extends State<MyApp> {
primaryColor: const Color(0xFFf4533d),
colorScheme: ThemeData.light().colorScheme.copyWith(
primary: const Color(0xFFf4533d),
background: Colors.white,
surface: Colors.white,
),
scaffoldBackgroundColor: Colors.white,
),
Expand All @@ -64,7 +65,7 @@ class _MyAppState extends State<MyApp> {
primaryColor: Colors.blue,
colorScheme: ThemeData.dark().colorScheme.copyWith(
primary: Colors.blue,
background: Colors.grey[850],
surface: Colors.grey[850],
),
scaffoldBackgroundColor: Colors.grey[850],
),
Expand Down Expand Up @@ -98,22 +99,26 @@ class _MyAppState extends State<MyApp> {
setState(() {
atClientPreference = preference;
});
final result = await AtOnboarding.onboard(
context: context,
config: AtOnboardingConfig(
atClientPreference: atClientPreference!,
domain: AtEnv.rootDomain,
rootEnvironment: AtEnv.rootEnvironment,
appAPIKey: AtEnv.appApiKey,
),
);
switch (result.status) {
AtOnboardingResult? result;
if (context.mounted) {
result = await AtOnboarding.onboard(
context: context,
config: AtOnboardingConfig(
atClientPreference: atClientPreference!,
domain: AtEnv.rootDomain,
rootEnvironment: AtEnv.rootEnvironment,
appAPIKey: AtEnv.appApiKey,
),
);
}
switch (result?.status) {
case AtOnboardingResultStatus.success:
Navigator.push(
context,
MaterialPageRoute(
builder: (_) => const SecondScreen()));
break;
case null:
case AtOnboardingResultStatus.error:
ScaffoldMessenger.of(context).showSnackBar(
const SnackBar(
Expand All @@ -133,15 +138,17 @@ class _MyAppState extends State<MyApp> {
onPressed: () async {
var preference = await futurePreference;
atClientPreference = preference;
AtOnboarding.reset(
context: context,
config: AtOnboardingConfig(
atClientPreference: atClientPreference!,
domain: AtEnv.rootDomain,
rootEnvironment: AtEnv.rootEnvironment,
appAPIKey: AtEnv.appApiKey,
),
);
if(context.mounted) {
AtOnboarding.reset(
context: context,
config: AtOnboardingConfig(
atClientPreference: atClientPreference!,
domain: AtEnv.rootDomain,
rootEnvironment: AtEnv.rootEnvironment,
appAPIKey: AtEnv.appApiKey,
),
);
}
},
child: const Text('Reset'),
),
Expand Down
10 changes: 6 additions & 4 deletions packages/at_contacts_flutter/example/lib/second_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ class SecondScreen extends StatefulWidget {
const SecondScreen({Key? key}) : super(key: key);

@override
_SecondScreenState createState() => _SecondScreenState();
SecondScreenState createState() => SecondScreenState();
}

class _SecondScreenState extends State<SecondScreen> {
class SecondScreenState extends State<SecondScreen> {
String? activeAtSign, pickedAtSign;
@override
void initState() {
Expand All @@ -29,7 +29,7 @@ class _SecondScreenState extends State<SecondScreen> {
if (atsign[0] == '@') {
return atsign;
} else {
return '@' + atsign;
return '@$atsign';
}
}

Expand Down Expand Up @@ -83,7 +83,9 @@ class _SecondScreenState extends State<SecondScreen> {
}

pickedAtSign = '';
Navigator.pop(context);
if(context.mounted) {
Navigator.pop(context);
}
},
child: Text(
'Delete',
Expand Down
3 changes: 3 additions & 0 deletions packages/at_contacts_flutter/example/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ dependencies:
at_contacts_flutter:
path: ../
at_onboarding_flutter: ^6.1.7
at_client: ^3.0.75
at_client_mobile: ^3.2.15
path_provider: ^2.1.3

# The following adds the Cupertino Icons font to your application.
# Use with the CupertinoIcons class for iOS style icons.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ class _AddContactDialogState extends State<AddContactDialog> {
if (contactService.checkAtSign != null &&
contactService.checkAtSign! &&
response) {
if (!mounted) return;
if (!context.mounted) return;
Navigator.pop(context);
}
},
Expand Down
4 changes: 2 additions & 2 deletions packages/at_contacts_flutter/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ environment:
flutter: ">=1.20.0"

dependencies:
at_client: ^3.0.72
at_client_mobile: ^3.2.12
at_client: ^3.0.75
at_client_mobile: ^3.2.15
at_common_flutter: ^2.0.12
at_commons: ^4.0.1
at_contact: ^3.0.8
Expand Down
4 changes: 2 additions & 2 deletions packages/at_contacts_group_flutter/example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -52,15 +52,15 @@ class _MyAppState extends State<MyApp> {
brightness: Brightness.light,
primaryColor: const Color(0xFFf4533d),
colorScheme: ThemeData.light().colorScheme.copyWith(
primary: const Color(0xFFf4533d), background: Colors.white),
primary: const Color(0xFFf4533d), surface: Colors.white),
scaffoldBackgroundColor: Colors.white,
),
darkTheme: ThemeData().copyWith(
brightness: Brightness.dark,
primaryColor: Colors.blue,
colorScheme: ThemeData.dark()
.colorScheme
.copyWith(primary: Colors.blue, background: Colors.white),
.copyWith(primary: Colors.blue, surface: Colors.white),
scaffoldBackgroundColor: Colors.grey[850],
),
themeMode: themeMode,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,12 @@ class _DesktopGroupBottomSheetState extends State<DesktopGroupBottomSheet> {
: TextButton(
onPressed: () {},
style: ButtonStyle(
backgroundColor: MaterialStateProperty.resolveWith<Color>(
(Set<MaterialState> states) {
backgroundColor: WidgetStateProperty.resolveWith<Color>(
(Set<WidgetState> states) {
return ColorConstants.orangeColor;
},
), fixedSize: MaterialStateProperty.resolveWith<Size>(
(Set<MaterialState> states) {
), fixedSize: WidgetStateProperty.resolveWith<Size>(
(Set<WidgetState> states) {
return const Size(120, 40);
},
)),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,14 +118,14 @@ class _DesktopEmptyGroupState extends State<DesktopEmptyGroup> {
widget.onCreateBtnTap!();
},
style: ButtonStyle(
backgroundColor: MaterialStateProperty.resolveWith<Color>(
(Set<MaterialState> states) {
backgroundColor: WidgetStateProperty.resolveWith<Color>(
(Set<WidgetState> states) {
return widget.createBtnTapped
? ColorConstants.dullText
: ColorConstants.orangeColor;
},
), fixedSize: MaterialStateProperty.resolveWith<Size>(
(Set<MaterialState> states) {
), fixedSize: WidgetStateProperty.resolveWith<Size>(
(Set<WidgetState> states) {
return const Size(160, 45);
},
)),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -234,8 +234,6 @@ class _DesktopGroupDetailState extends State<DesktopGroupDetail> {
widget.currentIndex);

if (result is AtGroup) {
// ignore: todo
// TODO: Doubt
widget.group = _group;
if (mounted) {
ScaffoldMessenger.of(context)
Expand Down Expand Up @@ -427,8 +425,6 @@ class _DesktopGroupDetailState extends State<DesktopGroupDetail> {
isDesktop: true, expandIndex: widget.currentIndex);

if (result is AtGroup) {
// ignore: todo
// TODO: Doubt
widget.group = _group;
ScaffoldMessenger.of(context).showSnackBar(const SnackBar(
content: Text(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,12 +111,12 @@ class _DesktopGroupListState extends State<DesktopGroupList> {
});
},
style: ButtonStyle(
backgroundColor: MaterialStateProperty.resolveWith<Color>(
(Set<MaterialState> states) {
backgroundColor: WidgetStateProperty.resolveWith<Color>(
(Set<WidgetState> states) {
return ColorConstants.orangeColor;
},
), fixedSize: MaterialStateProperty.resolveWith<Size>(
(Set<MaterialState> states) {
), fixedSize: WidgetStateProperty.resolveWith<Size>(
(Set<WidgetState> states) {
return const Size(100, 40);
},
)),
Expand Down Expand Up @@ -218,7 +218,7 @@ class _DesktopGroupListState extends State<DesktopGroupList> {
onYesPressed: () async {
var result = await GroupService().deleteGroup(group);

if(!mounted) return;
if(!context.mounted) return;
if (result != null && result) {
Navigator.of(context).pop();
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class AddContactDialog extends StatefulWidget {
}

class _AddContactDialogState extends State<AddContactDialog> {
String atsignName = '';
String atsign = '';
TextEditingController atSignController = TextEditingController();
@override
void dispose() {
Expand Down Expand Up @@ -67,7 +67,7 @@ class _AddContactDialogState extends State<AddContactDialog> {
TextFormField(
autofocus: true,
onChanged: (value) {
atsignName = value;
atsign = value;
},
// validator: Validators.validateAdduser,
decoration: InputDecoration(
Expand Down Expand Up @@ -119,16 +119,16 @@ class _AddContactDialogState extends State<AddContactDialog> {
isLoading = true;
});
var response = await _contactService.addAtSign(
atSign: atsignName);
atSign: atsign);
var _groupService = GroupService();
_groupService.appendNewContact(atsignName);
_groupService.appendNewContact(atsign);
setState(() {
isLoading = false;
});
if (_contactService.checkAtSign != null &&
_contactService.checkAtSign! &&
response) {
if(!mounted) return;
if(!context.mounted) return;
Navigator.pop(context);
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ class _RemoveTrustedContactState extends State<RemoveTrustedContact> {
);

if (result is bool && result) {
if(mounted){
if(context.mounted){
Navigator.of(context).pop();
}
} else if (result == null) {
Expand Down
Loading

0 comments on commit eadcbef

Please sign in to comment.