Native splash screen width and height - android

I'm using flutter_native_splash to create native splash screen for both android and ios but i need to specify the height and width of my app logo which appears in this splash screen because i'm using the same logo for some animation in the next screen, so i need them to be in the same width and height
Update 1
this is the code of the image i'm using in the next screen
AnimatedAlignPositioned(
duration: const Duration(milliseconds:500),
alignment: Alignment.center,
moveByChildHeight: change ? -0.5 : 0,
child: Image.asset(
'assets/images/splash.png',
width: ScreenUtil().setWidth(250),
height: ScreenUtil().setHeight(250),
fit: BoxFit.fill,
filterQuality: FilterQuality.medium,
),
),

Related

row is not expanding as its parent container in flutter

Here is my code
Screen shot of code
current output
current output screen shot
i want both my icons to spaced between.
Give width to Container()
Container(
width: MediaQuery.of(context).size.width,
),

Flutter, Android and IOS bottom navigation bar size is different

An overflow error occurred due to the bottom navigation bar height in ios, the layout that worked well on all Android devices.
It seemed to be because of the extra space because of the format of turning off the app by pulling it up from the bottom, which is governed by the IOS operating system.
it is super annoying I forcibly increased the bottom navigation bar height because of IOS, but the design is now bad in Android. Anyone know how to solve it?
--UPDATE
Scaffold(
bottomNavigationBar: Container(
height: 50,
child: BottomNavigationBar(
...
),
),
)
Try add SafeArea on top of Container :
Scaffold(
bottomNavigationBar: SafeArea(
child: Container(
height: 50,
child: BottomNavigationBar(
...
),
),
),
)
You can easily make height different for both platforms:
height: Platform.isIOS ? 50:40
So here if the Platform is IOS the height will be 50 or it will be 40.
Hey i tried custom painter and i realized that for iphone 13 the height is 90 pixel for bottom navigation bar and for android the height is different which is the value of kBottomNavigationBarHeight. So i declared this value in my constant file such as double btmNavigationBarHeight = Platform.isAndroid ? kBottomNavigationBarHeight : 90;. Hope it helps anyone with the same problem

Background Image

return Stack(
children: <Widget>[
Image.asset(
'assets/logo/greenframe.png',
height: MediaQuery.of(context).size.height,
width: MediaQuery.of(context).size.width,
fit: BoxFit.fill,
),
...
I'm using this code for using a background image on my app. It is a rectangle frame. It works okay with my Redmi Note 8 screen but on another phone with a different size of the screen, it's not looking good. Not fitting the screen. Is there a way to fix this?
How can I set the size based on screen size?
You can use MediaQuery.of(context).size to get a responsive design for all screen sizes. For example, defining the size of the icon button will look like this:
IconButton(
iconSize: MediaQuery.of(context).size.height * 0.03, // Here!
icon: Icon(
Icons.arrow_back,
color: Colors.black,
),
onPressed: () => Navigator.pop(context),
),
Read more from here.

how to change size of svg image in flutter?

I used flutter_svg: ^0.18.0 to use svg images inside my project. But I cannot able to find a proper way to change the size of it.
Here's my code
body: SafeArea(
child: Center(
child: SvgPicture.asset('assets/images/morelights.svg'),
),
),
The key hint is to use fit attribute like this:
SvgPicture.asset(
'assets/svg/notification.svg',
height: 5, width: 5,
fit: BoxFit.scaleDown
)
I found a solution for this :)
Steps
Wrap svg icon inside a container. ( Container should be a child widget)
Set color of the container to transparent.
Change the size of the container. (Svg icon inhert the size of parent widget.)
Note: You can use IconButton widget as well. Container works better in my case :)
Example
You can wrap your SvgPicture widget with IconButton
IconButton(
onPressed: (){},
icon: SvgPicture.asset(
icDate,
height: 24,
width: 24,
),
),
you just have to use properties width and height of svg picture.
SvgPicture.asset(
'assets/images/bm-icon1.svg',
width: 18.0,
height: 18.0,
),
I found the solution by accident. Wrap SvgPicture with Container widget and add alignment.
That way you can freely change the width and height of the SvgPicture.
Container(
height: 100,
width: 100,
alignment: Alignment.center, // <---- The magic
padding: const EdgeInsets.all(12),
child: SvgPicture.asset(
'assets/icons/svg-image.svg',
semanticsLabel: 'Image',
height: 50,
width: 50,
),
),
Hope this works in your case
Wrap it in a Container widget as the SvgPicture.asset() will always take the full available height or width of the parent. you can size the Container widget height and width to get the desirable sizing you want for your SVG.
Container(
child: SvgPicture.asset('assets/images/morelights.svg'),
height: 100,
),
Edit:
You can use the SizedBox to easily achieve this:
SizedBox(
width: 100.0,
height: 150.0,
child: SvgPicture.asset('assets/images/morelights.svg',),
)
Original Answer:
You can specify the height and width in the asset constructor itself:
SvgPicture.asset('assets/images/morelights.svg', height: 100, width: 150)
Read all the available properties in this document: SvgPicture.asset
You can use the height and width parameters of SvgPicture.asset:
Center(child: SvgPicture.asset(icon, height: 20, width: 20))
You can Wrap the SvgPicture.asset widget with an IconButton, This property have the behavior to overwrite this problem. the sample code is given below.
IconButton(
icon: SvgPicture.asset('assets/svg_images/ic_plane.svg',
color: const Color(0xffFF5D2A),
height: 20,
width: 20,
), onPressed: () { },
),

how to add a MediaQueryData to a spacific padding?

How to add a specific padding to bottom using MediaQueryData ?
Padding(
padding: const EdgeInsets.only(
bottom:8.0,
),
)
I think you mean
MediaQueryData mediaQueryData = MediaQuery.of(context);
And to get width and height of the device screen:
mediaQueryData.size.width;
mediaQueryData.size.height;
Then you can do something like this
Padding(
padding: EdgeInsets.only(
bottom: mediaQueryData.size.height * 0.05 // means 5% of screen height
),
)
I think you need to add spacing from the bottom and you're using a wrong widget for that, you should either use a SizedBox or provide a dummy child to your Padding.
For instance:
Column(
children: <Widget>[
SomeWidget(),
SizedBox(height: 20), // provides padding from bottom
],
)
If this isn't something you're looking for, I request you to update your question by adding more details of what you're trying to achieve.
Padding widget always takes a const value in flutter and MediaQuery based value is not treated as constant.
So in case you need to provide a bottom padding add SizedBox widget below your widget to create the required free space as follows:
SizedBox(
height:MediaQuery.of(context).size.height*0.1,
),
So this will give a space equivalent to one tenth of the screen height. Likewise you can adjust padding by changing the multiplication factor.

Categories

Resources