Skip to content

Commit

Permalink
Merge pull request #860 from atsign-foundation/859-clear-up-info-mess…
Browse files Browse the repository at this point in the history
…ages-from-flutter-analyze-flutter-beta-323-edition

chore: Clear Up Info Messages for at_widget packages using  flutter 3.23 beta channel
  • Loading branch information
CurtlyCritchlow authored Jun 17, 2024
2 parents d29a67d + b56e7fd commit a1545b6
Show file tree
Hide file tree
Showing 34 changed files with 593 additions and 594 deletions.
70 changes: 24 additions & 46 deletions packages/at_backupkey_flutter/lib/widgets/backup_key_widget.dart
Original file line number Diff line number Diff line change
Expand Up @@ -73,16 +73,12 @@ class BackupKeyWidget extends StatelessWidget {
width: buttonWidth ?? 158.toWidth,
height: buttonHeight ?? (50.toHeight),
padding: EdgeInsets.symmetric(horizontal: 10.toWidth),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(30.toWidth),
color: buttonColor ?? Colors.black),
decoration:
BoxDecoration(borderRadius: BorderRadius.circular(30.toWidth), color: buttonColor ?? Colors.black),
child: Center(
child: Text(buttonText!,
textAlign: TextAlign.center,
style: TextStyle(
fontSize: 16.toFont,
color: Colors.white,
fontWeight: FontWeight.bold)),
style: TextStyle(fontSize: 16.toFont, color: Colors.white, fontWeight: FontWeight.bold)),
),
),
)
Expand All @@ -107,16 +103,14 @@ class BackupKeyWidget extends StatelessWidget {
children: [
Text(
'Error',
style: TextStyle(
fontWeight: FontWeight.bold, fontSize: 14.toFont),
style: TextStyle(fontWeight: FontWeight.bold, fontSize: 14.toFont),
),
Icon(Icons.sentiment_dissatisfied, size: 25.toFont)
],
),
content: Text(
'Could not backup the key file',
style:
TextStyle(fontWeight: FontWeight.bold, fontSize: 14.toFont),
style: TextStyle(fontWeight: FontWeight.bold, fontSize: 14.toFont),
),
actions: <Widget>[
TextButton(
Expand All @@ -142,10 +136,7 @@ class BackupKeyWidget extends StatelessWidget {
return Dialog(
child: Container(
padding: const EdgeInsets.all(20),
width:
(Platform.isMacOS || Platform.isWindows || Platform.isLinux)
? 600
: null,
width: (Platform.isMacOS || Platform.isWindows || Platform.isLinux) ? 600 : null,
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
Expand All @@ -161,8 +152,7 @@ class BackupKeyWidget extends StatelessWidget {
'PLEASE SECURELY SAVE YOUR KEYS. WE DO NOT HAVE ACCESS TO THEM AND CANNOT CREATE A BACKUP OR RESET THEM.',
targetShapeBorder: const CircleBorder(),
disableMovingAnimation: true,
targetBorderRadius:
const BorderRadius.all(Radius.circular(40)),
targetBorderRadius: const BorderRadius.all(Radius.circular(40)),
showArrow: false,
targetPadding: const EdgeInsets.all(5),
blurValue: 2,
Expand All @@ -182,9 +172,8 @@ class BackupKeyWidget extends StatelessWidget {
ShowCaseWidget.of(myContext!).startShowCase([key]);
},
child: Container(
decoration: BoxDecoration(
color: Colors.grey.shade400,
borderRadius: BorderRadius.circular(50)),
decoration:
BoxDecoration(color: Colors.grey.shade400, borderRadius: BorderRadius.circular(50)),
margin: const EdgeInsets.all(0),
height: 20,
width: 20,
Expand All @@ -210,9 +199,8 @@ class BackupKeyWidget extends StatelessWidget {
Row(
children: [
TextButton(
child: const Text(Strings.backButtonTitle,
style:
TextStyle(fontWeight: FontWeight.bold)),
child:
const Text(Strings.backButtonTitle, style: TextStyle(fontWeight: FontWeight.bold)),
onPressed: () async {
var result = await onBackup(context);
if (context.mounted) {
Expand All @@ -224,8 +212,7 @@ class BackupKeyWidget extends StatelessWidget {
}),
const Spacer(),
TextButton(
child: const Text(Strings.cancelButtonTitle,
style: TextStyle()),
child: const Text(Strings.cancelButtonTitle, style: TextStyle()),
onPressed: () {
Navigator.pop(context);
})
Expand Down Expand Up @@ -276,20 +263,17 @@ class BackupKeyWidget extends StatelessWidget {

String? dir = await getDownloadPath();
if (dir != null) {
String newPath =
"$dir/$atsign${Strings.backupKeyName}";
String newPath = "$dir/$atsign${Strings.backupKeyName}";
debugPrint(newPath);

try {
if (await File(newPath).exists()) {
if (context.mounted) {
Navigator.of(context).pop();
showSnackBar(
context: context, content: "File exists!");
showSnackBar(context: context, content: "File exists!");
}
} else {
final encryptedKeysFile =
await File(newPath).create();
final encryptedKeysFile = await File(newPath).create();
var keyString = jsonEncode(aesEncryptedKeys);
encryptedKeysFile.writeAsStringSync(keyString);
if (context.mounted) {
Expand Down Expand Up @@ -339,18 +323,15 @@ class BackupKeyWidget extends StatelessWidget {
var size = MediaQuery.of(context).size;
await Share.shareXFiles(
[XFile(tempFilePath)],
sharePositionOrigin:
Rect.fromLTWH(0, 0, size.width, size.height / 2),
sharePositionOrigin: Rect.fromLTWH(0, 0, size.width, size.height / 2),
).then((ShareResult shareResult) {
if (shareResult.status == ShareResultStatus.success) {
ScaffoldMessenger.of(context).showSnackBar(
const SnackBar(content: Text('File saved successfully')));
if (shareResult.status == ShareResultStatus.success && context.mounted) {
ScaffoldMessenger.of(context).showSnackBar(const SnackBar(content: Text('File saved successfully')));
}
});
}
} else {
final path = await getSaveLocation(
suggestedName: '$atsign${Strings.backupKeyName}');
final path = await getSaveLocation(suggestedName: '$atsign${Strings.backupKeyName}');
if (path == null) return;
final file = XFile(tempFilePath);
await file.saveTo(path.path);
Expand All @@ -377,8 +358,7 @@ class BackupKeyWidget extends StatelessWidget {

var directory = await path_provider.getApplicationSupportDirectory();
String path = directory.path.toString() + Platform.pathSeparator;
final encryptedKeysFile =
await File('$path$atsign${Strings.backupKeyName}').create();
final encryptedKeysFile = await File('$path$atsign${Strings.backupKeyName}').create();
var keyString = jsonEncode(aesEncryptedKeys);
encryptedKeysFile.writeAsStringSync(keyString);
return encryptedKeysFile.path;
Expand All @@ -387,9 +367,8 @@ class BackupKeyWidget extends StatelessWidget {
var keyString = jsonEncode(aesEncryptedKeys);
final List<int> codeUnits = keyString.codeUnits;
final Uint8List data = Uint8List.fromList(codeUnits);
String desktopPath = await FileSaver.instance.saveFile(
encryptedKeysFile, data, Strings.backupKeyExtension,
mimeType: MimeType.OTHER);
String desktopPath = await FileSaver.instance
.saveFile(encryptedKeysFile, data, Strings.backupKeyExtension, mimeType: MimeType.OTHER);
return desktopPath;
}
}
Expand All @@ -403,9 +382,8 @@ class BackupKeyWidget extends StatelessWidget {
[XFile(path)],
sharePositionOrigin: Rect.fromLTWH(0, 0, size.width, size.height / 2),
).then((ShareResult shareResult) {
if (shareResult.status == ShareResultStatus.success) {
ScaffoldMessenger.of(context).showSnackBar(
const SnackBar(content: Text('File saved successfully')));
if (shareResult.status == ShareResultStatus.success && context.mounted) {
ScaffoldMessenger.of(context).showSnackBar(const SnackBar(content: Text('File saved successfully')));
}
});
}
Expand Down
4 changes: 4 additions & 0 deletions packages/at_common_flutter/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 2.0.14
- **CHORE**: Addressed static analysis info and warning messages to improve code quality and reduce noise during analysis.
- **FIX**: Replace depreciated items with up-to-date-ones

## 2.0.13:
- **CHORE**: Major version increase of at_commons from ^3.0.55 to ^4.0.1

Expand Down
33 changes: 10 additions & 23 deletions packages/at_common_flutter/example/lib/main.dart
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import 'dart:async';
import 'dart:developer';

import 'package:at_common_flutter/at_common_flutter.dart';
import 'package:at_common_flutter/utils/text_styles.dart';
import 'package:flutter/material.dart';
import 'package:at_common_flutter/at_common_flutter.dart';

final StreamController<ThemeMode> updateThemeMode =
StreamController<ThemeMode>.broadcast();
final StreamController<ThemeMode> updateThemeMode = StreamController<ThemeMode>.broadcast();

void main() {
runApp(const MyApp());
Expand Down Expand Up @@ -57,7 +56,7 @@ class MyHomePage extends StatefulWidget {
final String? title;

@override
_MyHomePageState createState() => _MyHomePageState();
State<MyHomePage> createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
Expand All @@ -77,16 +76,12 @@ class _MyHomePageState extends State<MyHomePage> {
showTitle: true,
titleText: widget.title,
titleTextStyle: CustomTextStyles.primaryBold18.copyWith(
color: Theme.of(context).brightness == Brightness.light
? Colors.black
: Colors.white,
color: Theme.of(context).brightness == Brightness.light ? Colors.black : Colors.white,
),
showLeadingIcon: true,
leadingIcon: Icon(
Icons.home_outlined,
color: Theme.of(context).brightness == Brightness.light
? Colors.black
: Colors.white,
color: Theme.of(context).brightness == Brightness.light ? Colors.black : Colors.white,
),
onTrailingIconPressed: () {
log('Trailing icon of appbar pressed');
Expand All @@ -95,15 +90,11 @@ class _MyHomePageState extends State<MyHomePage> {
trailingIcon: Center(
child: IconButton(
onPressed: () {
updateThemeMode.sink.add(
Theme.of(context).brightness == Brightness.light
? ThemeMode.dark
: ThemeMode.light);
updateThemeMode.sink
.add(Theme.of(context).brightness == Brightness.light ? ThemeMode.dark : ThemeMode.light);
},
icon: Icon(
Theme.of(context).brightness == Brightness.light
? Icons.dark_mode_outlined
: Icons.light_mode_outlined,
Theme.of(context).brightness == Brightness.light ? Icons.dark_mode_outlined : Icons.light_mode_outlined,
color: Theme.of(context).colorScheme.secondary,
),
),
Expand Down Expand Up @@ -161,12 +152,8 @@ class _MyHomePageState extends State<MyHomePage> {
onPressed: () {
log('Custom button pressed');
},
buttonColor: Theme.of(context).brightness == Brightness.light
? Colors.black
: Colors.white,
fontColor: Theme.of(context).brightness == Brightness.light
? Colors.white
: Colors.black,
buttonColor: Theme.of(context).brightness == Brightness.light ? Colors.black : Colors.white,
fontColor: Theme.of(context).brightness == Brightness.light ? Colors.white : Colors.black,
),
],
),
Expand Down
4 changes: 2 additions & 2 deletions packages/at_common_flutter/example/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ dependencies:

# The following adds the Cupertino Icons font to your application.
# Use with the CupertinoIcons class for iOS style icons.
cupertino_icons: ^1.0.2
cupertino_icons: ^1.0.8
at_common_flutter:
path: ../

Expand All @@ -41,7 +41,7 @@ dependencies:
# activated in the `analysis_options.yaml` file located at the root of your
# package. See that file for information about deactivating specific lint
# rules and activating additional ones.
flutter_lints: ^1.0.0
flutter_lints: ^4.0.0


# For information on the generic Dart part of this file, see the
Expand Down
6 changes: 3 additions & 3 deletions packages/at_common_flutter/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: at_common_flutter
description: A Flutter package to provide common widgets used by other atPlatform Flutter packages.
version: 2.0.13
version: 2.0.14
homepage: https://docs.atsign.com/
repository: https://github.com/atsign-foundation/at_widgets/tree/trunk/packages/at_common_flutter
issue_tracker: https://github.com/atsign-foundation/at_widgets/issues
Expand All @@ -17,8 +17,8 @@ dependencies:
dev_dependencies:
flutter_test:
sdk: flutter
flutter_lints: ^2.0.1
mocktail: ^0.3.0
flutter_lints: ^4.0.0
mocktail: ^1.0.4


# For information on the generic Dart part of this file, see the
Expand Down
Loading

0 comments on commit a1545b6

Please sign in to comment.