From 2fa6645f1302e51806491dd8b66326bc73b833b7 Mon Sep 17 00:00:00 2001 From: shilangyu Date: Sat, 30 Jan 2021 13:11:41 +0000 Subject: [PATCH] Generate asset names --- lib/gen/assets.gen.dart | 64 +++++++++++++++++++++++++++++++++++++ lib/widgets/about_tile.dart | 7 ++-- 2 files changed, 67 insertions(+), 4 deletions(-) create mode 100644 lib/gen/assets.gen.dart diff --git a/lib/gen/assets.gen.dart b/lib/gen/assets.gen.dart new file mode 100644 index 0000000..ef8e3bd --- /dev/null +++ b/lib/gen/assets.gen.dart @@ -0,0 +1,64 @@ +/// GENERATED CODE - DO NOT MODIFY BY HAND +/// ***************************************************** +/// FlutterGen +/// ***************************************************** + +import 'package:flutter/widgets.dart'; + +class Assets { + Assets._(); + + static const AssetGenImage appIcon = AssetGenImage('assets/app_icon.png'); +} + +class AssetGenImage extends AssetImage { + const AssetGenImage(String assetName) + : _assetName = assetName, + super(assetName); + final String _assetName; + + Image image({ + Key key, + ImageFrameBuilder frameBuilder, + ImageLoadingBuilder loadingBuilder, + ImageErrorWidgetBuilder errorBuilder, + String semanticLabel, + bool excludeFromSemantics = false, + double width, + double height, + Color color, + BlendMode colorBlendMode, + BoxFit fit, + AlignmentGeometry alignment = Alignment.center, + ImageRepeat repeat = ImageRepeat.noRepeat, + Rect centerSlice, + bool matchTextDirection = false, + bool gaplessPlayback = false, + bool isAntiAlias = false, + FilterQuality filterQuality = FilterQuality.low, + }) { + return Image( + key: key, + image: this, + frameBuilder: frameBuilder, + loadingBuilder: loadingBuilder, + errorBuilder: errorBuilder, + semanticLabel: semanticLabel, + excludeFromSemantics: excludeFromSemantics, + width: width, + height: height, + color: color, + colorBlendMode: colorBlendMode, + fit: fit, + alignment: alignment, + repeat: repeat, + centerSlice: centerSlice, + matchTextDirection: matchTextDirection, + gaplessPlayback: gaplessPlayback, + isAntiAlias: isAntiAlias, + filterQuality: filterQuality, + ); + } + + String get path => _assetName; +} diff --git a/lib/widgets/about_tile.dart b/lib/widgets/about_tile.dart index 5794345..289d044 100644 --- a/lib/widgets/about_tile.dart +++ b/lib/widgets/about_tile.dart @@ -1,8 +1,10 @@ +import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:flutter_hooks/flutter_hooks.dart'; import 'package:flutter_markdown/flutter_markdown.dart'; import 'package:package_info/package_info.dart'; +import '../gen/assets.gen.dart'; import '../hooks/memo_future.dart'; import '../url_launcher.dart'; import 'bottom_modal.dart'; @@ -74,10 +76,7 @@ class AboutTile extends HookWidget { ], applicationIcon: ClipRRect( borderRadius: BorderRadius.circular(10), - child: Image.asset( - 'assets/app_icon.png', - width: 54, - ), + child: Assets.appIcon.image(width: 54), ), applicationVersion: packageInfo.version, );