From 0e55289c64a85da0b22845b4de32a653952abcd0 Mon Sep 17 00:00:00 2001 From: ricardodalarme Date: Mon, 23 Oct 2023 21:00:41 -0300 Subject: [PATCH] feat: add flutter_gen --- lib/app.dart | 6 +- lib/constants/app_images.dart | 9 - lib/constants/assets.gen.dart | 120 +++++++++++ lib/constants/fonts.gen.dart | 18 ++ lib/constants/nu_icons.dart | 3 +- lib/pages/easyinvest/easyinvest_screen.dart | 5 +- lib/pages/pix/pix_screen.dart | 5 +- lib/pages/refer/refer_screen.dart | 4 +- lib/pages/rewards/rewards_screen.dart | 11 +- pubspec.lock | 224 ++++++++++++++++++++ pubspec.yaml | 5 + 11 files changed, 384 insertions(+), 26 deletions(-) delete mode 100644 lib/constants/app_images.dart create mode 100644 lib/constants/assets.gen.dart create mode 100644 lib/constants/fonts.gen.dart diff --git a/lib/app.dart b/lib/app.dart index 78036a9..f92b40b 100644 --- a/lib/app.dart +++ b/lib/app.dart @@ -1,5 +1,6 @@ import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; +import 'package:nubank_clone/constants/fonts.gen.dart'; import 'package:nubank_clone/core/app_state.dart'; import 'package:nubank_clone/pages/home/home_screen.dart'; import 'package:nubank_clone/theme/texts.dart'; @@ -26,7 +27,10 @@ class App extends StatelessWidget { child: MaterialApp( title: 'Nubank Clone', debugShowCheckedModeBanner: false, - theme: ThemeData(fontFamily: 'Gotham-SSm', textTheme: customTextTheme), + theme: ThemeData( + fontFamily: FontFamily.gothamSSm, + textTheme: customTextTheme, + ), home: HomeScreen(), ), ); diff --git a/lib/constants/app_images.dart b/lib/constants/app_images.dart deleted file mode 100644 index ef38a9a..0000000 --- a/lib/constants/app_images.dart +++ /dev/null @@ -1,9 +0,0 @@ -abstract class AppImages { - static const String _path = 'assets/images/'; - static const String logo = '${_path}logo.png'; - static const String logoBackground = '${_path}logo_background.png'; - static const String logoWhite = '${_path}logo_white.png'; - static const String easyinvest = '${_path}easyinvest.jpg'; - static const String pix = '${_path}pix.jpg'; - static const String referFriend = '${_path}refer_friend.jpg'; -} diff --git a/lib/constants/assets.gen.dart b/lib/constants/assets.gen.dart new file mode 100644 index 0000000..bc3e919 --- /dev/null +++ b/lib/constants/assets.gen.dart @@ -0,0 +1,120 @@ +/// GENERATED CODE - DO NOT MODIFY BY HAND +/// ***************************************************** +/// FlutterGen +/// ***************************************************** + +// coverage:ignore-file +// ignore_for_file: type=lint +// ignore_for_file: directives_ordering,unnecessary_import,implicit_dynamic_list_literal,deprecated_member_use + +import 'package:flutter/widgets.dart'; + +class $AssetsImagesGen { + const $AssetsImagesGen(); + + /// File path: assets/images/easyinvest.jpg + AssetGenImage get easyinvest => + const AssetGenImage('assets/images/easyinvest.jpg'); + + /// File path: assets/images/logo.png + AssetGenImage get logo => const AssetGenImage('assets/images/logo.png'); + + /// File path: assets/images/logo_background.png + AssetGenImage get logoBackground => + const AssetGenImage('assets/images/logo_background.png'); + + /// File path: assets/images/logo_white.png + AssetGenImage get logoWhite => + const AssetGenImage('assets/images/logo_white.png'); + + /// File path: assets/images/pix.jpg + AssetGenImage get pix => const AssetGenImage('assets/images/pix.jpg'); + + /// File path: assets/images/refer_friend.jpg + AssetGenImage get referFriend => + const AssetGenImage('assets/images/refer_friend.jpg'); + + /// List of all assets + List get values => + [easyinvest, logo, logoBackground, logoWhite, pix, referFriend]; +} + +class Assets { + Assets._(); + + static const $AssetsImagesGen images = $AssetsImagesGen(); +} + +class AssetGenImage { + const AssetGenImage(this._assetName); + + final String _assetName; + + Image image({ + Key? key, + AssetBundle? bundle, + ImageFrameBuilder? frameBuilder, + ImageErrorWidgetBuilder? errorBuilder, + String? semanticLabel, + bool excludeFromSemantics = false, + double? scale, + double? width, + double? height, + Color? color, + Animation? opacity, + BlendMode? colorBlendMode, + BoxFit? fit, + AlignmentGeometry alignment = Alignment.center, + ImageRepeat repeat = ImageRepeat.noRepeat, + Rect? centerSlice, + bool matchTextDirection = false, + bool gaplessPlayback = false, + bool isAntiAlias = false, + String? package, + FilterQuality filterQuality = FilterQuality.low, + int? cacheWidth, + int? cacheHeight, + }) { + return Image.asset( + _assetName, + key: key, + bundle: bundle, + frameBuilder: frameBuilder, + errorBuilder: errorBuilder, + semanticLabel: semanticLabel, + excludeFromSemantics: excludeFromSemantics, + scale: scale, + width: width, + height: height, + color: color, + opacity: opacity, + colorBlendMode: colorBlendMode, + fit: fit, + alignment: alignment, + repeat: repeat, + centerSlice: centerSlice, + matchTextDirection: matchTextDirection, + gaplessPlayback: gaplessPlayback, + isAntiAlias: isAntiAlias, + package: package, + filterQuality: filterQuality, + cacheWidth: cacheWidth, + cacheHeight: cacheHeight, + ); + } + + ImageProvider provider({ + AssetBundle? bundle, + String? package, + }) { + return AssetImage( + _assetName, + bundle: bundle, + package: package, + ); + } + + String get path => _assetName; + + String get keyName => _assetName; +} diff --git a/lib/constants/fonts.gen.dart b/lib/constants/fonts.gen.dart new file mode 100644 index 0000000..70b1382 --- /dev/null +++ b/lib/constants/fonts.gen.dart @@ -0,0 +1,18 @@ +/// GENERATED CODE - DO NOT MODIFY BY HAND +/// ***************************************************** +/// FlutterGen +/// ***************************************************** + +// coverage:ignore-file +// ignore_for_file: type=lint +// ignore_for_file: directives_ordering,unnecessary_import,implicit_dynamic_list_literal,deprecated_member_use + +class FontFamily { + FontFamily._(); + + /// Font family: Gotham-SSm + static const String gothamSSm = 'Gotham-SSm'; + + /// Font family: NuIcons + static const String nuIcons = 'NuIcons'; +} diff --git a/lib/constants/nu_icons.dart b/lib/constants/nu_icons.dart index 24ac28a..7db7418 100644 --- a/lib/constants/nu_icons.dart +++ b/lib/constants/nu_icons.dart @@ -1,9 +1,10 @@ // ignore_for_file: constant_identifier_names import 'package:flutter/widgets.dart'; +import 'package:nubank_clone/constants/fonts.gen.dart'; abstract class NuIcons { - static const _kFontFamily = 'NuIcons'; + static const _kFontFamily = FontFamily.nuIcons; static const IconData nuds_ic_category_store = IconData(0xe800, fontFamily: _kFontFamily); diff --git a/lib/pages/easyinvest/easyinvest_screen.dart b/lib/pages/easyinvest/easyinvest_screen.dart index 60b1a33..dab5a7d 100644 --- a/lib/pages/easyinvest/easyinvest_screen.dart +++ b/lib/pages/easyinvest/easyinvest_screen.dart @@ -1,7 +1,7 @@ import 'package:flutter/material.dart'; import 'package:material_design_icons_flutter/material_design_icons_flutter.dart'; import 'package:nubank_clone/constants/app_colors.dart'; -import 'package:nubank_clone/constants/app_images.dart'; +import 'package:nubank_clone/constants/assets.gen.dart'; import 'package:nubank_clone/constants/nu_icons.dart'; import 'package:nubank_clone/utils/extensions/router_context_extension.dart'; @@ -34,8 +34,7 @@ class EasyInvestScreen extends StatelessWidget { child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ - Image.asset( - AppImages.easyinvest, + Assets.images.easyinvest.image( height: 118, ), const SizedBox(height: 47), diff --git a/lib/pages/pix/pix_screen.dart b/lib/pages/pix/pix_screen.dart index 3a7d772..3996da9 100644 --- a/lib/pages/pix/pix_screen.dart +++ b/lib/pages/pix/pix_screen.dart @@ -1,7 +1,7 @@ import 'package:flutter/material.dart'; import 'package:material_design_icons_flutter/material_design_icons_flutter.dart'; import 'package:nubank_clone/constants/app_colors.dart'; -import 'package:nubank_clone/constants/app_images.dart'; +import 'package:nubank_clone/constants/assets.gen.dart'; import 'package:nubank_clone/constants/nu_icons.dart'; import 'package:nubank_clone/pages/pix/widgets/pix_menu.dart'; import 'package:nubank_clone/utils/extensions/router_context_extension.dart'; @@ -29,8 +29,7 @@ class PixScreen extends StatelessWidget { child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ - Image.asset( - AppImages.pix, + Assets.images.pix.image( height: 150, ), const SizedBox(height: 30), diff --git a/lib/pages/refer/refer_screen.dart b/lib/pages/refer/refer_screen.dart index aad8d0d..f4caae8 100644 --- a/lib/pages/refer/refer_screen.dart +++ b/lib/pages/refer/refer_screen.dart @@ -1,6 +1,6 @@ import 'package:flutter/material.dart'; import 'package:nubank_clone/constants/app_colors.dart'; -import 'package:nubank_clone/constants/app_images.dart'; +import 'package:nubank_clone/constants/assets.gen.dart'; import 'package:nubank_clone/constants/nu_icons.dart'; import 'package:nubank_clone/utils/extensions/router_context_extension.dart'; import 'package:nubank_clone/widgets/nu_outlined_button.dart'; @@ -37,7 +37,7 @@ class ReferScreen extends StatelessWidget { ), const SizedBox(height: 20), const NuOutlinedButton('Indicar amigos'), - Image.asset(AppImages.referFriend), + Assets.images.referFriend.image(), ], ), ), diff --git a/lib/pages/rewards/rewards_screen.dart b/lib/pages/rewards/rewards_screen.dart index 22c1d75..3420b1d 100644 --- a/lib/pages/rewards/rewards_screen.dart +++ b/lib/pages/rewards/rewards_screen.dart @@ -1,7 +1,7 @@ import 'package:flutter/material.dart'; import 'package:material_design_icons_flutter/material_design_icons_flutter.dart'; import 'package:nubank_clone/constants/app_colors.dart'; -import 'package:nubank_clone/constants/app_images.dart'; +import 'package:nubank_clone/constants/assets.gen.dart'; import 'package:nubank_clone/constants/nu_icons.dart'; import 'package:nubank_clone/utils/extensions/router_context_extension.dart'; @@ -45,8 +45,7 @@ class RewardsScreen extends StatelessWidget { Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ - Image.asset( - AppImages.easyinvest, + Assets.images.referFriend.image( height: 118, ), const SizedBox(height: 47), @@ -68,8 +67,7 @@ class RewardsScreen extends StatelessWidget { Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ - Image.asset( - AppImages.easyinvest, + Assets.images.easyinvest.image( height: 118, ), const SizedBox(height: 47), @@ -91,8 +89,7 @@ class RewardsScreen extends StatelessWidget { Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ - Image.asset( - AppImages.easyinvest, + Assets.images.easyinvest.image( height: 118, ), const SizedBox(height: 47), diff --git a/pubspec.lock b/pubspec.lock index 32f07dc..611be50 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -73,6 +73,70 @@ packages: url: "https://pub.dev" source: hosted version: "1.11.1" + build: + dependency: transitive + description: + name: build + sha256: "80184af8b6cb3e5c1c4ec6d8544d27711700bc3e6d2efad04238c7b5290889f0" + url: "https://pub.dev" + source: hosted + version: "2.4.1" + build_config: + dependency: transitive + description: + name: build_config + sha256: bf80fcfb46a29945b423bd9aad884590fb1dc69b330a4d4700cac476af1708d1 + url: "https://pub.dev" + source: hosted + version: "1.1.1" + build_daemon: + dependency: transitive + description: + name: build_daemon + sha256: "5f02d73eb2ba16483e693f80bee4f088563a820e47d1027d4cdfe62b5bb43e65" + url: "https://pub.dev" + source: hosted + version: "4.0.0" + build_resolvers: + dependency: transitive + description: + name: build_resolvers + sha256: "64e12b0521812d1684b1917bc80945625391cb9bdd4312536b1d69dcb6133ed8" + url: "https://pub.dev" + source: hosted + version: "2.4.1" + build_runner: + dependency: "direct dev" + description: + name: build_runner + sha256: "10c6bcdbf9d049a0b666702cf1cee4ddfdc38f02a19d35ae392863b47519848b" + url: "https://pub.dev" + source: hosted + version: "2.4.6" + build_runner_core: + dependency: transitive + description: + name: build_runner_core + sha256: c9e32d21dd6626b5c163d48b037ce906bbe428bc23ab77bcd77bb21e593b6185 + url: "https://pub.dev" + source: hosted + version: "7.2.11" + built_collection: + dependency: transitive + description: + name: built_collection + sha256: "376e3dd27b51ea877c28d525560790aee2e6fbb5f20e2f85d5081027d94e2100" + url: "https://pub.dev" + source: hosted + version: "5.1.1" + built_value: + dependency: transitive + description: + name: built_value + sha256: a8de5955205b4d1dbbbc267daddf2178bd737e4bab8987c04a500478c9651e74 + url: "https://pub.dev" + source: hosted + version: "8.6.3" characters: dependency: transitive description: @@ -105,6 +169,14 @@ packages: url: "https://pub.dev" source: hosted version: "1.1.1" + code_builder: + dependency: transitive + description: + name: code_builder + sha256: "1be9be30396d7e4c0db42c35ea6ccd7cc6a1e19916b5dc64d6ac216b5544d677" + url: "https://pub.dev" + source: hosted + version: "4.7.0" collection: dependency: transitive description: @@ -113,6 +185,14 @@ packages: url: "https://pub.dev" source: hosted version: "1.17.2" + color: + dependency: transitive + description: + name: color + sha256: ddcdf1b3badd7008233f5acffaf20ca9f5dc2cd0172b75f68f24526a5f5725cb + url: "https://pub.dev" + source: hosted + version: "3.0.0" convert: dependency: transitive description: @@ -161,6 +241,14 @@ packages: url: "https://pub.dev" source: hosted version: "2.3.2" + dartx: + dependency: transitive + description: + name: dartx + sha256: "8b25435617027257d43e6508b5fe061012880ddfdaa75a71d607c3de2a13d244" + url: "https://pub.dev" + source: hosted + version: "1.2.0" fake_async: dependency: transitive description: @@ -177,11 +265,35 @@ packages: url: "https://pub.dev" source: hosted version: "6.1.4" + fixnum: + dependency: transitive + description: + name: fixnum + sha256: "25517a4deb0c03aa0f32fd12db525856438902d9c16536311e76cdc57b31d7d1" + url: "https://pub.dev" + source: hosted + version: "1.1.0" flutter: dependency: "direct main" description: flutter source: sdk version: "0.0.0" + flutter_gen_core: + dependency: transitive + description: + name: flutter_gen_core + sha256: "8b4ff1d45d125e576e26ea99d15e0419bb3c45b53696e022880866b78bb6b830" + url: "https://pub.dev" + source: hosted + version: "5.3.2" + flutter_gen_runner: + dependency: "direct dev" + description: + name: flutter_gen_runner + sha256: fd197f8c657e79313d53d3934de602ebe604ba722a84c88ae3a43cd90428c67a + url: "https://pub.dev" + source: hosted + version: "5.3.2" flutter_launcher_icons: dependency: "direct dev" description: @@ -224,6 +336,14 @@ packages: description: flutter source: sdk version: "0.0.0" + frontend_server_client: + dependency: transitive + description: + name: frontend_server_client + sha256: "408e3ca148b31c20282ad6f37ebfa6f4bdc8fede5b74bc2f08d9d92b55db3612" + url: "https://pub.dev" + source: hosted + version: "3.2.0" glob: dependency: transitive description: @@ -232,6 +352,14 @@ packages: url: "https://pub.dev" source: hosted version: "2.1.2" + graphs: + dependency: transitive + description: + name: graphs + sha256: aedc5a15e78fc65a6e23bcd927f24c64dd995062bcd1ca6eda65a3cff92a4d19 + url: "https://pub.dev" + source: hosted + version: "2.3.1" html: dependency: transitive description: @@ -248,6 +376,14 @@ packages: url: "https://pub.dev" source: hosted version: "0.13.6" + http_multi_server: + dependency: transitive + description: + name: http_multi_server + sha256: "97486f20f9c2f7be8f514851703d0119c3596d14ea63227af6f7a481ef2b2f8b" + url: "https://pub.dev" + source: hosted + version: "3.2.1" http_parser: dependency: transitive description: @@ -264,6 +400,14 @@ packages: url: "https://pub.dev" source: hosted version: "4.1.3" + io: + dependency: transitive + description: + name: io + sha256: "2ec25704aba361659e10e3e5f5d672068d332fc8ac516421d483a11e5cbd061e" + url: "https://pub.dev" + source: hosted + version: "1.0.4" js: dependency: transitive description: @@ -288,6 +432,14 @@ packages: url: "https://pub.dev" source: hosted version: "3.0.0" + logging: + dependency: transitive + description: + name: logging + sha256: "623a88c9594aa774443aa3eb2d41807a48486b5613e67599fb4c41c0ad47c340" + url: "https://pub.dev" + source: hosted + version: "1.2.0" matcher: dependency: transitive description: @@ -320,6 +472,14 @@ packages: url: "https://pub.dev" source: hosted version: "1.9.1" + mime: + dependency: transitive + description: + name: mime + sha256: e4ff8e8564c03f255408decd16e7899da1733852a9110a58fe6d1b817684a63e + url: "https://pub.dev" + source: hosted + version: "1.0.4" nested: dependency: transitive description: @@ -376,6 +536,14 @@ packages: url: "https://pub.dev" source: hosted version: "3.7.3" + pool: + dependency: transitive + description: + name: pool + sha256: "20fe868b6314b322ea036ba325e6fc0711a22948856475e2c2b6306e8ab39c2a" + url: "https://pub.dev" + source: hosted + version: "1.5.1" process: dependency: transitive description: @@ -408,6 +576,30 @@ packages: url: "https://pub.dev" source: hosted version: "0.3.0" + pubspec_parse: + dependency: transitive + description: + name: pubspec_parse + sha256: c63b2876e58e194e4b0828fcb080ad0e06d051cb607a6be51a9e084f47cb9367 + url: "https://pub.dev" + source: hosted + version: "1.2.3" + shelf: + dependency: transitive + description: + name: shelf + sha256: ad29c505aee705f41a4d8963641f91ac4cee3c8fad5947e033390a7bd8180fa4 + url: "https://pub.dev" + source: hosted + version: "1.4.1" + shelf_web_socket: + dependency: transitive + description: + name: shelf_web_socket + sha256: "9ca081be41c60190ebcb4766b2486a7d50261db7bd0f5d9615f2d653637a84c1" + url: "https://pub.dev" + source: hosted + version: "1.0.4" sky_engine: dependency: transitive description: flutter @@ -437,6 +629,14 @@ packages: url: "https://pub.dev" source: hosted version: "2.1.1" + stream_transform: + dependency: transitive + description: + name: stream_transform + sha256: "14a00e794c7c11aa145a170587321aedce29769c08d7f58b1d141da75e3b1c6f" + url: "https://pub.dev" + source: hosted + version: "2.1.0" string_scanner: dependency: transitive description: @@ -461,6 +661,22 @@ packages: url: "https://pub.dev" source: hosted version: "0.6.0" + time: + dependency: transitive + description: + name: time + sha256: "83427e11d9072e038364a5e4da559e85869b227cf699a541be0da74f14140124" + url: "https://pub.dev" + source: hosted + version: "2.1.3" + timing: + dependency: transitive + description: + name: timing + sha256: "70a3b636575d4163c477e6de42f247a23b315ae20e86442bebe32d3cabf61c32" + url: "https://pub.dev" + source: hosted + version: "1.0.1" typed_data: dependency: transitive description: @@ -509,6 +725,14 @@ packages: url: "https://pub.dev" source: hosted version: "0.1.4-beta" + web_socket_channel: + dependency: transitive + description: + name: web_socket_channel + sha256: d88238e5eac9a42bb43ca4e721edba3c08c6354d4a53063afaa568516217621b + url: "https://pub.dev" + source: hosted + version: "2.4.0" xml: dependency: transitive description: diff --git a/pubspec.yaml b/pubspec.yaml index f23dfc3..70518eb 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -18,7 +18,9 @@ dependencies: sdk: flutter dev_dependencies: + build_runner: ^2.4.6 dart_code_metrics: ^5.7.6 + flutter_gen_runner: ^5.3.2 flutter_launcher_icons: ^0.13.1 flutter_lints: ^3.0.0 @@ -72,3 +74,6 @@ flutter: weight: 900 - asset: assets/fonts/Gotham-SSm/GothamSSm-BlackItalic.ttf weight: 900 + +flutter_gen: + output: lib/constants