Flutter mobile device image screen to large - flutter

I am currently using android studio flutter to test my prototype I manage to run my template successfully onto the mobile device however template is to large and I dont know how to make the template smaller so that it would fit onto the screen
when you select this link you can be able to see what it looks like:
mobile device image link
import 'package:flutter/material.dart';
final Color darkBlue = Color.fromARGB(255, 18, 32,47);
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
// This widget is the root of your application.
#override
Widget build(BuildContext context) {
return MaterialApp(
theme: ThemeData.dark().copyWith(scaffoldBackgroundColor: darkBlue),
debugShowCheckedModeBanner: false,
home: Scaffold(
body: Center(
child: Image.network("https://i.stack.imgur.com/deB5P.png", fit: Boxfit.fill),
)
title: 'Flutter Demo',
// This is the theme of your application.
//
// Try running your application with "flutter run". You'll see the
// application has a blue toolbar. Then, without quitting the app, try
// changing the primarySwatch below to Colors.green and then invoke
// "hot reload" (press "r" in the console where you ran "flutter run",
// or simply save your changes to "hot reload" in a Flutter IDE).
// Notice that the counter didn't reset back to zero; the application
// is not restarted.
primarySwatch: Colors.blue,
),
),
);
}
}

You can use box constraints by giving width and height properties. If you want your app to be responsive you can use MediaQuery. And for image you can use fit property like Image.asset("image", fit: BoxFit.cover), to know more about constants of BoxFit refer this.
import 'package:flutter/material.dart';
final Color darkBlue = Color.fromARGB(255, 18, 32, 47);
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
#override
Widget build(BuildContext context) {
return MaterialApp(
theme: ThemeData.dark().copyWith(scaffoldBackgroundColor: darkBlue),
debugShowCheckedModeBanner: false,
home: YourImage(),
);
}
}
class YourImage extends StatelessWidget {
#override
Widget build(BuildContext context) {
return Container(
child: Center(
child: Image.asset("assets/images/logo.png", fit: BoxFit.fill),
),
);
}
}

Related

Adjusting the size of the web on the flutter

Can you adjust the execution size of the Chrome browser on the flutter? I want to be able to adjust the size of my web program to smaller like a messenger program.
import 'package:flutter/material.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
#override
Widget build(BuildContext context) {
return MaterialApp(
title: 'basic',
theme: ThemeData(
primarySwatch: Colors.blue,
),
home: MyHomePage(),
);
}
}
class MyHomePage extends StatelessWidget {
#override
Widget build(BuildContext context) {
return Scaffold(
body: Container(
width: 0.5625*360,
height: 360,
child: Container(
color: Colors.greenAccent,
),
),
);
}
}
You don't need to think about size because during the debug mode app size is always larger but when you make a release build it will decrease.

Change color of CircularProgressIndicator and LinearProgressIndicator

Is it possible to change color of CircularProgressIndicator and LinearProgressIndicator to accent color with theme of MaterialApp globally?
(In previous version of flutter the default color was accent color and after upgrading flutter it's primary color)
Try the following code in dart pad, I want to change color of progress globally without chaining primarySwatch if possible
import 'package:flutter/material.dart';
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
#override
Widget build(BuildContext context) {
return MaterialApp(
theme: ThemeData(
accentColor: Colors.red,
primarySwatch: Colors.green,
),
debugShowCheckedModeBanner: false,
home: Scaffold(
body: Center(
child: CircularProgressIndicator(),
),
),
);
}
}
By wrapping with ProgressIndicatorTheme we can customize the color of CircularProgressIndicator and LinearProgressIndicator globally

trying to run flutter program and keep getting this error "the method 'HomeScreen' isn't defined for the type 'MyApp'

trying to run flutter program and keep getting this error "the method 'HomeScreen' isn't defined for the type 'MyApp' i need and answer to this problem quickly
import 'package:flutter/material.dart';
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
// This widget is the root of your application.
#override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Food Delivery UI',
debugShowCheckedModeBanner: false,
theme: ThemeData(
scaffoldBackgroundColor: Colors.grey[50],
primaryColor: Colors.deepOrangeAccent,
// This is the theme of your application.
//
// Try running your application with "flutter run". You'll see the
// application has a blue toolbar. Then, without quitting the app, try
// changing the primarySwatch below to Colors.green and then invoke
// "hot reload" (press "r" in the console where you ran "flutter run",
// or simply save your changes to "hot reload" in a Flutter IDE).
// Notice that the counter didn't reset back to zero; the application
// is not restarted.
primarySwatch: Colors.blue,
),
home: HomeScreen(),
);
}
}
I think you miss import file of HomeScreen at top of the main.dart.
HomeScreen class wasn't define in main.dart file as per your code.
Or maybe class name is something else. Check it again.
Chances are Home Screen is in another .dart file. You'll need to import this dart file into your main.dart for it to work. Super easy fix just add this part at the top
import 'package:flutter/material.dart';
import 'package:<projectname>/lib/<subfolder if you have one>/HomeScreen.dart'
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
// This widget is the root of your application.
#override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Food Delivery UI',
debugShowCheckedModeBanner: false,
theme: ThemeData(
scaffoldBackgroundColor: Colors.grey[50],
primaryColor: Colors.deepOrangeAccent,
primarySwatch: Colors.blue,
),
home: HomeScreen(),
);
}
}

Emojis on flutter web are not displayed

I try to use emojis on flutter web, for example 😀, on a Text() widget, but the emoji does not appear and I get a cross instead.
Screenshot:
Code:
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
// This widget is the root of your application.
#override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
theme: ThemeData(),
home: Scaffold(body: Text('This is an emoji 😀')),
);
}
}
Do you know how to solve it on flutter web ?
can try flutter_emoji package : https://pub.dev/packages/flutter_emoji
I think this issue is already solved on Flutter 2.8 😀
I just copy pasted the emoji on the Text string as follows.
Center(
child: AppCard(
child: Text(
'Hi there 👋',
style: Theme.of(context).textTheme.bodyText1,
),
),
),

Change background color used in Recents apps screen with Flutter app

How can I change the color shown in the app switcher of Android. Right now the color comes up with a gray background, but I want it to be red.
This is the app code.
import 'package:flutter/material.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
#override
Widget build(BuildContext context) {
return MaterialApp(
color: Colors.red,
title: 'Flutter Demo',
theme: ThemeData(
primarySwatch: Colors.blue,
),
home: Material(
child: Text('Check color in app switcher.'),
),
);
}
}
The color parameter of MaterialApp has no effect.
If you are using the MaterialApp you would use the color attribute to change the color of the app bar in the switcher.
You could also use the SystemChrome.setApplicationSwitcherDescription method which you would find in package:flutter/services.dart