From 11d9710805421e3ac04e9aa7af308b94262509f7 Mon Sep 17 00:00:00 2001 From: khimji9883 <115577182+khimji9883@users.noreply.github.com> Date: Tue, 11 Oct 2022 23:44:42 +0530 Subject: [PATCH 1/3] format code with added const and remove PROBLEMS --- lib/app_screens/first_screen.dart | 24 +++++++++++++++--------- lib/main.dart | 16 +++++++++------- test/widget_test.dart | 30 ------------------------------ 3 files changed, 24 insertions(+), 46 deletions(-) delete mode 100644 test/widget_test.dart diff --git a/lib/app_screens/first_screen.dart b/lib/app_screens/first_screen.dart index 7fcde6f..bb7d30f 100644 --- a/lib/app_screens/first_screen.dart +++ b/lib/app_screens/first_screen.dart @@ -2,23 +2,29 @@ import 'dart:math'; import 'package:flutter/material.dart'; -class FirstScreen extends StatelessWidget{ +class FirstScreen extends StatelessWidget { + const FirstScreen({super.key}); + @override Widget build(BuildContext context) { return Material( color: Colors.amber, - child:Center( - child:Text( + child: Center( + child: Text( "Your No. is ${yourluckyno()}", - textDirection:TextDirection.ltr, - style: TextStyle(color: Colors.white,fontSize: 40.0), + textDirection: TextDirection.ltr, + style: const TextStyle( + color: Colors.white, + fontSize: 40.0, + ), ), ), ); } - int yourluckyno(){ - var random=Random(); - int luckyNumber=random.nextInt(10); + + int yourluckyno() { + var random = Random(); + int luckyNumber = random.nextInt(10); return luckyNumber; } -} \ No newline at end of file +} diff --git a/lib/main.dart b/lib/main.dart index 93750a1..978e815 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -1,20 +1,22 @@ import "package:flutter/material.dart"; import './app_screens/first_screen.dart'; -void main()=>runApp(new MyApp()); +void main() => runApp(const MyApp()); + +class MyApp extends StatelessWidget { + const MyApp({super.key}); -class MyApp extends StatelessWidget{ @override Widget build(BuildContext context) { return MaterialApp( debugShowCheckedModeBanner: false, - title:"MY APP", - home:Scaffold( + title: "MY APP", + home: Scaffold( appBar: AppBar( - title: Text("MY First App"), - ), - body:FirstScreen() + title: const Text("MY First App"), ), + body: const FirstScreen(), + ), ); } } diff --git a/test/widget_test.dart b/test/widget_test.dart deleted file mode 100644 index 3434c37..0000000 --- a/test/widget_test.dart +++ /dev/null @@ -1,30 +0,0 @@ -// This is a basic Flutter widget test. -// -// To perform an interaction with a widget in your test, use the WidgetTester -// utility in the flutter_test package. For example, you can send tap and scroll -// gestures. You can also use WidgetTester to find child widgets in the widget -// tree, read text, and verify that the values of widget properties are correct. - -import 'package:flutter/material.dart'; -import 'package:flutter_test/flutter_test.dart'; - -import 'package:hello/main.dart'; - -void main() { - testWidgets('Counter increments smoke test', (WidgetTester tester) async { - // Build our app and trigger a frame. - await tester.pumpWidget(const MyApp()); - - // Verify that our counter starts at 0. - expect(find.text('0'), findsOneWidget); - expect(find.text('1'), findsNothing); - - // Tap the '+' icon and trigger a frame. - await tester.tap(find.byIcon(Icons.add)); - await tester.pump(); - - // Verify that our counter has incremented. - expect(find.text('0'), findsNothing); - expect(find.text('1'), findsOneWidget); - }); -} From 50d57a93d6103827a74be2b7ddd8e43b9d88119d Mon Sep 17 00:00:00 2001 From: hamjayakub <115658520+hamjayakub@users.noreply.github.com> Date: Wed, 12 Oct 2022 23:52:33 +0530 Subject: [PATCH 2/3] removed comment --- pubspec.yaml | 69 +--------------------------------------------------- 1 file changed, 1 insertion(+), 68 deletions(-) diff --git a/pubspec.yaml b/pubspec.yaml index 484e61d..b0a3851 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,89 +1,22 @@ name: hello description: A new Flutter project. -# The following line prevents the package from being accidentally published to -# pub.dev using `flutter pub publish`. This is preferred for private packages. publish_to: 'none' # Remove this line if you wish to publish to pub.dev -# The following defines the version and build number for your application. -# A version number is three numbers separated by dots, like 1.2.43 -# followed by an optional build number separated by a +. -# Both the version and the builder number may be overridden in flutter -# build by specifying --build-name and --build-number, respectively. -# In Android, build-name is used as versionName while build-number used as versionCode. -# Read more about Android versioning at https://developer.android.com/studio/publish/versioning -# In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion. -# Read more about iOS versioning at -# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html version: 1.0.0+1 environment: sdk: ">=2.17.6 <3.0.0" -# Dependencies specify other packages that your package needs in order to work. -# To automatically upgrade your package dependencies to the latest versions -# consider running `flutter pub upgrade --major-versions`. Alternatively, -# dependencies can be manually updated by changing the version numbers below to -# the latest version available on pub.dev. To see which dependencies have newer -# versions available, run `flutter pub outdated`. dependencies: flutter: sdk: flutter - - - # The following adds the Cupertino Icons font to your application. - # Use with the CupertinoIcons class for iOS style icons. cupertino_icons: ^1.0.2 dev_dependencies: flutter_test: sdk: flutter - - # The "flutter_lints" package below contains a set of recommended lints to - # encourage good coding practices. The lint set provided by the package is - # 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: ^2.0.0 - -# For information on the generic Dart part of this file, see the -# following page: https://dart.dev/tools/pub/pubspec - -# The following section is specific to Flutter packages. + flutter: - - # The following line ensures that the Material Icons font is - # included with your application, so that you can use the icons in - # the material Icons class. uses-material-design: true - - # To add assets to your application, add an assets section, like this: - # assets: - # - images/a_dot_burr.jpeg - # - images/a_dot_ham.jpeg - - # An image asset can refer to one or more resolution-specific "variants", see - # https://flutter.dev/assets-and-images/#resolution-aware - - # For details regarding adding assets from package dependencies, see - # https://flutter.dev/assets-and-images/#from-packages - - # To add custom fonts to your application, add a fonts section here, - # in this "flutter" section. Each entry in this list should have a - # "family" key with the font family name, and a "fonts" key with a - # list giving the asset and other descriptors for the font. For - # example: - # fonts: - # - family: Schyler - # fonts: - # - asset: fonts/Schyler-Regular.ttf - # - asset: fonts/Schyler-Italic.ttf - # style: italic - # - family: Trajan Pro - # fonts: - # - asset: fonts/TrajanPro.ttf - # - asset: fonts/TrajanPro_Bold.ttf - # weight: 700 - # - # For details regarding fonts from package dependencies, - # see https://flutter.dev/custom-fonts/#from-packages From 6970910b2b9c63f3b35af39479a02b940954b4e9 Mon Sep 17 00:00:00 2001 From: yakub-8287 <116015895+yakub-8287@users.noreply.github.com> Date: Mon, 17 Oct 2022 21:06:21 +0530 Subject: [PATCH 3/3] Update analysis and solved all problems --- analysis_options.yaml | 23 ++--------------------- lib/app_screens/first_screen.dart | 2 +- lib/main.dart | 2 +- 3 files changed, 4 insertions(+), 23 deletions(-) diff --git a/analysis_options.yaml b/analysis_options.yaml index 61b6c4d..a5cd6c3 100644 --- a/analysis_options.yaml +++ b/analysis_options.yaml @@ -1,29 +1,10 @@ -# 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 + 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 diff --git a/lib/app_screens/first_screen.dart b/lib/app_screens/first_screen.dart index bb7d30f..1966dab 100644 --- a/lib/app_screens/first_screen.dart +++ b/lib/app_screens/first_screen.dart @@ -11,7 +11,7 @@ class FirstScreen extends StatelessWidget { color: Colors.amber, child: Center( child: Text( - "Your No. is ${yourluckyno()}", + 'Your No. is ${yourluckyno()}', textDirection: TextDirection.ltr, style: const TextStyle( color: Colors.white, diff --git a/lib/main.dart b/lib/main.dart index 978e815..127dc12 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -13,7 +13,7 @@ class MyApp extends StatelessWidget { title: "MY APP", home: Scaffold( appBar: AppBar( - title: const Text("MY First App"), + title: const Text('Flutter Start'), ), body: const FirstScreen(), ),