Missing most text on android emulator - android

So I'm running the following code and no text is displayed on the emulator screen, the example app showed absolutely no text on screen. If I ran the app without a degugger attached, the text was there but disappeared when a refresh was made.
Same thing happens with API 24, 27, 28. On API 28 I didnt have any text in the home screen of the OS and sometimes half of the clock text was missing and half was there (like clock showed up as " :22" instead of "10:22"), app titles text under their icons was missing.
Tried reinstalling devices and downloading new images. Same thing happens if running with xamarin.
Some images showcasing the problem: https://imgur.com/a/OigLsCE
Has anyone had to deal with this before?
import 'package:flutter/material.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
#override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Welcome to Flutter',
home: Scaffold(
appBar: AppBar(
title: Text('Welcome to Flutter'),
),
body: Center(
child: Text('Hello World'),
),
),
);
}
}

Try changing the renderer in the emulator settings:
answer from https://www.reddit.com/r/androiddev/comments/dc8n2a/missing_text_in_android_emulator/f29dk6z?utm_source=share&utm_medium=web2x&context=3

Related

INSTALL_FAILED_INSUFFICIENT_STORAGE when attempting to run in emulator in flutter

I keep getting this error when trying to run a simple flutter app in emulator.
Below is what is have tries
I have tried increasing internal storage
flutter clean and flutter pub get
Below is the main.dart file
import 'package:english_words/english_words.dart';
import 'package:flutter/material.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
#override
Widget build(BuildContext context) {
final wordPair = WordPair.random();
return MaterialApp(
title: 'Welcome to Flutter',
home: Scaffold(
appBar: AppBar(
title: const Text('Welcome to Flutter'),
),
body: Center(
child:Text(wordPair.asPascalCase),
),
),
);
}
}
You can resolve this by going into avd and adding a new device or edit the current.
Select Hardware-> Select System image -> verify Configuration section
Click on Advance settings and increase the limit of device internal storage. It will be 800 by default.
See the images below
Try to uninstall some other apps from your device or wipe data of the emulator will help to install the new app
You have increased the internal storage, but are you sure that there is space on your computer's disk? If there isn't, freeing up space would probably fix the problem

I am trying to use center widget in flutter, but due to some unknown reason it is not working, please help me

I have recently started learning flutter and got stuck at my very first basic hello world application:/
So, basically I am trying to center the entire content on the screen using the center tag, but it is not working, it would be really helpful if someone looks into my problem and helps me:)
Here's the code
import 'package:flutter/material.dart';
void main() {
runApp(MaterialApp(home: Center(child: Text('Hello World'))));
}
The application screen:
Try this:
void main() {
runApp(MaterialApp(
home: Scaffold(
body: Center(
child: Text('Hello World')
),
),
),
);
}
Text needs an ancestor of Material to be rendered "correctly" and since Scaffold has one, it'll work fine.

New Flutter app has same font style as one of my previous apps

I created a new Flutter app from scratch, in Android Studio. In one of my previous apps, I intentionally used a weird font style. Now, for some reason, the new app has the same fonts. Is it possible that I had stored some "global" font style somewhere in the Android Studio, and now it's getting re-used? How can I get rid of it and revert the "normal" fonts?
Here's the code of one widget and its screenshot in the emulator:
import 'package:flutter/material.dart';
class LoginScreen extends StatelessWidget {
#override
Widget build(BuildContext context) {
return SafeArea(
child: Container(
child: Column(
children: <Widget>[
RaisedButton(
child: Text('Login'),
onPressed: () {
Navigator.pushNamed(context, '/');
},
),
Text('Login'),
],
),
),
);
}
}
No, there shouldn't be.
In my case it also appeared in the debug app, but disappeared again when I recompiled the project. I haven't seen it in a finished app yet.

MaterialApp Widget's title Property Not Working

I am an absolute beginner to Flutter !
Picture# 1 : Reference from tutorial.
Picture# 2 : My implementation.
Virtual Device: Nexus_5X_API_28
Android: 9.0
Are you sure you are using the same emulator in both examples?
The title in MaterialApp Widget isn't the title you will see in the Application Bar.
used by the device to identify the app
as documentation says.
So Maybe it is how the device displays 'running applications menu'.
If you want to display the appBar you need to use Scaffold
void main() => runApp(
MaterialApp(
title: 'App',
home: Scaffold(
appBar: AppBar(
title: Text('My App'),
),
body: Center(
child: Text("text"),
),
),
),
);

Force Flutter Android Application to behave like it is on an iOS Device

Is there a way to force an Flutter Android App to behave like it is on an iOS Device?
I'm not referring to the Cupertino package.
Here is what I mean with Android/iOS Style
iOS Style:
Android style:
You can set the platform parameter in the ThemeData of the app to TargetPlatform.iOS. Then the app will behave as if it were running on an iOS device, including showing iOS text controls, etc. Very useful for testing things out at least!
Here's a full app that will use iOS stylings even when run on an Android device:
import 'package:flutter/material.dart';
void main() {
runApp(
MaterialApp(
title: 'Flutter Demo',
theme: ThemeData(
primarySwatch: Colors.blue,
// The line below forces the theme to iOS.
platform: TargetPlatform.iOS,
),
home: Scaffold(
body: Center(
child: TextField(),
),
),
),
);
}
Edit
If you also want to fake defaultTargetPlatform, you can do that by setting debugDefaultTargetPlatform. Including that as well we have:
import 'package:flutter/material.dart';
import 'package:flutter/foundation.dart';
void main() {
// This line will fake defaultTargetPlatform to iOS.
debugDefaultTargetPlatform = TargetPlatform.iOS;
runApp(
MaterialApp(
title: 'Flutter Demo',
theme: ThemeData(
primarySwatch: Colors.blue,
// The line below forces the theme to iOS.
platform: TargetPlatform.iOS,
),
home: Scaffold(
body: Center(
child: TextField(),
),
),
),
);
}
Update
This is not valid anymore with latest Flutter version
Solution from Previous Versions
Yes, it is possible during development stage, if that is what you want.
If the App is started from Intellij/Android studio, open Flutter Performance tab from Intellij/Android Studio, there you can find the option Platform and you can toggle it between iOS and Android.
If you are launching app from command line and using flutter devtools, in Devtools Web Interface, go to tab Flutter Inspector, there you can find the option Platform and you can toggle it between iOS and Android.
Use debugDefaultTargetPlatformOverride to force it, obviously in debug:
Widget build(BuildContext context) {
debugDefaultTargetPlatformOverride = TargetPlatform.iOS;
return PlatformApp(
title: 'Lovey-Dovey',
home: MyHomePage(title: 'Lovey-Dovey2'),
);
}
Flutter will default the style to the native platform. So iOS/Android apps, while maintaining similar functionality, won't look out of place on the phone as they will follow Cupertino/Material guidelines respectively.

Categories

Resources