diff --git a/lib/bademagic_module/utils/converters.dart b/lib/bademagic_module/utils/converters.dart index 6e8f07a9..482a9008 100644 --- a/lib/bademagic_module/utils/converters.dart +++ b/lib/bademagic_module/utils/converters.dart @@ -25,7 +25,14 @@ class Converters { if (key is List) { String filename = key[0]; List? decodedData = await fileHelper.readFromFile(filename); - final List> image = decodedData!.cast>(); + + // Handling the potential null case for decodedData + if (decodedData == null) { + // Optionally handle the null case, e.g., throw an exception, return a default value, or log the error. + throw Exception('Decoded data is null for the file: $filename'); + } + + final List> image = decodedData.cast>(); List> imageData = image.map((list) => list.cast()).toList(); hexStrings += convertBitmapToLEDHex(imageData, true); @@ -50,8 +57,7 @@ class Converters { return hexStrings; } - //function to convert the bitmap to the LED hex format - //it takes the 2D list of pixels and converts it to the LED hex format + // Function to convert the bitmap to the LED hex format static List convertBitmapToLEDHex( List> image, bool isDrawn) { // Determine the height and width of the image @@ -170,7 +176,7 @@ class Converters { return e.map((e) => e ? 1 : 0).toList(); }).toList(); - //add 1 at the satrt and end of each row in the 2D list + // Add 1 at the start and end of each row in the 2D list for (int i = 0; i < hexArray.length; i++) { hexArray[i].insert(0, 1); hexArray[i].add(1); diff --git a/lib/view/about_us_screen.dart b/lib/view/about_us_screen.dart index b19e7f63..7af5eaee 100644 --- a/lib/view/about_us_screen.dart +++ b/lib/view/about_us_screen.dart @@ -53,7 +53,7 @@ class _AboutUsScreenState extends State { padding: const EdgeInsets.all(16.0), child: Column( children: [ - SizedBox( + const SizedBox( height: 25, ), Center( @@ -74,40 +74,47 @@ class _AboutUsScreenState extends State { fontSize: 12), ), const SizedBox(height: 16), - Row( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - Text( - 'Developed by', - style: GoogleFonts.sora( - fontWeight: FontWeight.w500, - color: Colors.grey), - ), - SizedBox( - width: 10, - ), - GestureDetector( - onTap: () => openUrl( - 'https://github.com/fossasia/badge-magic-android'), - child: Text( - 'FOSSASIA contributors', - style: GoogleFonts.sora( - fontWeight: FontWeight.w500, - color: Colors.red, - decoration: TextDecoration.underline), + SingleChildScrollView( + scrollDirection: Axis.horizontal, + child: Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Flexible( + child: Text( + 'Developed by', + style: GoogleFonts.sora( + fontWeight: FontWeight.w500, + color: Colors.grey), + ), ), - ), - ], + const SizedBox( + width: 10, + ), + Flexible( + child: GestureDetector( + onTap: () => openUrl( + 'https://github.com/fossasia/badge-magic-android'), + child: Text( + 'FOSSASIA contributors', + style: GoogleFonts.sora( + fontWeight: FontWeight.w500, + color: Colors.red, + decoration: TextDecoration.underline), + ), + ), + ), + ], + ), ), ], ), ), ), - SizedBox(height: 10), + const SizedBox(height: 10), Container( decoration: BoxDecoration( color: Colors.white, - boxShadow: [ + boxShadow: const [ BoxShadow( blurRadius: 1, color: Colors.grey, @@ -119,7 +126,7 @@ class _AboutUsScreenState extends State { crossAxisAlignment: CrossAxisAlignment.start, children: [ Padding( - padding: EdgeInsets.only(left: 12.0, top: 12.0), + padding: const EdgeInsets.only(left: 12.0, top: 12.0), child: Text( 'Contact With Us', style: GoogleFonts.sora( @@ -151,13 +158,13 @@ class _AboutUsScreenState extends State { ], ), ), - SizedBox( + const SizedBox( height: 10, ), Container( decoration: BoxDecoration( color: Colors.white, - boxShadow: [ + boxShadow: const [ BoxShadow( blurRadius: 1, color: Colors.grey, diff --git a/lib/view/homescreen.dart b/lib/view/homescreen.dart index e306cb66..b344a99b 100644 --- a/lib/view/homescreen.dart +++ b/lib/view/homescreen.dart @@ -170,7 +170,7 @@ class _HomeScreenState extends State specialTextSpanBuilder: ImageBuilder(), decoration: InputDecoration( hintText: errorVal, - hintStyle: TextStyle(color: Colors.red), + hintStyle: const TextStyle(color: Colors.red), border: OutlineInputBorder( borderRadius: BorderRadius.circular(10.r), ), diff --git a/lib/view/widgets/about_us_daialog.dart b/lib/view/widgets/about_us_daialog.dart index afc98001..8470d3bc 100644 --- a/lib/view/widgets/about_us_daialog.dart +++ b/lib/view/widgets/about_us_daialog.dart @@ -22,7 +22,7 @@ class LicenseDialogContainer extends StatelessWidget { Row( crossAxisAlignment: CrossAxisAlignment.start, children: [ - SizedBox( + const SizedBox( width: 16, ), Text( @@ -39,7 +39,7 @@ class LicenseDialogContainer extends StatelessWidget { ], ), Padding( - padding: EdgeInsets.only(left: 16.0), + padding: const EdgeInsets.only(left: 16.0), child: GestureDetector( onTap: () => openUrl(url), child: Text( @@ -83,7 +83,7 @@ void showLicenseDialog(BuildContext context) { context: context, builder: (BuildContext context) { return Dialog( - insetPadding: EdgeInsets.all(8), + insetPadding: const EdgeInsets.all(8), backgroundColor: Colors.white, shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(8.0), @@ -94,9 +94,9 @@ void showLicenseDialog(BuildContext context) { children: [ Container( padding: const EdgeInsets.only(left: 16.0, top: 16, bottom: 8), - decoration: BoxDecoration( + decoration: const BoxDecoration( color: Colors.white, - borderRadius: const BorderRadius.only( + borderRadius: BorderRadius.only( topLeft: Radius.circular(10.0), topRight: Radius.circular(10.0), ), @@ -117,7 +117,7 @@ void showLicenseDialog(BuildContext context) { child: InteractiveViewer( minScale: 1.0, maxScale: 5.0, - child: SingleChildScrollView( + child: const SingleChildScrollView( child: Padding( padding: EdgeInsets.all(8.0), child: Column( diff --git a/lib/view/widgets/badge_delete_dialog.dart b/lib/view/widgets/badge_delete_dialog.dart index f0e7c190..51376350 100644 --- a/lib/view/widgets/badge_delete_dialog.dart +++ b/lib/view/widgets/badge_delete_dialog.dart @@ -26,11 +26,11 @@ class DeleteBadgeDialog extends StatelessWidget { ), Row( children: [ - SizedBox( + const SizedBox( width: 20, ), - Icon(Icons.delete, color: Colors.black), - SizedBox( + const Icon(Icons.delete, color: Colors.black), + const SizedBox( width: 10, ), Text( @@ -47,7 +47,7 @@ class DeleteBadgeDialog extends StatelessWidget { ), Row( children: [ - SizedBox( + const SizedBox( width: 20, ), Text('Are you sure want to delete this badge?', diff --git a/lib/view/widgets/save_badge_dialog.dart b/lib/view/widgets/save_badge_dialog.dart index c0afef32..d14226be 100644 --- a/lib/view/widgets/save_badge_dialog.dart +++ b/lib/view/widgets/save_badge_dialog.dart @@ -41,9 +41,9 @@ class SaveBadgeDialog extends StatelessWidget { crossAxisAlignment: CrossAxisAlignment.start, mainAxisAlignment: MainAxisAlignment.start, children: [ - Expanded( + const Expanded( flex: 1, - child: const Text( + child: Text( 'Save Badge', style: TextStyle( fontWeight: FontWeight.bold,