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
11,372
questions
49
votes
5
answers
31k
views
What is a Future and how do I use it?
I get the following error:
A value of type 'Future<int>' can't be assigned to a variable of type 'int'
It might be another type instead of int, but basically the pattern is:
A value of type '...
22
votes
2
answers
5k
views
What is a NoSuchMethodError and how do I fix it?
I have some code and when I run it produces an error, saying:
NoSuchMethod: the method 'XYZ' was called on null
What does that mean and how do I fix it?
305
votes
7
answers
105k
views
How to deal with unwanted widget build?
For various reasons, sometimes the build method of my widgets is called again.
I know that it happens because a parent updated. But this causes undesired effects.
A typical situation where it causes ...
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 ...
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 }) {
...
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 "...
201
votes
15
answers
509k
views
Null check operator used on a null value
I got this error when I run my simple flutter app:
Null check operator used on a null value
My code in main.dart
import 'package:flutter/material.dart';
import './ui/login.dart';
void main() {
...
53
votes
2
answers
38k
views
Null check doesn't cause type promotion in Dart
I'm upgrading a personal package that is based on the Flutter framework. I noticed here in the Flutter Text widget source code that there is a null check:
if (textSpan != null) {
properties.add(...
28
votes
1
answer
16k
views
How to wait for forEach to complete with asynchronous callbacks?
Sample code:
Map<String, String> gg = {'gg': 'abc', 'kk': 'kojk'};
Future<void> secondAsync() async {
await Future.delayed(const Duration(seconds: 2));
print("Second!");
...
228
votes
13
answers
234k
views
Sort a list of objects in Flutter (Dart) by property value
How to sort a list of objects by the alphabetical order of one of its properties (Not the name but the actual value the property holds)?
10
votes
1
answer
3k
views
How to display response from the server in Flutter app screen?
i'm new to flutter, i'm trying to display response from the server on my screen. I get from the server Orders history and trying to display it on History screen, how can u do this?
void getAllHistory()...
47
votes
6
answers
60k
views
Undefined class 'FirebaseUser'
I'm new to Flutter. I have an Issue with Firebase Auth/ Google Auth
The FirebaseUser is not defined
Code:
FirebaseAuth _auth = FirebaseAuth.instance;
GoogleSignIn googleSignIn = GoogleSignIn();
...
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, ...
9
votes
1
answer
3k
views
No data from sever API's is not showing on Listview using flutter
I'm fetching data from server APIs, The data is being successfully fetched from the server but the issue is that when the data is provided to Listview it cant be shown. How can I show the data on ...
22
votes
1
answer
8k
views
Firestore - unexpected reads
there guys, I do have an interesting problem here and I would be really glad if any of you it will be able to help me with that.
What's my app flow:
Register with the email, password and some other ...
105
votes
1
answer
119k
views
The argument type 'String' can't be assigned to the parameter type 'Uri'
I am trying to make an HTTP POST request with the flutter plugin HTTP but I am getting an error of the title.
Does anyone know the cause of this since in my other applications this works just ...
128
votes
13
answers
252k
views
Passing data between screens in Flutter
As I'm learning Flutter I've come to navigation. I want to pass data between screens similarly to passing data between Activities in Android and passing data between View Controllers in iOS. How do I ...
10
votes
1
answer
6k
views
Is there a difference in how member variables are initialized in Dart?
In Dart, is there a difference in assigning values right away vs in constructor like in Java?
class Example {
int x = 3;
}
vs
class Example {
int x;
Example() {
x = 3;
}
}
I ...
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' ...
6
votes
3
answers
2k
views
How to call nested json data using API in flutter?
My JSON looks like this:
{
Info: [
{
c_type_id: "1",
cleaning type: "A Cleaning"
},
{
c_type_id: "2",
...
256
votes
34
answers
329k
views
Check whether there is an Internet connection available on Flutter app
I have a network call to be executed. But before doing that I need to check whether the device have internet connectivity.
This is what i have done so far:
var connectivityResult = new ...
157
votes
37
answers
222k
views
error: 'Flutter/Flutter.h' file not found when flutter run on iOS
I don't know why but I can't build or run the App in my new Macbook, I run the same folder on another Mac or my windows computer and runs perfectly.
here when I run flutter clean, I have to run pub ...
188
votes
33
answers
408k
views
Generate SHA-1 for Flutter/React-Native/Android-Native app
I'm trying to generate a SHA-1 for a Flutter app, for Android studio to support Google Sign in, but I don't know how to do that, I saw some posts that indicate to run a command, but there I need a jks ...
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?
225
votes
15
answers
286k
views
How can I get the height of a widget?
I don't understand how LayoutBuilder is used to get the height of a widget.
I need to display the list of Widgets and get their height, so I can compute some special scroll effects. I am developing a ...
222
votes
32
answers
252k
views
How to solve Flutter CERTIFICATE_VERIFY_FAILED error while performing a POST request?
I am sending a post request in Dart. It is giving a response when I test it on API testing tools such as Postman. But when I run the app. It gives me the following error:-
E/flutter ( 6264): ...
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 ...
12
votes
2
answers
4k
views
After updating cloud firestore: The operator '[]' isn't defined for the type 'Object'. Try defining the operator '[]'
Every thing was working good but when i upgraded my cloud firestore dependecy. I started getting an error "The operator '[]' isn't defined for the type 'Object'. ". This error is coming in ...
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 ...
318
votes
31
answers
352k
views
Unable to find bundled Java version on Flutter
I have Android Studio version 3.0. When I use the command flutter doctor it shows me the following:
Unable to find bundled Java version
My current Java version is (build 1.8.0_131-b11) on Windows 10....
135
votes
30
answers
216k
views
How to solve flutter web api cors error only with dart code?
It seems like CORS error is well-known issue in the web field. But I tried flutter web for the first time ever and I faced critical error.
The code below worked well in app version when it was running ...
195
votes
23
answers
239k
views
Flutter: Scrolling to a widget in ListView
How can I scroll to a special widget in a ListView?
For instance I want to scroll automatically to some Container in the ListView if I press a specific button.
ListView(children: <Widget>[
...
179
votes
21
answers
181k
views
Navigator operation requested with a context that does not include a Navigator
I'm trying to start a new screen within an onTap but I get the following error:
Navigator operation requested with a context that does not include a
Navigator.
The code I am using to navigate is:...
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 ...
231
votes
41
answers
328k
views
How to change status bar color in Flutter?
I am trying to change the status bar color to white. I found this pub on flutter. I tried to use the example code on my dart files.
193
votes
11
answers
140k
views
How to refresh an AlertDialog in Flutter?
Currently, I have an AlertDialog with an IconButton. The user can click on the IconButton, I have two colors for each click. The problem is that I need to close the AlertDialog and reopen to see the ...
12
votes
1
answer
16k
views
Flutter - ClipPath
How to create the above custom clipPath widget? (I attached the screenshot)
I tried but it's not exact output
Clipper class
class MessageClipper extends CustomClipper<Path> {
final double ...
249
votes
14
answers
165k
views
Do not use BuildContexts across async gaps
I have noticed a new lint issue in my project.
Long story short:
I need to use BuildContext in my custom classes
flutter lint tool is not happy when this being used with aysnc method.
Example:
...
293
votes
7
answers
144k
views
What is the difference between named and positional parameters in Dart?
Dart supports both named optional parameters and positional optional parameters. What are the differences between the two?
Also, how can you tell if an optional parameter was actually specified?
104
votes
4
answers
159k
views
When should I use a FutureBuilder?
I was wondering when I should use the future builder. For example, if I want to make an http request and show the results in a list view, as soon as you open the view, should I have to use the future ...
5
votes
1
answer
1k
views
How can I navigate between 2 classes, one of them requires passing data? in flutter
I have 2 classes, one of them requires passing data, and class B does not have data for this class, for example, the login class passes the registration data to class A, but class B does not have this ...
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();
...
267
votes
25
answers
234k
views
Adding a splash screen to Flutter apps
How would you approach adding a splash screen to Flutter apps? It should load and display before any other content. Currently, there is a brief flash of color before the Scaffold(home:X) widget loads.
133
votes
10
answers
84k
views
How to preserve widget states in flutter, when navigating using BottomNavigationBar?
I'm currently working on building a Flutter app that will preserve states when navigating from one screen, to another, and back again when utilizing BottomNavigationBar. Just like it works in the ...
28
votes
6
answers
17k
views
How do I join data from two Firestore collections in Flutter?
I have a chat app in Flutter using Firestore, and I have two main collections:
chats, which is keyed on auto-ids, and has message, timestamp, and uid fields.
users, which is keyed on uid, and has a ...
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 ...
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 ...
184
votes
4
answers
80k
views
Flutter: How to correctly use an Inherited Widget?
What is the correct way to use an InheritedWidget? So far I understood that it gives you the chance to propagate data down the Widget tree. In extreme if you put is as RootWidget it will be accessible ...
162
votes
14
answers
108k
views
How to remove scroll glow?
By default, flutter adds a glowing effect on ListView/GridView/... to overscrolls on android phones
I would like to remove this effect entirely or on one specific scrollable.
I know that I can change ...
80
votes
25
answers
233k
views
how to solve Execution failed for task ':app:compileFlutterBuildDebug'
I was trying to run my Flutter app and this shows up:
Compiler message:
lib/main.dart:1:8: Error: Not found: 'dart:html'
import 'dart:html';
^
Invalid depfile: C:\Users\IMBA\...