main.dart file
This is my code...In splash screen my logo image size is very big how to fix the size to normal and align the image in center?
import 'package:firebase_auth/firebase_auth.dart';
import 'package:firebase_core/firebase_core.dart';
import 'package:flutter/material.dart';
import 'package:phone_verification/screens/home_screen.dart';
import 'package:phone_verification/screens/login_screen.dart';
import 'package:splashscreen/splashscreen.dart';
void main() async {
WidgetsFlutterBinding.ensureInitialized();
await Firebase.initializeApp();
runApp(Spl());
}
class Spl extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
home: SplashScreen(
seconds: 6,
imageBackground: AssetImage('./assets/images/logo.png'),
backgroundColor: Colors.red ,
photoSize: 50,
navigateAfterSeconds: LoginScreen(),
),
debugShowCheckedModeBanner: false,
); // define it once at root level.
}
}
class MyApp extends StatelessWidget {
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Hazardx',
theme: ThemeData(
primarySwatch: Colors.red,
visualDensity: VisualDensity.adaptivePlatformDensity,
),
debugShowCheckedModeBanner: false,
home: InitializerWidget());
}
}
class InitializerWidget extends StatefulWidget {
@override
_InitializerWidgetState createState() => _InitializerWidgetState();
}
class _InitializerWidgetState extends State<InitializerWidget> {
FirebaseAuth _auth;
User _user;
bool isLoading = true;
@override
void initState() {
// TODO: implement initState
super.initState();
_auth = FirebaseAuth.instance;
_user = _auth.currentUser;
isLoading = false;
}
@override
Widget build(BuildContext context) {
return isLoading ? Scaffold(
body: Center(
child: CircularProgressIndicator(),
),
) : _user == null ? LoginScreen() : HomeScreen();
}
}
This is my code...In splash screen my logo image size is very big how to fix the size to normal and align the image in center?
This is my code...In splash screen my logo image size is very big how to fix the size to normal and align the image in center?
CodePudding user response:
I think the .svg
format images can be used to solve this case.
The SVG images are specially designed to scale & shrink based on the screen space & availability. Try getting the image in .svg
format & use here.
SvgPicture.asset(<SVG_IMAGE_PATH>, height: <HEIGHT_VALUE>, width: <WIDTH_VALUE>);
& if possible give height & width based on the media query size value as a percentage
WIDTH_VALUE = MediaQuery.of(context).size.width * 0.5
HEIGHT_VALUE = MediaQuery.of(context).size.height * 0.5
CodePudding user response:
instead of using AssetImage() try
Image.asset('./assets/images/logo.png', height: 100 ,weight: 100),