From e316348d5da778cca20ca115030d69797dbd166e Mon Sep 17 00:00:00 2001 From: Bhanuka Isuru Date: Mon, 27 Oct 2025 22:30:01 +0400 Subject: [PATCH] fix: replace deprecated withOpacity with withValues Replaces deprecated withOpacity() with withValues(alpha:) to resolve Flutter analyzer warnings from PR #294. - Updated 11 example files with 12 replacements - Verified with flutter analyze - no issues found --- example/audio_classification/lib/main.dart | 2 +- example/bertqa/lib/ui/qa_detail.dart | 2 +- example/digit_classification/lib/main.dart | 2 +- example/gesture_classification/lib/main.dart | 2 +- example/image_classification_mobilenet/lib/main.dart | 2 +- example/image_segmentation/lib/main.dart | 4 ++-- example/object_detection_ssd_mobilenet/lib/main.dart | 2 +- example/object_detection_ssd_mobilenet_v2/lib/main.dart | 2 +- example/pose_estimation/lib/main.dart | 2 +- example/style_transfer/lib/main.dart | 2 +- example/super_resolution_esrgan/lib/main.dart | 2 +- 11 files changed, 12 insertions(+), 12 deletions(-) diff --git a/example/audio_classification/lib/main.dart b/example/audio_classification/lib/main.dart index e65a6ee..f0609ea 100644 --- a/example/audio_classification/lib/main.dart +++ b/example/audio_classification/lib/main.dart @@ -186,7 +186,7 @@ class _MyHomePageState extends State { backgroundColor: Colors.white, appBar: AppBar( title: Image.asset('assets/images/tfl_logo.png'), - backgroundColor: Colors.black.withOpacity(0.5), + backgroundColor: Colors.black.withValues(alpha: 0.5), ), body: _buildBody(), ); diff --git a/example/bertqa/lib/ui/qa_detail.dart b/example/bertqa/lib/ui/qa_detail.dart index 0271923..9f7d0df 100644 --- a/example/bertqa/lib/ui/qa_detail.dart +++ b/example/bertqa/lib/ui/qa_detail.dart @@ -140,7 +140,7 @@ class _QaDetailState extends State { padding: const EdgeInsets.all(16), decoration: BoxDecoration(color: Colors.white, boxShadow: [ BoxShadow( - color: Colors.grey.withOpacity(0.5), + color: Colors.grey.withValues(alpha: 0.5), spreadRadius: 2, blurRadius: 5, offset: const Offset(0, 3)) diff --git a/example/digit_classification/lib/main.dart b/example/digit_classification/lib/main.dart index b9c3145..dc90359 100644 --- a/example/digit_classification/lib/main.dart +++ b/example/digit_classification/lib/main.dart @@ -91,7 +91,7 @@ class _MyHomePageState extends State { title: Center( child: Image.asset('assets/images/tfl_logo.png'), ), - backgroundColor: Colors.black.withOpacity(0.5), + backgroundColor: Colors.black.withValues(alpha: 0.5), ), body: Center( child: Column( diff --git a/example/gesture_classification/lib/main.dart b/example/gesture_classification/lib/main.dart index 803e967..9cb9d15 100644 --- a/example/gesture_classification/lib/main.dart +++ b/example/gesture_classification/lib/main.dart @@ -166,7 +166,7 @@ class _MyHomePageState extends State with WidgetsBindingObserver { title: Center( child: Image.asset('assets/images/tfl_logo.png'), ), - backgroundColor: Colors.black.withOpacity(0.5), + backgroundColor: Colors.black.withValues(alpha: 0.5), ), body: Center( // Center is a layout widget. It takes a single child and positions it diff --git a/example/image_classification_mobilenet/lib/main.dart b/example/image_classification_mobilenet/lib/main.dart index fad0275..3eacfab 100644 --- a/example/image_classification_mobilenet/lib/main.dart +++ b/example/image_classification_mobilenet/lib/main.dart @@ -88,7 +88,7 @@ class _BottomNavigationBarExampleState return Scaffold( appBar: AppBar( title: Image.asset('assets/images/tfl_logo.png'), - backgroundColor: Colors.black.withOpacity(0.5), + backgroundColor: Colors.black.withValues(alpha: 0.5), ), body: Center( child: _widgetOptions?.elementAt(_selectedIndex), diff --git a/example/image_segmentation/lib/main.dart b/example/image_segmentation/lib/main.dart index c8c8fbe..5bb80af 100644 --- a/example/image_segmentation/lib/main.dart +++ b/example/image_segmentation/lib/main.dart @@ -226,7 +226,7 @@ class _MyHomePageState extends State with WidgetsBindingObserver { // parse color from label color color: Color(ImageSegmentationHelper .labelColors[_labelsIndex![index]]) - .withOpacity(0.5), + .withValues(alpha: 0.5), borderRadius: BorderRadius.circular(8), ), child: Text( @@ -251,7 +251,7 @@ class _MyHomePageState extends State with WidgetsBindingObserver { title: Center( child: Image.asset('assets/images/tfl_logo.png'), ), - backgroundColor: Colors.black.withOpacity(0.5), + backgroundColor: Colors.black.withValues(alpha: 0.5), ), body: cameraWidget(context), ); diff --git a/example/object_detection_ssd_mobilenet/lib/main.dart b/example/object_detection_ssd_mobilenet/lib/main.dart index 12819e7..4556e11 100644 --- a/example/object_detection_ssd_mobilenet/lib/main.dart +++ b/example/object_detection_ssd_mobilenet/lib/main.dart @@ -64,7 +64,7 @@ class _MyHomeState extends State { return Scaffold( appBar: AppBar( title: Image.asset('assets/images/tfl_logo.png'), - backgroundColor: Colors.black.withOpacity(0.5), + backgroundColor: Colors.black.withValues(alpha: 0.5), ), body: SafeArea( child: Column( diff --git a/example/object_detection_ssd_mobilenet_v2/lib/main.dart b/example/object_detection_ssd_mobilenet_v2/lib/main.dart index 8071e39..7027ba5 100644 --- a/example/object_detection_ssd_mobilenet_v2/lib/main.dart +++ b/example/object_detection_ssd_mobilenet_v2/lib/main.dart @@ -49,7 +49,7 @@ class _MyHomeState extends State { return Scaffold( appBar: AppBar( title: Image.asset('assets/images/tfl_logo.png'), - backgroundColor: Colors.black.withOpacity(0.5), + backgroundColor: Colors.black.withValues(alpha: 0.5), ), body: SafeArea( child: Column( diff --git a/example/pose_estimation/lib/main.dart b/example/pose_estimation/lib/main.dart index 82336c0..3ded2c3 100644 --- a/example/pose_estimation/lib/main.dart +++ b/example/pose_estimation/lib/main.dart @@ -180,7 +180,7 @@ class _MyHomePageState extends State with WidgetsBindingObserver { title: Center( child: Image.asset('assets/images/tfl_logo.png'), ), - backgroundColor: Colors.black.withOpacity(0.5), + backgroundColor: Colors.black.withValues(alpha: 0.5), ), body: resultWidget(context), ); diff --git a/example/style_transfer/lib/main.dart b/example/style_transfer/lib/main.dart index dbd2ad3..67136cd 100644 --- a/example/style_transfer/lib/main.dart +++ b/example/style_transfer/lib/main.dart @@ -291,7 +291,7 @@ class _HomeState extends State { return Scaffold( appBar: AppBar( title: Image.asset('assets/images/tfl_logo.png'), - backgroundColor: Colors.black.withOpacity(0.5), + backgroundColor: Colors.black.withValues(alpha: 0.5), ), body: SafeArea( child: Center( diff --git a/example/super_resolution_esrgan/lib/main.dart b/example/super_resolution_esrgan/lib/main.dart index 72bb7c3..9964e2d 100644 --- a/example/super_resolution_esrgan/lib/main.dart +++ b/example/super_resolution_esrgan/lib/main.dart @@ -181,7 +181,7 @@ class _HomeState extends State { return Scaffold( appBar: AppBar( title: Image.asset('assets/images/tfl_logo.png'), - backgroundColor: Colors.black.withOpacity(0.5), + backgroundColor: Colors.black.withValues(alpha: 0.5), ), body: SafeArea( child: Center(