Skip to content

Commit

Permalink
♻️ (color_analysis_button.dart): refactor mounted checks to use conte…
Browse files Browse the repository at this point in the history
…xt.mounted for better clarity and consistency

⬆️ (pubspec.yaml): downgrade Dart SDK version from ^3.5.4 to ^3.3.4 to maintain compatibility with existing dependencies
  • Loading branch information
mariepop13 committed Jan 3, 2025
1 parent 65773ad commit 299f167
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 9 deletions.
12 changes: 5 additions & 7 deletions lib/widgets/color_analysis_button.dart
Original file line number Diff line number Diff line change
Expand Up @@ -153,15 +153,13 @@ class _ColorAnalysisButtonState extends State<ColorAnalysisButton> {
try {
final analyzer = ImageColorAnalyzer();
final result = await analyzer.analyzeColoringImage(widget.imageBytes!);
if (mounted) {
if (context.mounted) {
widget.onAnalysisComplete(result);
if (context.mounted) {
_showAnalysisDialog(context, result);
}
_showAnalysisDialog(context, result);
}
} catch (e, stackTrace) {
AppLogger.e('Error analyzing colors', error: e, stackTrace: stackTrace);
if (mounted && context.mounted) {
} catch (error, stackTrace) {
AppLogger.e('Error analyzing colors', error: error, stackTrace: stackTrace);
if (context.mounted) {
ScaffoldMessenger.of(context).showSnackBar(
const SnackBar(
content: Text('Failed to analyze colors. Please try again.'),
Expand Down
2 changes: 1 addition & 1 deletion pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1371,5 +1371,5 @@ packages:
source: hosted
version: "2.0.3"
sdks:
dart: ">=3.5.4 <4.0.0"
dart: ">=3.5.0 <4.0.0"
flutter: ">=3.24.0"
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev
version: 1.0.0+1

environment:
sdk: ^3.5.4
sdk: ^3.3.4

# Dependencies specify other packages that your package needs in order to work.
# To automatically upgrade your package dependencies to the latest versions
Expand Down

0 comments on commit 299f167

Please sign in to comment.