Questions tagged [flutter]
Use this tag for questions about the Flutter cross-platform UI toolkit. If your question is platform-specific, tag the platform as well (e.g., [android], [ios], etc.). You may also wish to include the [dart] tag for coding questions.
flutter
196,851
questions
774
votes
16
answers
382k
views
How can I remove the debug banner in Flutter?
I'm using flutter screenshot and I expected the screenshot to not have a banner, but it has.
Note that I get a not supported for emulator message for profile and release mode.
644
votes
33
answers
653k
views
How do I use hexadecimal color strings in Flutter?
How do I convert a hexadecimal color string like #b74093 to a Color in Flutter?
I want to use a HEX color code in Dart.
581
votes
25
answers
570k
views
I am getting error "cmdline-tools component is missing" after installing Flutter and Android Studio... I added the Android SDK. How can I solve them?
Android toolchain - I develop for Android devices (Android SDK version 30.0.3):
X cmdline-tools component is missing
Run `path/to/sdkmanager --install "cmdline-tools;latest"`
See https://...
577
votes
40
answers
808k
views
Create a rounded button / button with border-radius in Flutter
I'm currently developing an Android app in Flutter. How can I add a rounded button?
575
votes
16
answers
614k
views
How to change the application launcher icon on Flutter?
When I create an app with a flutter create command, the flutter logo is used as an application icon for both platforms.
If I want to change the app icon, shall I go to both platforms directories and ...
567
votes
22
answers
1.0m
views
How can I add a border to a widget in Flutter?
I'm using Flutter and I'd like to add a border to a widget (in this case, a Text widget).
I tried TextStyle and Text, but I didn't see how to add a border.
544
votes
87
answers
761k
views
Getting error "No such module" using Xcode, but the framework is there
I'm currently coding in Swift, and I've got an error:
No such module Social
But I don't understand, because the module is in my project, declared in "Linked frameworks and Libraries" and in "...
507
votes
31
answers
296k
views
How do you build a Singleton in Dart?
The singleton pattern ensures only one instance of a class is ever created. How do I build this in Dart?
507
votes
35
answers
491k
views
How to change package name in flutter?
Is there any way to change Package Name of Flutter project?
I want to change package name and application name in flutter project.
499
votes
34
answers
368k
views
How can I dismiss the on screen keyboard?
I am collecting user input with a TextFormField and when the user presses a FloatingActionButton indicating they are done, I want to dismiss the on screen keyboard.
How do I make the keyboard go away ...
490
votes
28
answers
418k
views
No Firebase App '[DEFAULT]' has been created - call Firebase.initializeApp() in Flutter and Firebase
I am building a Flutter application and I have integrated Firebase, but I keep getting this error when I click on a button either to register, login, or logout. I have seen other people have asked the ...
478
votes
23
answers
288k
views
How do you detect the host platform from Dart code?
For UI that should differ slightly on iOS and Android, i.e. on different platforms, there must be a way to detect which one the app is running on, but I couldn't find it in the docs. What is it?
459
votes
41
answers
528k
views
How to run CocoaPods on Apple Silicon (M1)
I have a Flutter project that I'm trying to run on iOS. It runs normally on my Intel-based Mac, but on my new Apple Silicon-based M1 Mac it fails to install pods.
LoadError - dlsym(0x7f8926035eb0, ...
457
votes
24
answers
549k
views
Flutter - Wrap text on overflow, like insert ellipsis or fade
I'm trying to create a line in which center text has a maximum size, and if the text content is too large, it fits in size.
I insert the TextOverflow.ellipsis property to shorten the text and ...
450
votes
20
answers
516k
views
How to do Rounded Corners Image in Flutter
I am using Flutter to make a list of information about movies. Now I want the cover image on the left to be a rounded corners picture. I did the following, but it didn’t work. Thanks!
getItem(var ...
428
votes
28
answers
509k
views
How to create number input field in Flutter?
I'm unable to find a way to create an input field in Flutter that would open up a numeric keyboard and should take numeric input only. Is this possible with Flutter material widgets? Some GitHub ...
417
votes
20
answers
375k
views
How can I change the app display name build with Flutter?
I have created the app using Flutter create testapp.
Now, I want to change the app name from "testapp" to "My Trips Tracker". How can I do that?
I have tried changing from the ...
408
votes
20
answers
280k
views
How to add a ListView to a Column in Flutter?
I'm trying to construct a simple login page for my Flutter app. I've successfully built the TextFields and log in/Sign in buttons. I want to add a horizontal ListView. When I run the code my ...
400
votes
36
answers
474k
views
Dart SDK is not configured
I installed Flutter and set up Android Studio. Then I cloned an example of flutter on GitHub (https://github.com/flutter/flutter) and launched it in Android Studio, but it warns me "Dart SDK is ...
396
votes
25
answers
228k
views
Waiting for another flutter command to release the startup lock
When I run my flutter application it show
Waiting for another flutter command to release the startup lock
this messages and not proceed further.
394
votes
28
answers
378k
views
Flutter : How to change Android minSdkVersion in Flutter Project?
I was trying to start a flutter project for an App using Bluetooth to communicate. For that, I was using flutter blue.
Unfortunately, when trying to run (on an Android device) the first example I ...
380
votes
62
answers
594k
views
Message "flutter run: No connected devices"
I am trying to create a sample application with Flutter (fresh installation). Android Studio is also installed (fresh installation).
Here is the output of flutter run
flutter run
No connected devices.
...
378
votes
32
answers
631k
views
How to use conditional statement within child attribute of a Flutter Widget (Center Widget)
So far whenever I needed to use a conditional statement within a Widget I have done the following (Using Center and Containers as simplified dummy examples):
new Center(
child: condition == true ? ...
375
votes
20
answers
325k
views
How do I supply an initial value to a text field?
I'd like to supply an initial value to a text field and redraw it with an empty value to clear the text. What's the best approach to do that with Flutter's APIs?
363
votes
16
answers
155k
views
Scaffold.of() called with a context that does not contain a Scaffold
As you can see, my button is inside the Scaffold's body. But I get this exception:
Scaffold.of() called with a context that does not contain a Scaffold.
import 'package:flutter/material.dart';
void ...
360
votes
37
answers
488k
views
Module was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.5.1, expected version is 1.1.15
In Stripe, my client wants email and cardholder name, but the Stripe payment UI doesn't provide that option in com.stripe.android.view.CardMultilineWidget. I wanted to give it a try with the latest ...
359
votes
18
answers
404k
views
Sizing elements to percentage of screen width/height
Is there a simple (non-LayoutBuilder) way to size an element relative to screen size (width/height)? For example: how do I set the width of a CardView to be 65% of the screen width.
It can't be done ...
353
votes
10
answers
248k
views
Passing data to StatefulWidget and accessing it in its state in Flutter
I have 2 screens in my Flutter app: a list of records and a screen for creating and editing records.
If I pass an object to the second screen that means I am going to edit this and if I pass null it ...
353
votes
25
answers
540k
views
Error:(1, 0) Plugin with id 'com.android.application' not found
This is my first attempt at Android Studio. I installed 0.8.0 and updated to 0.8.2. As soon as a project is created I get the error message:
Error:(1, 0) Plugin with id 'com.android.application' ...
352
votes
24
answers
238k
views
Flutter: how to prevent device orientation changes and force portrait?
I would like to prevent my application from changing its orientation and force the layout to stick to "portrait".
In the main.dart, I put:
void main(){
SystemChrome.setPreferredOrientations([
...
349
votes
27
answers
319k
views
Vertical viewport was given unbounded height
This is my code:
@override
Widget build(BuildContext context) {
return new Material(
color: Colors.deepPurpleAccent,
child: new Column(
mainAxisAlignment: MainAxisAlignment.center,
...
347
votes
17
answers
359k
views
How do I disable a Button in Flutter?
I'm having trouble figuring out how to set the enabled state of a button in Flutter.
From the docs, it says to set onPressed to null to disable a button, and give it a value to enable it. This is fine ...
343
votes
18
answers
144k
views
Yellow lines under Text Widgets in Flutter?
The main app screen doesn't have this issue, all the texts show up as they should.
However, in the new screen, all the text widget have some weird yellow line / double-line underneath.
Any ideas on ...
343
votes
15
answers
341k
views
Flutter: Run method on Widget build complete
I would like to be able to run functions once a Widget has finished building/loading but I am unsure how.
My current use case is to check if a user is authenticated and if not, redirect to a login ...
339
votes
15
answers
132k
views
flutter doctor --android-licenses gives a java error
Exception in thread "main" java.lang.NoClassDefFoundError: javax/xml/bind/annotation/XmlSchema
at com.android.repository.api.SchemaModule$SchemaModuleVersion.<init>(SchemaModule.java:156)
...
336
votes
16
answers
375k
views
How to show/hide widgets programmatically in Flutter
In Android, every single View subclass has a setVisibility() method that allows you modify the visibility of a View object
There are 3 options of setting the visibility:
Visible: Renders the View ...
336
votes
7
answers
60k
views
What is the difference between functions and classes to create reusable widgets?
I have realized that it is possible to create widgets using plain functions instead of subclassing StatelessWidget. An example would be this:
Widget function({ String title, VoidCallback callback }) {
...
330
votes
15
answers
521k
views
Flutter- wrapping text
I want wrap text as text grows. I searched through and tried wrap with almost everything but still text stays one line and overflows from the screen.
Does anyone know how to achieve this?
Any help is ...
329
votes
12
answers
291k
views
setState() or markNeedsBuild called during build
class MyHome extends StatefulWidget {
@override
State<StatefulWidget> createState() => new MyHomePage2();
}
class MyHomePage2 extends State<MyHome> {
List items = new List();
...
325
votes
13
answers
385k
views
Flutter: how to make a TextField with HintText but no Underline?
This is what I'm trying to make:
In the Flutter docs for Text Fields (https://flutter.io/text-input/) it says you can remove the underline by passing null to the decoration. However, that also gets ...
322
votes
11
answers
169k
views
TextField inside of Row causes layout exception: Unable to calculate size
I’m getting a rendering exception that I don’t understand how to fix. I’m attempting to create a column that has 3 rows.
Row [Image]
Row [TextField ]
Row [Buttons]
Here is my code to build the ...