Generate asset names

This commit is contained in:
shilangyu 2021-01-30 13:11:41 +00:00
parent dd15ebb2c0
commit 2fa6645f13
2 changed files with 67 additions and 4 deletions

64
lib/gen/assets.gen.dart Normal file
View File

@ -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;
}

View File

@ -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,
);