From 92e79630f3d6d765bf14559f961a40213da7b5eb Mon Sep 17 00:00:00 2001 From: Andrea Bizzotto Date: Wed, 26 Jun 2024 16:03:12 +0100 Subject: [PATCH] Fix DCM rule violations, disable some rules --- analysis_options.yaml | 38 ++++----- lib/src/constants/breakpoints.dart | 6 +- lib/src/features/about_me/about_me.dart | 27 ++++--- lib/src/features/app_header/app_header.dart | 81 ++++++++++--------- .../app_header/mobile_navigation_menu.dart | 13 +-- .../features/app_header/navigation_link.dart | 11 +-- .../features/cards/border_mouse_hover.dart | 29 +++---- .../features/cards/featured_tutorials.dart | 25 +++--- lib/src/features/cards/flutter_courses.dart | 7 +- lib/src/features/cards/item_card.dart | 17 ++-- .../common_widgets/email_signup_button.dart | 18 +++-- .../common_widgets/email_text_field.dart | 7 +- .../features/email_footer/email_footer.dart | 7 +- lib/src/features/footer/footer.dart | 4 +- lib/src/features/intro/email_signup.dart | 23 +++--- lib/src/features/intro/intro.dart | 2 +- lib/src/features/intro/intro_header.dart | 11 ++- .../testimonials/testimonial_card.dart | 20 +++-- .../features/testimonials/testimonials.dart | 24 +++--- lib/src/tags.dart | 2 +- 20 files changed, 203 insertions(+), 169 deletions(-) diff --git a/analysis_options.yaml b/analysis_options.yaml index 61b6c4d..ace2201 100644 --- a/analysis_options.yaml +++ b/analysis_options.yaml @@ -1,29 +1,19 @@ -# This file configures the analyzer, which statically analyzes Dart code to -# check for errors, warnings, and lints. -# -# The issues identified by the analyzer are surfaced in the UI of Dart-enabled -# IDEs (https://dart.dev/tools#ides-and-editors). The analyzer can also be -# invoked from the command line by running `flutter analyze`. - -# The following line activates a set of recommended lints for Flutter apps, -# packages, and plugins designed to encourage good coding practices. include: package:flutter_lints/flutter.yaml linter: - # The lint rules applied to this project can be customized in the - # section below to disable rules from the `package:flutter_lints/flutter.yaml` - # included above or to enable additional rules. A list of all available lints - # and their documentation is published at - # https://dart-lang.github.io/linter/lints/index.html. - # - # Instead of disabling a lint rule for the entire project in the - # section below, it can also be suppressed for a single line of code - # or a specific dart file by using the `// ignore: name_of_lint` and - # `// ignore_for_file: name_of_lint` syntax on the line or in the file - # producing the lint. rules: - # avoid_print: false # Uncomment to disable the `avoid_print` rule - # prefer_single_quotes: true # Uncomment to enable the `prefer_single_quotes` rule -# Additional information about this file can be found at -# https://dart.dev/guides/language/analysis-options +dart_code_metrics: + extends: + - recommended + rules: + - prefer-trailing-comma: false + - prefer-single-widget-per-file: false + - unnecessary-trailing-comma: false + - avoid-shadowing: false + - prefer-match-file-name: false + - no-empty-block: false + - avoid-unsafe-collection-methods: false + - avoid-redundant-else: false + - avoid-missing-controller: false + - prefer-correct-callback-field-name: false \ No newline at end of file diff --git a/lib/src/constants/breakpoints.dart b/lib/src/constants/breakpoints.dart index 4720ca0..1a2a268 100644 --- a/lib/src/constants/breakpoints.dart +++ b/lib/src/constants/breakpoints.dart @@ -11,9 +11,8 @@ double horizontalPadding(double screenWidth) { return 0; } else if (screenWidth > Breakpoints.mobile) { return 28; - } else { - return 20; } + return 20; } double sliverHorizontalPadding(double screenWidth) { @@ -21,7 +20,6 @@ double sliverHorizontalPadding(double screenWidth) { return (screenWidth - Breakpoints.desktop) / 2; } else if (screenWidth > Breakpoints.mobile) { return 28; - } else { - return 20; } + return 20; } diff --git a/lib/src/features/about_me/about_me.dart b/lib/src/features/about_me/about_me.dart index 62eb1ab..4447a47 100644 --- a/lib/src/features/about_me/about_me.dart +++ b/lib/src/features/about_me/about_me.dart @@ -10,7 +10,7 @@ class AboutMe extends StatelessWidget { @override Widget build(BuildContext context) { - final screenWidth = MediaQuery.of(context).size.width; + final screenWidth = MediaQuery.sizeOf(context).width; return Center( child: SizedBox( width: Breakpoints.desktop.toDouble(), @@ -50,12 +50,10 @@ class AboutMeContent extends StatelessWidget { @override Widget build(BuildContext context) { - final screenWidth = MediaQuery.of(context).size.width; - if (screenWidth > Breakpoints.tablet) { - return const AboutMeContentDesktop(); - } else { - return const AboutMeContentMobile(); - } + final screenWidth = MediaQuery.sizeOf(context).width; + return screenWidth > Breakpoints.tablet + ? const AboutMeContentDesktop() + : const AboutMeContentMobile(); } } @@ -64,7 +62,7 @@ class AboutMeContentDesktop extends StatelessWidget { @override Widget build(BuildContext context) { - final screenWidth = MediaQuery.of(context).size.width; + final screenWidth = MediaQuery.sizeOf(context).width; final fontSize = screenWidth > Breakpoints.tablet ? 36.0 : (screenWidth > 640 ? 27.0 : 24.0); @@ -106,7 +104,7 @@ class AboutMeContentDesktop extends StatelessWidget { .copyWith(color: AppColors.neutral2), ), ), - ) + ), ], ), const SizedBox(height: 96), @@ -123,7 +121,7 @@ class AboutMeContentDesktop extends StatelessWidget { child: AboutParagraph2(), ), ], - ) + ), ], ); } @@ -134,7 +132,7 @@ class AboutMeContentMobile extends StatelessWidget { @override Widget build(BuildContext context) { - final screenWidth = MediaQuery.of(context).size.width; + final screenWidth = MediaQuery.sizeOf(context).width; final fontSize = screenWidth > Breakpoints.tablet ? 36.0 : (screenWidth > 640 ? 27.0 : 24.0); @@ -197,8 +195,11 @@ Happy coding! } class AboutParagraph extends StatelessWidget { - const AboutParagraph( - {super.key, required this.heading, required this.content}); + const AboutParagraph({ + super.key, + required this.heading, + required this.content, + }); final String heading; final String content; diff --git a/lib/src/features/app_header/app_header.dart b/lib/src/features/app_header/app_header.dart index d60bd8d..3b64ac4 100644 --- a/lib/src/features/app_header/app_header.dart +++ b/lib/src/features/app_header/app_header.dart @@ -11,7 +11,7 @@ class AppHeader extends StatelessWidget { @override Widget build(BuildContext context) { - final screenWidth = MediaQuery.of(context).size.width; + final screenWidth = MediaQuery.sizeOf(context).width; bool isWide = screenWidth > Breakpoints.tablet; return Container( color: AppColors.neutral7, @@ -27,7 +27,7 @@ class DesktopNavigationLayout extends StatelessWidget { @override Widget build(BuildContext context) { - final screenWidth = MediaQuery.of(context).size.width; + final screenWidth = MediaQuery.sizeOf(context).width; bool isVeryWide = screenWidth > Breakpoints.desktop; return SizedBox( height: 64, @@ -60,7 +60,15 @@ class MobileNavigationLayout extends StatefulWidget { class _MobileNavigationLayoutState extends State with SingleTickerProviderStateMixin { late final _menuController = AnimationController( - vsync: this, duration: const Duration(milliseconds: 150)); + vsync: this, + duration: const Duration(milliseconds: 150), + ); + + @override + void dispose() { + _menuController.dispose(); + super.dispose(); + } void _toggleMenu() { if (_menuController.isCompleted) { @@ -73,40 +81,41 @@ class _MobileNavigationLayoutState extends State @override Widget build(BuildContext context) { return AnimatedBuilder( - animation: _menuController, - builder: (context, _) { - final height = - 64 + _menuController.value * MobileNavigationMenu.menuHeight; - return SizedBox( - height: height, - child: Column( - children: [ - SizedBox( - height: 64, - child: Row( - crossAxisAlignment: CrossAxisAlignment.center, - children: [ - const SizedBox(width: 28), - Assets.appLogo.image(), - const Spacer(), - NavigationIconButton(child: Assets.search.image()), - GestureDetector( - onTap: _toggleMenu, - child: AnimatedIcon( - icon: AnimatedIcons.menu_close, - progress: _menuController, - color: AppColors.neutral2, - ), + animation: _menuController, + builder: (context, _) { + final height = + 64 + _menuController.value * MobileNavigationMenu.menuHeight; + return SizedBox( + height: height, + child: Column( + children: [ + SizedBox( + height: 64, + child: Row( + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + const SizedBox(width: 28), + Assets.appLogo.image(), + const Spacer(), + NavigationIconButton(child: Assets.search.image()), + GestureDetector( + onTap: _toggleMenu, + child: AnimatedIcon( + icon: AnimatedIcons.menu_close, + progress: _menuController, + color: AppColors.neutral2, ), - //NavigationIconButton(assetName: Constants.hamburgerMenu), - const SizedBox(width: 28), - ], - ), + ), + //NavigationIconButton(assetName: Constants.hamburgerMenu), + const SizedBox(width: 28), + ], ), - const Expanded(child: MobileNavigationMenu()), - ], - ), - ); - }); + ), + const Expanded(child: MobileNavigationMenu()), + ], + ), + ); + }, + ); } } diff --git a/lib/src/features/app_header/mobile_navigation_menu.dart b/lib/src/features/app_header/mobile_navigation_menu.dart index d4acc81..843f4f8 100644 --- a/lib/src/features/app_header/mobile_navigation_menu.dart +++ b/lib/src/features/app_header/mobile_navigation_menu.dart @@ -30,7 +30,7 @@ class MobileNavigationMenu extends StatelessWidget { height: 64.0, alignment: Alignment.center, child: MobileToggleButton(onPressed: () {}), - ) + ), ], ), ); @@ -78,11 +78,12 @@ class MobileToggleButton extends StatelessWidget { children: [ Assets.toggleDay.image(), const SizedBox(width: 12), - Text('Switch to light mode', - style: Theme.of(context) - .textTheme - .titleSmall! - .copyWith(color: Colors.white)), + Text( + 'Switch to light mode', + style: Theme.of(context).textTheme.titleSmall!.copyWith( + color: Colors.white, + ), + ), ], ), ), diff --git a/lib/src/features/app_header/navigation_link.dart b/lib/src/features/app_header/navigation_link.dart index 05ec35e..dd6efff 100644 --- a/lib/src/features/app_header/navigation_link.dart +++ b/lib/src/features/app_header/navigation_link.dart @@ -10,11 +10,12 @@ class NavigationLink extends StatelessWidget { child: Padding( padding: const EdgeInsets.symmetric(horizontal: 8), child: TextButton( - child: Text(text, - style: Theme.of(context) - .textTheme - .titleSmall! - .copyWith(color: Colors.white)), + child: Text( + text, + style: Theme.of(context).textTheme.titleSmall!.copyWith( + color: Colors.white, + ), + ), onPressed: () {}, ), ), diff --git a/lib/src/features/cards/border_mouse_hover.dart b/lib/src/features/cards/border_mouse_hover.dart index 1229edf..060044b 100644 --- a/lib/src/features/cards/border_mouse_hover.dart +++ b/lib/src/features/cards/border_mouse_hover.dart @@ -31,22 +31,23 @@ class _BorderMouseHoverState extends State animation: _controller, builder: (context, _) { return Container( - margin: const EdgeInsets.all(2), + margin: const EdgeInsets.all(2), + decoration: BoxDecoration( + color: Colors.transparent, // AppColors.neutral5, + border: Border.all( + color: AppColors.primary.withOpacity(_controller.value), + width: 2, + ), + borderRadius: BorderRadius.circular(18), + ), + child: DecoratedBox( decoration: BoxDecoration( - color: Colors.transparent, // AppColors.neutral5, - border: Border.all( - color: AppColors.primary.withOpacity(_controller.value), - width: 2, - ), - borderRadius: BorderRadius.circular(18), + color: AppColors.neutral6, + borderRadius: BorderRadius.circular(16), ), - child: DecoratedBox( - decoration: BoxDecoration( - color: AppColors.neutral6, - borderRadius: BorderRadius.circular(16), - ), - child: widget.builder(context, _controller.value), - )); + child: widget.builder(context, _controller.value), + ), + ); }, ), ); diff --git a/lib/src/features/cards/featured_tutorials.dart b/lib/src/features/cards/featured_tutorials.dart index 479e63e..9a051d6 100644 --- a/lib/src/features/cards/featured_tutorials.dart +++ b/lib/src/features/cards/featured_tutorials.dart @@ -9,7 +9,7 @@ class FeaturedTutorialsHeader extends StatelessWidget { @override Widget build(BuildContext context) { - final screenWidth = MediaQuery.of(context).size.width; + final screenWidth = MediaQuery.sizeOf(context).width; return Center( child: SizedBox( width: Breakpoints.desktop.toDouble(), @@ -51,12 +51,13 @@ class FeaturedTutorialsContent extends StatelessWidget { @override Widget build(BuildContext context) { - final screenWidth = MediaQuery.of(context).size.width; + final screenWidth = MediaQuery.sizeOf(context).width; final crossAxisCount = screenWidth >= Breakpoints.twoColLayoutMinWidth ? 2 : 1; return SliverPadding( padding: EdgeInsets.symmetric( - horizontal: sliverHorizontalPadding(screenWidth)), + horizontal: sliverHorizontalPadding(screenWidth), + ), sliver: SliverAlignedGrid.count( crossAxisCount: crossAxisCount, mainAxisSpacing: 24, @@ -75,7 +76,7 @@ class FeaturedTutorialsFooter extends StatelessWidget { @override Widget build(BuildContext context) { - final screenWidth = MediaQuery.of(context).size.width; + final screenWidth = MediaQuery.sizeOf(context).width; if (screenWidth <= Breakpoints.twoColLayoutMinWidth) { return const Column( children: [ @@ -83,10 +84,8 @@ class FeaturedTutorialsFooter extends StatelessWidget { ExploreTutorialsButton(), ], ); - } else { - // TODO: return something more lightweight - return const SizedBox(); } + return const SizedBox.shrink(); } } @@ -97,12 +96,12 @@ class ExploreTutorialsButton extends StatelessWidget { Widget build(BuildContext context) { return ElevatedButton( style: ElevatedButton.styleFrom( - foregroundColor: AppColors.primary7, - backgroundColor: AppColors.secondary, - splashFactory: NoSplash.splashFactory, - padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 12), - shape: - RoundedRectangleBorder(borderRadius: BorderRadius.circular(6))), + foregroundColor: AppColors.primary7, + backgroundColor: AppColors.secondary, + splashFactory: NoSplash.splashFactory, + padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 12), + shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(6)), + ), child: Text( 'Explore More Tutorials →', textAlign: TextAlign.center, diff --git a/lib/src/features/cards/flutter_courses.dart b/lib/src/features/cards/flutter_courses.dart index 7551475..306ab10 100644 --- a/lib/src/features/cards/flutter_courses.dart +++ b/lib/src/features/cards/flutter_courses.dart @@ -9,7 +9,7 @@ class FlutterCoursesHeader extends StatelessWidget { @override Widget build(BuildContext context) { - final screenWidth = MediaQuery.of(context).size.width; + final screenWidth = MediaQuery.sizeOf(context).width; return Center( child: SizedBox( width: Breakpoints.desktop.toDouble(), @@ -50,12 +50,13 @@ class FlutterCoursesContent extends StatelessWidget { @override Widget build(BuildContext context) { - final screenWidth = MediaQuery.of(context).size.width; + final screenWidth = MediaQuery.sizeOf(context).width; final crossAxisCount = screenWidth >= Breakpoints.twoColLayoutMinWidth ? 2 : 1; return SliverPadding( padding: EdgeInsets.symmetric( - horizontal: sliverHorizontalPadding(screenWidth)), + horizontal: sliverHorizontalPadding(screenWidth), + ), sliver: SliverAlignedGrid.count( crossAxisCount: crossAxisCount, mainAxisSpacing: 24, diff --git a/lib/src/features/cards/item_card.dart b/lib/src/features/cards/item_card.dart index fba8dea..3a4afdd 100644 --- a/lib/src/features/cards/item_card.dart +++ b/lib/src/features/cards/item_card.dart @@ -108,7 +108,7 @@ class ItemCard extends StatelessWidget { final ItemCardData data; @override Widget build(BuildContext context) { - final screenWidth = MediaQuery.of(context).size.width; + final screenWidth = MediaQuery.sizeOf(context).width; final horizontalPadding = screenWidth >= Breakpoints.tablet ? 32.0 : 20.0; final verticalPadding = screenWidth >= Breakpoints.tablet ? 24.0 : 16.0; return BorderMouseHover( @@ -132,7 +132,9 @@ class ItemCard extends StatelessWidget { ), Padding( padding: EdgeInsets.symmetric( - horizontal: horizontalPadding, vertical: verticalPadding), + horizontal: horizontalPadding, + vertical: verticalPadding, + ), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ @@ -169,8 +171,11 @@ class ItemCard extends StatelessWidget { } class ItemMetadataWidget extends StatelessWidget { - const ItemMetadataWidget( - {super.key, required this.startText, required this.endText}); + const ItemMetadataWidget({ + super.key, + required this.startText, + required this.endText, + }); final String startText; final String endText; @@ -230,7 +235,9 @@ class ItemMetadataTags extends StatelessWidget { label: Text( tag, style: Theme.of(context).textTheme.titleSmall!.copyWith( - fontWeight: FontWeight.normal, color: tag.color().color), + fontWeight: FontWeight.normal, + color: tag.color().color, + ), ), ), ], diff --git a/lib/src/features/common_widgets/email_signup_button.dart b/lib/src/features/common_widgets/email_signup_button.dart index e02c3f0..b94e87e 100644 --- a/lib/src/features/common_widgets/email_signup_button.dart +++ b/lib/src/features/common_widgets/email_signup_button.dart @@ -1,8 +1,11 @@ import 'package:flutter/material.dart'; class EmailSignupButton extends StatelessWidget { - const EmailSignupButton( - {super.key, required this.primary, required this.onPrimary}); + const EmailSignupButton({ + super.key, + required this.primary, + required this.onPrimary, + }); final Color primary; final Color onPrimary; @@ -10,10 +13,13 @@ class EmailSignupButton extends StatelessWidget { Widget build(BuildContext context) { return ElevatedButton( style: ElevatedButton.styleFrom( - foregroundColor: onPrimary, backgroundColor: primary, - splashFactory: NoSplash.splashFactory, - shape: - RoundedRectangleBorder(borderRadius: BorderRadius.circular(6))), + foregroundColor: onPrimary, + backgroundColor: primary, + splashFactory: NoSplash.splashFactory, + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(6), + ), + ), child: Text( 'Get the course', textAlign: TextAlign.center, diff --git a/lib/src/features/common_widgets/email_text_field.dart b/lib/src/features/common_widgets/email_text_field.dart index 0829fe9..f14d7a5 100644 --- a/lib/src/features/common_widgets/email_text_field.dart +++ b/lib/src/features/common_widgets/email_text_field.dart @@ -2,8 +2,11 @@ import 'package:code_with_andrea_flutter/src/constants/app_colors.dart'; import 'package:flutter/material.dart'; class EmailTextField extends StatelessWidget { - const EmailTextField( - {super.key, required this.fillColor, required this.hintColor}); + const EmailTextField({ + super.key, + required this.fillColor, + required this.hintColor, + }); final Color fillColor; // AppColors.neutral5 final Color hintColor; // AppColors.neutral2 diff --git a/lib/src/features/email_footer/email_footer.dart b/lib/src/features/email_footer/email_footer.dart index 7cf8c4c..6865961 100644 --- a/lib/src/features/email_footer/email_footer.dart +++ b/lib/src/features/email_footer/email_footer.dart @@ -1,4 +1,3 @@ - import 'package:code_with_andrea_flutter/src/constants/app_colors.dart'; import 'package:code_with_andrea_flutter/src/constants/breakpoints.dart'; import 'package:code_with_andrea_flutter/src/features/common_widgets/email_signup_button.dart'; @@ -10,7 +9,7 @@ class EmailFooterSection extends StatelessWidget { @override Widget build(BuildContext context) { - final screenWidth = MediaQuery.of(context).size.width; + final screenWidth = MediaQuery.sizeOf(context).width; return Container( color: AppColors.primary, child: Center( @@ -76,7 +75,9 @@ class EmailFormFooterText extends StatelessWidget { TextSpan( text: 'newsletter page', style: Theme.of(context).textTheme.bodyLarge!.copyWith( - color: Colors.white, decoration: TextDecoration.underline), + color: Colors.white, + decoration: TextDecoration.underline, + ), ), TextSpan( text: ' to learn what\'s inside.', diff --git a/lib/src/features/footer/footer.dart b/lib/src/features/footer/footer.dart index f89937d..0e25787 100644 --- a/lib/src/features/footer/footer.dart +++ b/lib/src/features/footer/footer.dart @@ -8,7 +8,7 @@ class Footer extends StatelessWidget { @override Widget build(BuildContext context) { - final screenWidth = MediaQuery.of(context).size.width; + final screenWidth = MediaQuery.sizeOf(context).width; final isWide = screenWidth > Breakpoints.tablet; return Center( child: SizedBox( @@ -50,7 +50,7 @@ class FooterLinks extends StatelessWidget { @override Widget build(BuildContext context) { - final screenWidth = MediaQuery.of(context).size.width; + final screenWidth = MediaQuery.sizeOf(context).width; final isWide = screenWidth > Breakpoints.tablet; if (isWide) { return const Row( diff --git a/lib/src/features/intro/email_signup.dart b/lib/src/features/intro/email_signup.dart index eafc0de..a0a2faa 100644 --- a/lib/src/features/intro/email_signup.dart +++ b/lib/src/features/intro/email_signup.dart @@ -9,7 +9,7 @@ class EmailSignup extends StatelessWidget { @override Widget build(BuildContext context) { - final screenWidth = MediaQuery.of(context).size.width; + final screenWidth = MediaQuery.sizeOf(context).width; bool isWide = screenWidth > Breakpoints.tablet; final width = isWide ? 522.0 : 337.0; return SizedBox( @@ -40,12 +40,13 @@ class EmailSignup extends StatelessWidget { .copyWith(color: AppColors.neutral3), children: const [ TextSpan( - text: 'Flutter email course & newsletter:', - style: TextStyle( - //fontWeight: FontWeight.bold, - color: AppColors.neutral2, - decoration: TextDecoration.underline, - )), + text: 'Flutter email course & newsletter:', + style: TextStyle( + //fontWeight: FontWeight.bold, + color: AppColors.neutral2, + decoration: TextDecoration.underline, + ), + ), ], ), textAlign: TextAlign.center, @@ -66,7 +67,9 @@ class EmailSignup extends StatelessWidget { 'Andy Drexler', textAlign: TextAlign.center, style: Theme.of(context).textTheme.titleSmall!.copyWith( - fontWeight: FontWeight.normal, color: AppColors.neutral4), + fontWeight: FontWeight.normal, + color: AppColors.neutral4, + ), ), const SizedBox(height: 120), ], @@ -81,7 +84,7 @@ class EmailSignupForm extends StatelessWidget { @override Widget build(BuildContext context) { - final screenWidth = MediaQuery.of(context).size.width; + final screenWidth = MediaQuery.sizeOf(context).width; bool isWide = screenWidth > Breakpoints.tablet; if (isWide) { return const SizedBox( @@ -96,7 +99,7 @@ class EmailSignupForm extends StatelessWidget { SizedBox(width: 16), Expanded( child: IntroEmailSignupButton(), - ) + ), ], ), ); diff --git a/lib/src/features/intro/intro.dart b/lib/src/features/intro/intro.dart index b2720fc..88bfdfc 100644 --- a/lib/src/features/intro/intro.dart +++ b/lib/src/features/intro/intro.dart @@ -10,7 +10,7 @@ class Intro extends StatelessWidget { @override Widget build(BuildContext context) { - final screenWidth = MediaQuery.of(context).size.width; + final screenWidth = MediaQuery.sizeOf(context).width; return Center( child: Stack( children: [ diff --git a/lib/src/features/intro/intro_header.dart b/lib/src/features/intro/intro_header.dart index 088557a..f8a7963 100644 --- a/lib/src/features/intro/intro_header.dart +++ b/lib/src/features/intro/intro_header.dart @@ -18,7 +18,7 @@ class IntroHeader extends StatelessWidget { @override Widget build(BuildContext context) { - final screenWidth = MediaQuery.of(context).size.width; + final screenWidth = MediaQuery.sizeOf(context).width; return SizedBox( width: 880, child: Padding( @@ -46,9 +46,12 @@ class IntroHeader extends StatelessWidget { .copyWith(color: AppColors.neutral2), children: const [ TextSpan( - text: 'all for free!', - style: TextStyle( - fontWeight: FontWeight.bold, color: Colors.white)), + text: 'all for free!', + style: TextStyle( + fontWeight: FontWeight.bold, + color: Colors.white, + ), + ), ], ), textAlign: TextAlign.center, diff --git a/lib/src/features/testimonials/testimonial_card.dart b/lib/src/features/testimonials/testimonial_card.dart index 87a9867..12ca2c3 100644 --- a/lib/src/features/testimonials/testimonial_card.dart +++ b/lib/src/features/testimonials/testimonial_card.dart @@ -5,15 +5,19 @@ import 'package:flutter/material.dart'; import 'package:vector_graphics/vector_graphics.dart'; class TestimonialCardData { - TestimonialCardData( - this.content, this.author, this.courseName, this.avatarAssetName); + const TestimonialCardData( + this.content, + this.author, + this.courseName, + this.avatarAssetName, + ); final String content; final String author; final String courseName; final String? avatarAssetName; static final List allTestimonials = [ - TestimonialCardData( + const TestimonialCardData( """ I can honestly say that Andrea's knowledge and guidance is top notch! He explains the principles well which helps you understand the concepts and structures within the Dart language. @@ -23,7 +27,7 @@ This course is a great asset to anyone looking to improve their coding skills. H "The Complete Dart Developer Guide", null, ), - TestimonialCardData( + const TestimonialCardData( """ Clear explanations, a useful practical application that demonstrates all the core things essential to building an app ready for release into the wild. @@ -43,7 +47,7 @@ Cannot praise this course and Andrea’s presentation highly enough. // "The Complete Dart Developer Guide", // "assets/parker-stevens.jpg", // ), - TestimonialCardData( + const TestimonialCardData( """ Andrea is an excellent instructor and developer. Very thankful he takes the time to create these courses and maintain his YouTube tutorials. @@ -57,7 +61,7 @@ There are more intermediate level tips I don't see other devs covering. Thanks s "Flutter & Firebase Course: Build a Complete App for iOS & Android", "assets/niven-shah.jpg", ), - TestimonialCardData( + const TestimonialCardData( """ Up-to-date content, didactic instructor, good support community on Slack, additional resources, tutorials and optional videos with the latest advances in Flutter. @@ -67,7 +71,7 @@ Concise and direct to the point, with a huge number of diagrams. A colossal amou "Flutter & Firebase Course: Build a Complete App for iOS & Android", null, ), - TestimonialCardData( + const TestimonialCardData( """ This is by far the best flutter course if you want to learn coding best practises while learning flutter, which I think everyone should. @@ -79,7 +83,7 @@ Another impressive thing about this course is that most of the videos are around "Flutter & Firebase Course: Build a Complete App for iOS & Android", "assets/nipuna-cooray.jpg", ), - TestimonialCardData( + const TestimonialCardData( """ Animations have always been my weak point, but Andrea's course covers most if not all the biggest Animation topics, and does so with lots of examples. """, // Another fantastic course from a great teacher. diff --git a/lib/src/features/testimonials/testimonials.dart b/lib/src/features/testimonials/testimonials.dart index 82d45b5..5017804 100644 --- a/lib/src/features/testimonials/testimonials.dart +++ b/lib/src/features/testimonials/testimonials.dart @@ -9,14 +9,15 @@ class TestimonialsHeader extends StatelessWidget { @override Widget build(BuildContext context) { - final screenWidth = MediaQuery.of(context).size.width; + final screenWidth = MediaQuery.sizeOf(context).width; final fontSize = screenWidth > Breakpoints.tablet ? 36.0 : (screenWidth > 640 ? 27.0 : 24.0); final spacing = screenWidth > Breakpoints.tablet ? 56.0 : 32.0; return Padding( padding: EdgeInsets.symmetric( - horizontal: sliverHorizontalPadding(screenWidth)), + horizontal: sliverHorizontalPadding(screenWidth), + ), child: Column( children: [ Text( @@ -42,13 +43,14 @@ class TestimonialsLayoutGrid extends StatelessWidget { @override Widget build(BuildContext context) { - final screenWidth = MediaQuery.of(context).size.width; + final screenWidth = MediaQuery.sizeOf(context).width; final crossAxisCount = screenWidth >= 905 ? 3 : (screenWidth >= 600 ? 2 : 1); if (crossAxisCount >= 3) { return SliverPadding( padding: EdgeInsets.symmetric( - horizontal: sliverHorizontalPadding(screenWidth)), + horizontal: sliverHorizontalPadding(screenWidth), + ), sliver: SliverAlignedGrid.count( crossAxisCount: 3, mainAxisSpacing: 24, @@ -56,14 +58,16 @@ class TestimonialsLayoutGrid extends StatelessWidget { itemCount: TestimonialCardData.allTestimonials.length, itemBuilder: (context, index) { return TestimonialCard( - data: TestimonialCardData.allTestimonials[index]); + data: TestimonialCardData.allTestimonials[index], + ); }, ), ); } else if (crossAxisCount >= 2) { return SliverPadding( padding: EdgeInsets.symmetric( - horizontal: sliverHorizontalPadding(screenWidth)), + horizontal: sliverHorizontalPadding(screenWidth), + ), sliver: SliverAlignedGrid.count( crossAxisCount: 2, mainAxisSpacing: 24, @@ -71,7 +75,8 @@ class TestimonialsLayoutGrid extends StatelessWidget { itemCount: TestimonialCardData.allTestimonials.length, itemBuilder: (context, index) { return TestimonialCard( - data: TestimonialCardData.allTestimonials[index]); + data: TestimonialCardData.allTestimonials[index], + ); }, ), ); @@ -85,7 +90,8 @@ class TestimonialsLayoutGrid extends StatelessWidget { vertical: 12, ), child: TestimonialCard( - data: TestimonialCardData.allTestimonials[index]), + data: TestimonialCardData.allTestimonials[index], + ), ); }, childCount: 4, @@ -101,7 +107,7 @@ class TestimonialsLayoutGrid extends StatelessWidget { // @override // Widget build(BuildContext context) { -// final screenWidth = MediaQuery.of(context).size.width; +// final screenWidth = MediaQuery.sizeOf(context).width; // final crossAxisCount = screenWidth > 928 ? 3 : (screenWidth > 640 ? 2 : 1); // return SliverPadding( // padding: EdgeInsets.symmetric( diff --git a/lib/src/tags.dart b/lib/src/tags.dart index baa05d1..c9adc02 100644 --- a/lib/src/tags.dart +++ b/lib/src/tags.dart @@ -23,6 +23,6 @@ class TagColor { TagColor(Color(0xFF48731C), Color(0xFFFFFFFF)), TagColor(Color(0xFF582391), Color(0xFFFFFFFF)), TagColor(Color(0xFFAD5E03), Color(0xFFFFFFFF)), - TagColor(Color(0xFFB3122F), Color(0xFFFFFFFF)) + TagColor(Color(0xFFB3122F), Color(0xFFFFFFFF)), ]; }