All Questions
                1,140 questions
            
            
            2
            votes
        
        
            3
            answers
        
        
            66
            views
        
    I would like to modify the values of specific elements in a list in an efficient manner [closed]
                How can I make the function more efficient?
This is all the test code I wrote:
// ignore_for_file: public_member_api_docs, sort_constructors_first
import 'package:flutter_test/flutter_test.dart';
...
            
        
       
    
            1
            vote
        
        
            0
            answers
        
        
            53
            views
        
    Adding items to a list but getting duplicated values
                So I have a class called LedColChangeDate2 that has a constructor that takes a number of parameters. Within this class is a list of it's own classes ( see code if that don't make sense ).
In another ...
            
        
       
    
            1
            vote
        
        
            1
            answer
        
        
            67
            views
        
    List<dynamic>' is not a subtype of type 'Iterable<String> in flutter while fetching data from local storage
                I am creating a demo for adding and removing favourite products ID to an obs list and later to save to local storage...
While starting the app, it should fetch all favourite products IDs from storage.
...
            
        
       
    
            0
            votes
        
        
            1
            answer
        
        
            43
            views
        
    Dart List error The class 'List' doesn't have an unnamed constructor [duplicate]
                I'm trying to create a List of servers in this way:
class Server {
  final String country;
  final String ip;
  final String username;
  final String password;
  const Server(
      {required this....
            
        
       
    
            0
            votes
        
        
            2
            answers
        
        
            46
            views
        
    Comparing the same result of List<Map<String, Object>> is not true
                I'm trying to compare values from a List which consists of Map<String, Object>, but the result always returns false despite the value I'm comparing it with is the same. Is there something I did ...
            
        
       
    
            0
            votes
        
        
            2
            answers
        
        
            62
            views
        
    Different behavior when using const before a const constructor in Dart
                In the Dart documentation, it states that we should not place const before initializing a const constructor, as the keyword is already implicit.
However, can someone explain why the following codes ...
            
        
       
    
            -1
            votes
        
        
            0
            answers
        
        
            16
            views
        
    Exception caught by widgets library ═RangeError (index): Invalid value: Valid value range is empty: 0
                i am having this error i tried to use list of cart from api getcartproducts to store in products list then to use in my widgets i don't know what is the issue!
if some one can help me i am not expert ...
            
        
       
    
            0
            votes
        
        
            1
            answer
        
        
            76
            views
        
    How to dynamically execute list.map inside a Widget (Dart/Flutter)
                I'm trying to dynamically add lines to a widget that would change depending on how many elements an array holds.
However, I run into the following error over the second list operator (everything ...
            
        
       
    
            0
            votes
        
        
            1
            answer
        
        
            121
            views
        
    Spread operator to append List to List or Lists in Dart?
                I'm trying to figure out how to use the spread operator to append a List<int> to the end of a List<List<int>>.
I know that I can use the .addAll method, however that doesn't seem to ...
            
        
       
    
            1
            vote
        
        
            1
            answer
        
        
            38
            views
        
    type 'List<dynamic>' is not a subtype of type 'Iterable<String>' while fetching data from localstorage?
                I have created LocalStorage class for saving data to local storage
The main purpose of this class to store like favourite products, cart Items and thats why I have use T so that the saveData and ...
            
        
       
    
            0
            votes
        
        
            3
            answers
        
        
            47
            views
        
    How do I assign the length of a list to a double in Flutter?
                I am trying to assign the length of a list to a double and it says that an instance member can't be accessed in an initializer:
List numlist = [1,2,3,4,5];
double size = numlist.length.toDouble();
Is ...
            
        
       
    
            0
            votes
        
        
            0
            answers
        
        
            36
            views
        
    How to disable the flutter default List.generate Dropdown effect
                enter image description here    List.generate( controller.skills.length,
(index) => buildSkillWidget(index))
I'm trying to disable the default dropdown effect of listView when we set the data. I ...
            
        
       
    
            0
            votes
        
        
            1
            answer
        
        
            56
            views
        
    Error Unhandled Exception: Converting object to an encodable object failed: Instance of 'listActivities' when i am trying to add new data to list
                so i am trying to add a new object to activity and i store it in local storage, the code looks like this
 pushObjectWisata(selectedIndex, selectedObjectId) async {
    PengunjungModel ...
            
        
       
    
            0
            votes
        
        
            1
            answer
        
        
            47
            views
        
    Replace two numbers with a their sum in not more than K in a list
                I need help with solving this task.
Given an integer array inputList and integer max. I want to create an array where every two neighboring elements are replaced by their sum if the sum of these ...
            
        
       
    
            0
            votes
        
        
            1
            answer
        
        
            56
            views
        
    List methods returns Iterable. Does it loses the order after applying a that methods?
                I would like to keep the initial order while I apply different transformations to the items.
For example, I have a list that is ordered and I would like to apply a function using map to each element. ...
            
        
       
    
            1
            vote
        
        
            1
            answer
        
        
            88
            views
        
    Calculate the number of duplicate elements in the list in Dart
                I need to create a function that counts the number of duplicate items in the list, i.e. I have this list:
['a', 'b', 'a', 'c', 'e', 'c', 'a']
The output is the number. In this case it's 2 ('a' and 'c'...
            
        
       
    
            0
            votes
        
        
            1
            answer
        
        
            76
            views
        
    defining and accessing a list to build the content of a popup menu button including icons
                In _HomePageState I have a PopupMenuButton defined as
          PopupMenuButton(
            icon: Icon(Icons.more_vert),
            itemBuilder: (BuildContext context) {
              return <...
            
        
       
    
            0
            votes
        
        
            0
            answers
        
        
            42
            views
        
    How to show a list of lists that contain lists with unknown field names?
                I'm new to using Flutter and have to make a model class for a weirdly structured API that I can't seem to find any solutions for within the documentation or anywhere online.
Here's how the JSON file ...
            
        
       
    
            1
            vote
        
        
            2
            answers
        
        
            414
            views
        
    How should I pass a List of String to a riverpod provider without breaking it?
                I'm using riverpod with code generation for state management.
Here, I've a variable named 'handle' which is passed onto the constructor of my widget and then I need to pass this variable in a list to ...
            
        
       
    
            0
            votes
        
        
            0
            answers
        
        
            20
            views
        
    A list for displaying speeds
                I have a list that should change depending on the passed value, how do I move the pointer to the current value? Also, I need to understand how this list can be moved dynamically?
Now this is a list ...
            
        
       
    
            0
            votes
        
        
            1
            answer
        
        
            535
            views
        
    Unsupported operation: Cannot add to a fixed-length list
                Hello I have a Flutter app and a UserModel which was generated by Amplify. In the UserModel I have two fields named followers and following which are lists. I wish to add the userID to them when the ...
            
        
       
    
            0
            votes
        
        
            1
            answer
        
        
            55
            views
        
    Modify the element of a json that is inside a list
                I hope you can please help me, In my project I am creating a simple list "List listArticulosAdd = [ ];" where i put this map of a json that im decoding from a request https:
mapArticuleCode =...
            
        
       
    
            0
            votes
        
        
            2
            answers
        
        
            112
            views
        
    Find common elements in two lists when elements contain more than 1 word -Dart
                I am trying to build an app that can find specific ingredients in a food item's list of ingredients. 
I have a list of food ingredients called filtered results
filtered results: [{key: enriched corn ...
            
        
       
    
            0
            votes
        
        
            1
            answer
        
        
            83
            views
        
    Read json file and parse the data key and value using flutter
                I'm currently trying to read json from azure blob storage which I'm able to do.
Now I want to parse the data and display or print the data in Flutter (dart language).
Below is the code.
    Future<...
            
        
       
    
            1
            vote
        
        
            1
            answer
        
        
            48
            views
        
    Remove item from a list and return list as a constant
                I have an enum called Activities, which is defined as such
enum Activities {
     Football,
     Basketball,
     Painting
}
Now I want to create an enum called ActivityTypes, which is supposed to be ...
            
        
       
    
            1
            vote
        
        
            1
            answer
        
        
            48
            views
        
    Dart List consisting of Lists (i.e. 2d array) weirdly linked
                I was just trying to create a 2D array in Dart as follows:
List<List<int>> data = List.filled(7, List.filled(15, 0));
  
data[1][0] = 5;
  
for (int i = 0; i< 7; i++) {
  print('Index $...
            
        
       
    
            0
            votes
        
        
            1
            answer
        
        
            55
            views
        
    How to map a List of Lists from JSON
                Let's say I have a TestObject object that I am using for a JSON response from my API.
I also have an A Object and a B object.
Within my TestObject response, I am getting a List of Object A, but I am ...
            
        
       
    
            0
            votes
        
        
            0
            answers
        
        
            45
            views
        
    Flutter fill in a List based on data contained in other two lists
                I have three list models as follow (oversimplified):
class Product extends Object {
  int? type;
  Product({type});
  Product.fromJson(Map<String, dynamic> json) {
    type= json["type"...
            
        
       
    
            1
            vote
        
        
            0
            answers
        
        
            105
            views
        
    How to reduce duration of apk generation with flutter?
                I am experiencing very long apk generation time (14 984 seconds to be accurate) for a 500 lines of code program, so I am wondering if I am doing something wrong.
I am using flutter, the flutter build ...
            
        
       
    
            1
            vote
        
        
            1
            answer
        
        
            37
            views
        
    Prevent dart generic from accepting List of itself
                I have this constructor:
PuzMat.fromMatrix(List<List<T>> data) {
  _layers.add(data);
}
By mistake I passed it a List<List<List<T>>> and it just swallowed it. I want to ...
            
        
       
    
            0
            votes
        
        
            2
            answers
        
        
            58
            views
        
    type 'Future<List<SurveyData>>' is not a subtype of type 'List<SurveyData>' in type cast (DART)
                I'm trying to retrieve data from a database, and have made these two methods inside of a certain "TodoDB" class:
  Future<List<SurveyData>> fetchAll() async {
    final database =...
            
        
       
    
            1
            vote
        
        
            2
            answers
        
        
            76
            views
        
    Flutter list getting sync between screens
                I have a list on Screen A
I Navigate to Screen B passing list on Screen A and modify few fields in the list in Screen B
And I press back.
Then the Screen A list is also getting updated.
I need to ...
            
        
       
    
            1
            vote
        
        
            3
            answers
        
        
            309
            views
        
    Listview builder scroll list automatically when inserting data - flutter
                I am developing one chat app and I am adding data to chatList which is the list of model and I am getting the newest data from the backend like when I call API it will give the last message so I need ...
            
        
       
    
            0
            votes
        
        
            1
            answer
        
        
            554
            views
        
    Why i got A value of type "'List<dynamic>' can't be returned from the function 'items' because it has a return type of 'List<Item>'"
                When i try to run this code, it is throwing me the error. I understand that my return type is mismatching but i don't know what should i do to correct it.
I tried to convert my return type to string ...
            
        
       
    
            0
            votes
        
        
            1
            answer
        
        
            62
            views
        
    Sort List of Strings by having a character Flutter
                I have a List of strings ["pana", "open","peno","alp","palp"]
and i need to sort them by having the letter "p", then alphabetically:
so the ...
            
        
       
    
            1
            vote
        
        
            2
            answers
        
        
            169
            views
        
    how to delete items in my list on flutter/dart?
                I managed to add items (authors) to my list, so now how do I delete them?
APP.DART
import 'package:autores/view/list.dart';
import 'package:flutter/material.dart';
class App extends StatelessWidget {
...
            
        
       
    
            1
            vote
        
        
            1
            answer
        
        
            96
            views
        
    How do I delete an element from the list and from the UI in Flutter?
                Image of the interface I want to delete an item of type  BasketItem from BasketItemList and also remove it from the UI. I made two external class. Here is the code:
BasketItem class:
import 'package:...
            
        
       
    
            -2
            votes
        
        
            1
            answer
        
        
            27
            views
        
    About flutter list
                Can anybody please explain to me what operation does list.from() method performs. As I am a beginner I couldn't understand it.
I just wanna know about the list.from() method
Iterable l = json.decode(...
            
        
       
    
            -3
            votes
        
        
            1
            answer
        
        
            172
            views
        
    Dart Extension: dynamically index for List
                Can you give me some proposals about make an dynamic index extension for a List object in Dart
Below is what I mean:
final List<String> myList = ['one', 'two', 'three'];
// by default, get an ...
            
        
       
    
            0
            votes
        
        
            1
            answer
        
        
            35
            views
        
    Does the myList.where() method in Dart use reference type?
                Creating my Flutter app, I am using Dart obviously.
Now, something confuses me very much coming from other programming languages:
import 'dart:developer'; // so that inspect works
// List<Product&...
            
        
       
    
            0
            votes
        
        
            2
            answers
        
        
            575
            views
        
    Flutter Expandable Listview
                I have the below list of objects that am trying to make into an expandable list grouped by month. Which is a value in the list.
{
   "status":"Success",
   "payments":[
  ...
            
        
       
    
            0
            votes
        
        
            1
            answer
        
        
            30
            views
        
    How can I get sublist value only "Bangkok" in list "EngName" (Flutter) (type: list<dynamic>)
                I want to get value as "Bangkok" in list of "EngName"
 ---> that is my json data
So that is my dart code:
import 'dart:convert';
import 'package:flutter/material.dart';
import '...
            
        
       
    
            0
            votes
        
        
            0
            answers
        
        
            50
            views
        
    Not adding the class model to the list of models
                I fill a list through the text field and add that list to list 2 by a model, provided that none of the items of the first list are available in the models of the second list.
The problem is that in ...
            
        
       
    
            0
            votes
        
        
            2
            answers
        
        
            49
            views
        
    How to change the child of a listtile when tapped
                searchResult = ['john','doe','smith'];
Expanded(
                  child: Container(
                    width: ScreenSize.screenWidth,
                    child: Center(
                      child:...
            
        
       
    
            0
            votes
        
        
            1
            answer
        
        
            39
            views
        
    How to create List of common element included if there are duplicates from two different List in Dart?
                I have Two List, and I hope to create a new list with elements in common and also with elements that have the same name
List<String> A=['cow','dog','cat','rat','dog'];
List<String> B=['dog'...
            
        
       
    
            0
            votes
        
        
            1
            answer
        
        
            81
            views
        
    Get the depth of a List in flutter/dart
                How do you get the depth of a List in flutter/ dart language, given a list like this one
List  testRy = [1,2,[3,4,[5,6],7,[8,[9,91]],10],11,12];
Can you help me create something like an extension for ...
            
        
       
    
            0
            votes
        
        
            1
            answer
        
        
            23
            views
        
    The property 'kids' can't be unconditionally accessed because the receiver can be 'null'
                I have two models 'Kindergarten' and 'Kid'. I also have GetX controller where I store kindergarten informations who has information about lists of kids.
I want to if 'kids' list is empty to show ...
            
        
       
    
            0
            votes
        
        
            1
            answer
        
        
            237
            views
        
    Flutter Windows pass list of String/dynamic to MethodChannel
                According to official documentation you have to use std::vector to pass a list for Windows MethodChannel, however, it does not specify the allowed types.
If you try to pass a list of string and read ...
            
        
       
    
            0
            votes
        
        
            2
            answers
        
        
            52
            views
        
    After restarting flutter app, the added elements to the list are removed and from UI too
                The Problem is that the List elements that the user enters in Textfields are rendered correctly. After App restart, the elements are removed from the List and from UI too.
Here is the code:
I created ...
            
        
       
    
            0
            votes
        
        
            1
            answer
        
        
            44
            views
        
    Creating a list in one screen and then accessing it from another screen with passing the list as a parameter in flutter
                I have 2 screens that I am working with in a flutter app.
Screen 1:
This screen gets property data from an API based on zipcode. In this screen, I create a list of markers to be used in Google Maps ...