You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
web_image_mode: center reduce the image size by 4x;
I noticed in the web paragraph that such scaling is mentioned, but it's not clear how select the desired one
Configuration
flutter_native_splash
flutter_native_splash:
color: "#42a5f5"# web_image_mode can be one of the following modes: center, contain, stretch, and cover.web_image_mode: centerandroid: falseios: falseweb: trueimage_web: assets/splash_image.png
Devices:
Chrome Version 128.0.6613.120
Whichever Safari version runs on iPhone 16 Plus Simulator
To Reproduce
flutter create --platform web flutter_native_splash_web_issue
mkdir assets and paste an image of a circle with size 400x400 named splash_image.png
replace the content of pubspec.yaml with the one in under Additional context
add a flutter_native_splash.yaml provided under Configuration
replace the content of main.dart with the code sample below
run dart run flutter_native_splash:create and run the app
observe that the size of the asset in rendered by flutter
is different from the same asset in the splash screen
amend the image size as below, than repeat step 6. final size = await splashImage.size / 4;
observe splash and rendered image are identical
code sample
import'package:flutter/material.dart';
import'package:flutter_native_splash/flutter_native_splash.dart';
import'dart:ui'as ui;
import'package:flutter/services.dart';
const splashImage =AssetImage('assets/splash_image.png');
extensionSizeOfXonAssetImage {
Future<Size> get size async {
final data =await rootBundle.load(assetName);
final codec =await ui.instantiateImageCodec(data.buffer.asUint8List());
final frameInfo =await codec.getNextFrame();
returnSize(
frameInfo.image.width.toDouble(),
frameInfo.image.height.toDouble(),
);
}
}
voidmain() async {
final widgetsBinding =WidgetsFlutterBinding.ensureInitialized();
FlutterNativeSplash.preserve(widgetsBinding: widgetsBinding);
final size =await splashImage.size;
print(size);
runApp(
MaterialApp(
home:Center(
child:Image(
image: splashImage,
width: size.width,
height: size.height,
),
),
),
);
FlutterNativeSplash.remove();
}
Describe the bug
web_image_mode: center
reduce the image size by 4x;I noticed in the web paragraph that such scaling is mentioned, but it's not clear how select the desired one
Configuration
flutter_native_splash
Devices:
To Reproduce
flutter create --platform web flutter_native_splash_web_issue
mkdir assets
and paste an image of a circle with size 400x400 namedsplash_image.png
pubspec.yaml
with the one in underAdditional context
flutter_native_splash.yaml
provided underConfiguration
main.dart
with the code sample belowdart run flutter_native_splash:create
and run the appis different from the same asset in the splash screen
6.
final size = await splashImage.size / 4;
code sample
Screenshots
Screenshots
Additional context
pubspec
doctor
The text was updated successfully, but these errors were encountered: