问:
Join node to cluster and configure cluster using kubeadm config file
I tried to figure out solution for the task.

Configure node master02 as a master node

Join the node node02 to the cluster
I need to use the kubeadm configuration file located in /etc/kubeadm.conf for initialising cluster.
Docker run on each nodes and apt is already configured.

I join the node node02 this way:

kubadm token create --print-join-command

kubeadm token list

ssh node02

kubeadm join 192.168.103.15:6443 --token

How to configure kubeadm from file /etc/kubeadm.conf and set master02 as the master ?

答:
Both kubeadm join and kubeadm init takes a parameter --config which can point to the path of kubeadm config file.

If you do kubeadm init or kubeadm join --control-plane on a node it automatically becomes master node.


来源: stackexchange

问:
How to update text file value in Python
I want to edit/update a specific value in the text file. But in my code, it just adds the value from user's input to the text file and it do not update it at all

Here is my text File. It is composed of (employee number Lastname, First name Position Department Birthdate Rate)

```<code> 123456789, Jane, Jane, Manager, ADMIN, 1/1/2000, 1000;
 332244556, Dane, John, Manager, ADMIN, 1/2/1999, 1000;
 234567890, Doe, Jane, Manager, ADMIN, 1/2/1999, 1000;
</code>```

Here is my code

```<code>def updates():
     employee_num = []
     last_name = []
     first_name = []
     emp_possition=[]
     emp_department=[]
     emp_birthdate=[]
     emp_rate = []
     with open("empRecord.txt", 'r+') as files:
         for info in files:
             info = info.strip()
             if len(info) >= 1:
                lists = info.split(',')
                employee_num.append(lists[0].strip())
                first_name.append(lists[1].strip())
                last_name.append(lists[2].strip())
                emp_possition.append(lists[3].strip())
                emp_department.append(lists[4].strip())
                emp_birthdate.append(lists[5].strip())
                emp_rate.append(lists[6].rstrip(';'))

        y = input("Enter Employee number you wish to update Records  ")
        index = employee_num.index(y)
        print('Employee', y + "'s", "Position is:", emp_possition[index])
        changes = input("Enter the new Position of the employee")
        #it just add the input and it does not change the text file
        files.write(f"{changes}")

updates()
</code>```

答:
The contents of the changes variable is being successfully written to the end of the file (although it does not contain a terminating newline character).

However, it is unlikely to be the intended output.  To write the modified data to the file in this format, it will be necessary to rewrite the file.  Here is an example of how this might be done:

```<code>        new_position = input("Enter the new Position of the employee")

        emp_possition[index] = new_position

        files.seek(0, 0)  # go back to start
        files.truncate()

        for index in range(len(employee_num)):
            files.write("{}, {}, {}, {}, {}, {}, {};\n".format(
                employee_num[index],
                first_name[index],
                last_name[index],
                emp_possition[index],
                emp_department[index],
                emp_birthdate[index],
                emp_rate[index]))

</code>```

ContentLicense: CC BY-SA 4.0

Title: How to update text file value in Python

Body:
I want to edit/update a specific value in the text file. But in my code, it just adds the value from user's input to the text file and it do not update it at all

Here is my text File. It is composed of (employee number Lastname, First name Position Department Birthdate Rate)

 123456789, Jane, Jane, Manager, ADMIN, 1/1/2000, 1000;
 332244556, Dane, John, Manager, ADMIN, 1/2/1999, 1000;
 234567890, Doe, Jane, Manager, ADMIN, 1/2/1999, 1000;

Here is my code

def updates():
     employee_num = []
     last_name = []
     first_name = []
     emp_possition=[]
     emp_department=[]
     emp_birthdate=[]
     emp_rate = []
     with open("empRecord.txt", 'r+') as files:
         for info in files:
             info = info.strip()
             if len(info) >= 1:
                lists = info.split(',')
                employee_num.append(lists[0].strip())
                first_name.append(lists[1].strip())
                last_name.append(lists[2].strip())
                emp_possition.append(lists[3].strip())
                emp_department.append(lists[4].strip())
                emp_birthdate.append(lists[5].strip())
                emp_rate.append(lists[6].rstrip(';'))

        y = input("Enter Employee number you wish to update Records  ")
        index = employee_num.index(y)
        print('Employee', y + "'s", "Position is:", emp_possition[index])
        changes = input("Enter the new Position of the employee")
        #it just add the input and it does not change the text file
        files.write(f"{changes}")

updates()

Body:
The contents of the changes variable is being successfully written to the end of the file (although it does not contain a terminating newline character).

However, it is unlikely to be the intended output.  To write the modified data to the file in this format, it will be necessary to rewrite the file.  Here is an example of how this might be done:

        new_position = input("Enter the new Position of the employee")

        emp_possition[index] = new_position

        files.seek(0, 0)  # go back to start
        files.truncate()

        for index in range(len(employee_num)):
            files.write("{}, {}, {}, {}, {}, {}, {};\n".format(
                employee_num[index],
                first_name[index],
                last_name[index],
                emp_possition[index],
                emp_department[index],
                emp_birthdate[index],
                emp_rate[index]))


问:
SDKMAN - Is it possible to download sdks manually for installation
When I try to install an SDK (e.g. visualvm) using sdkman, download takes very long time (more than 1 hour). I was able to download zip directly from source much faster with tor browser.

Is it possible to configure sdkman to use local zip for installation instead of downloading the archive from source?

I've copied downloaded archive to ~/.sdkman/tmp and ~/.sdkman/archives folders. But when I try to install, sdkman tries to download the file again.

答:
I am able to make it work by copying the downloaded archive to ~/.sdkman/tmp folder and changing the name to what is expected by sdkman

For visualvm:

```<code>~/.sdkman/tmp$ cp /mnt/c/Users/user123/Downloads/visualvm_202.zip .
~/.sdkman/tmp$ mv visualvm_202.zip visualvm-2.0.2.bin
</code>```

For micronaut:

```<code>~/.sdkman/tmp$ cp /mnt/c/Users/user123/Downloads/micronaut-1.3.5.zip .
~/.sdkman/tmp$ mv micronaut-1.3.5.zip micronaut-1.3.5.bin
</code>```

How to find the file name sdkman is expecting:

Try to install SDK usually with sdk install visualvm 2.0.2

If downloading SDK is too slow, abort the installation process with ctrl + c

ls ~/.sdkman/tmp and you can see the filename sdkman is trying to download

Please suggest if there is any simpler and better approach

Body:
I am able to make it work by copying the downloaded archive to ~/.sdkman/tmp folder and changing the name to what is expected by sdkman

For visualvm:

~/.sdkman/tmp$ cp /mnt/c/Users/user123/Downloads/visualvm_202.zip .
~/.sdkman/tmp$ mv visualvm_202.zip visualvm-2.0.2.bin

For micronaut:

~/.sdkman/tmp$ cp /mnt/c/Users/user123/Downloads/micronaut-1.3.5.zip .
~/.sdkman/tmp$ mv micronaut-1.3.5.zip micronaut-1.3.5.bin

How to find the file name sdkman is expecting:

Try to install SDK usually with sdk install visualvm 2.0.2

If downloading SDK is too slow, abort the installation process with ctrl + c

ls ~/.sdkman/tmp and you can see the filename sdkman is trying to download

Please suggest if there is any simpler and better approach


问:
Rolling sum over a partition in python
Code:

```<code>data['rolling_sum'] = data.groupby(['User_id'])['Amount'].rolling().sum()
</code>```

Error

```<code>TypeError: incompatible index of inserted column with frame index
</code>```

Please help in figuring out the mistake in the code. An alternative method would also be appreciated.

答:
Use DataFrame.reset_index with level=0 and drop=True for remove first level of MultiIndex, what is safer because aligned by original index values:

```<code>data = pd.DataFrame({
         'Amount':[5,3,6,9,2,4],
         'User_id':list('aababb')
})
data['rolling_sum1'] = data.groupby(['User_id'])['Amount'].rolling(2).sum().reset_index(level=0, drop=True)
</code>```

If assign only numpy array is possible values are added incorrectly:

```<code>data['rolling_sum2'] = data.groupby(['User_id'])['Amount'].rolling(2).sum().values
print (data)
   Amount User_id  rolling_sum1  rolling_sum2
0       5       a           NaN           NaN
1       3       a           8.0           8.0
2       6       b           NaN          12.0
3       9       a          12.0           NaN
4       2       b           8.0           8.0
5       4       b           6.0           6.0
</code>```

Title: Rolling sum over a partition in python

Body:
Code:

data['rolling_sum'] = data.groupby(['User_id'])['Amount'].rolling().sum()

Error

TypeError: incompatible index of inserted column with frame index

Please help in figuring out the mistake in the code. An alternative method would also be appreciated.

Body:
Use DataFrame.reset_index with level=0 and drop=True for remove first level of MultiIndex, what is safer because aligned by original index values:

data = pd.DataFrame({
         'Amount':[5,3,6,9,2,4],
         'User_id':list('aababb')
})
data['rolling_sum1'] = data.groupby(['User_id'])['Amount'].rolling(2).sum().reset_index(level=0, drop=True)

If assign only numpy array is possible values are added incorrectly:

data['rolling_sum2'] = data.groupby(['User_id'])['Amount'].rolling(2).sum().values
print (data)
   Amount User_id  rolling_sum1  rolling_sum2
0       5       a           NaN           NaN
1       3       a           8.0           8.0
2       6       b           NaN          12.0
3       9       a          12.0           NaN
4       2       b           8.0           8.0
5       4       b           6.0           6.0


问:
I have accidentally deleted a page from Azure DevOps Wiki. How can I recover it?
I have accidentally deleted a Wiki-page from our repository in Azure DevOps.
(How) can I recover it?</p>

答:
Assuming you're managing a provisioned wiki (vs using published code as a wiki):

Look in the top-right corner for the vertical 3-dot menu, where there's an option to view revisions:

Choose the revision you want to revert to (e.g. the one prior to deleting the needed wiki page), from the list (click on its version hash):

From the revision details, select "Revert":

At this point, your wiki should be at its prior state, and your wiki page should once again be available.

Note: If you're using published code as a wiki, you would recover/revert your changes as you would with any other code commit.

More details may be found here.


问:
How to extend terraform module input variable schema without breaking existing clients?
I have a module with the following input variable:

```<code>variable "apsvc_map" {
  description = "The App Services sharing the same App Service Plan. Maps an App Service name to its properties."
  type        = map(object({
    identity_ids = list(string),
    disabled = bool
  }))
}
</code>```

Now I would like to add a new property to the schema - no_custom_hostname_binding. The new version would be:

```<code>variable "apsvc_map" {
  description = "The App Services sharing the same App Service Plan. Maps an App Service name to its properties."
  type        = map(object({
    identity_ids = list(string),
    disabled = bool
    no_custom_hostname_binding = bool
  }))
}
</code>```

And this change can be made backwards compatible in the module code with the help of the try function, because omitting the new property is equivalent to providing it with the false value.

However, terraform treats this schema strictly and would not allow passing an input without the new field:

```<code>2020-05-30T15:34:20.8061749Z Error: Invalid value for module argument
2020-05-30T15:34:20.8062005Z
2020-05-30T15:34:20.8062205Z   on ..\..\modules\web\main.tf line 47, in module "web":
2020-05-30T15:34:20.8062336Z   47:   apsvc_map = {
2020-05-30T15:34:20.8062484Z   48:     dfhub = {
2020-05-30T15:34:20.8062727Z   49:       disabled     = false
2020-05-30T15:34:20.8065156Z   50:       identity_ids = [local.identity_id]
2020-05-30T15:34:20.8065370Z   51:     }
2020-05-30T15:34:20.8065459Z   52:   }
2020-05-30T15:34:20.8065538Z
</code>```

I understand from the error that terraform complains because I did not specify the value for the new property in the input.

So, there are three solutions:

Update all the existing code to add the new property - out of the question.

Tag the new version of the module differently and let the new code reference the new tag, while the old code continues to reference the old tag - in the long run would lead to proliferation of tags, creating all kinds of bizarre Cartesian multiplications of features in the tag names. Ultimately - out of the question.

Relax the input variable schema by commenting out the optional properties and use try in the code.

The last option is not ideal, because the documentation for the module would not list the optional properties. But from the code management perspective - it is the best.

So the question is - can input object properties be defined as optional? Ideally, it should include the default value, but I am OK with the try approach for now.

EDIT 1

I actually thought I could pass unknown properties in the object, but no. Once the schema is given it is nothing less nothing more. So, the only backwards compatible solution is to use map(any) in my case.

答:
Given your options, your preferences, and the fact that Terraform 0.12 doesn't support and Terraform 0.13 likely won't support optional or default values on objects, I think you have a fourth option:

```<code>variable "apsvc_map" {
  description = "The App Services sharing the same App Service Plan. Maps an App Service name to its properties."
  default = {}
  type        = map(object({
    identity_ids = list(string),
    disabled = bool
  }))
}

variable "no_custom_hostname_binding" {
  description = "Whether or not an App Service should disable hostname binding. Maps an App Service name to an override of the no_custom_hostname_binding property."
  type        = map(bool)
}
</code>```

From there, you can use it like this:

```<code>lookup(var.no_custom_hostname_binding[local.awsvpc_map_key], null)
</code>```

And declare overrides like this:

```<code>no_custom_hostname_binding = {
  "vpc_key" = true
}
</code>```

in expressions where you need to know that parameter. This is not super-elegant, but without optional parameters, you don't have many good alternatives.

You can follow this pattern to add as many optional overrides as you need and add more later also without breaking clients.

Body:
I have a module with the following input variable:

variable "apsvc_map" {
  description = "The App Services sharing the same App Service Plan. Maps an App Service name to its properties."
  type        = map(object({
    identity_ids = list(string),
    disabled = bool
  }))
}

Now I would like to add a new property to the schema - no_custom_hostname_binding. The new version would be:

variable "apsvc_map" {
  description = "The App Services sharing the same App Service Plan. Maps an App Service name to its properties."
  type        = map(object({
    identity_ids = list(string),
    disabled = bool
    no_custom_hostname_binding = bool
  }))
}

And this change can be made backwards compatible in the module code with the help of the try function, because omitting the new property is equivalent to providing it with the false value.

However, terraform treats this schema strictly and would not allow passing an input without the new field:

2020-05-30T15:34:20.8061749Z Error: Invalid value for module argument
2020-05-30T15:34:20.8062005Z
2020-05-30T15:34:20.8062205Z   on ..\..\modules\web\main.tf line 47, in module "web":
2020-05-30T15:34:20.8062336Z   47:   apsvc_map = {
2020-05-30T15:34:20.8062484Z   48:     dfhub = {
2020-05-30T15:34:20.8062727Z   49:       disabled     = false
2020-05-30T15:34:20.8065156Z   50:       identity_ids = [local.identity_id]
2020-05-30T15:34:20.8065370Z   51:     }
2020-05-30T15:34:20.8065459Z   52:   }
2020-05-30T15:34:20.8065538Z

I understand from the error that terraform complains because I did not specify the value for the new property in the input.

So, there are three solutions:

Update all the existing code to add the new property - out of the question.

Tag the new version of the module differently and let the new code reference the new tag, while the old code continues to reference the old tag - in the long run would lead to proliferation of tags, creating all kinds of bizarre Cartesian multiplications of features in the tag names. Ultimately - out of the question.

Relax the input variable schema by commenting out the optional properties and use try in the code.

The last option is not ideal, because the documentation for the module would not list the optional properties. But from the code management perspective - it is the best.

So the question is - can input object properties be defined as optional? Ideally, it should include the default value, but I am OK with the try approach for now.

EDIT 1

I actually thought I could pass unknown properties in the object, but no. Once the schema is given it is nothing less nothing more. So, the only backwards compatible solution is to use map(any) in my case.

Body:
Given your options, your preferences, and the fact that Terraform 0.12 doesn't support and Terraform 0.13 likely won't support optional or default values on objects, I think you have a fourth option:

variable "apsvc_map" {
  description = "The App Services sharing the same App Service Plan. Maps an App Service name to its properties."
  default = {}
  type        = map(object({
    identity_ids = list(string),
    disabled = bool
  }))
}

variable "no_custom_hostname_binding" {
  description = "Whether or not an App Service should disable hostname binding. Maps an App Service name to an override of the no_custom_hostname_binding property."
  type        = map(bool)
}

From there, you can use it like this:

lookup(var.no_custom_hostname_binding[local.awsvpc_map_key], null)

And declare overrides like this:

no_custom_hostname_binding = {
  "vpc_key" = true
}

in expressions where you need to know that parameter. This is not super-elegant, but without optional parameters, you don't have many good alternatives.

You can follow this pattern to add as many optional overrides as you need and add more later also without breaking clients.


问:
How do I set up a connection string into appsettings.json?
How can I set up a connection string in my ASP.NET Core blazor WebAssembly Server component where I created the appsettings.json.

```<code>{
  "ConnectionStrings": {
    "SQLiteTestConnection": "Data Source=./TestDB.db",
  }
}
</code>```

Right now it looks like this but I cant create the database via Update-Database.

Startup.cs:

```<code>...
 public void ConfigureServices(IServiceCollection services)
        {
            services.AddMvc();
            services.AddResponseCompression(opts =>
            {
                opts.MimeTypes = ResponseCompressionDefaults.MimeTypes.Concat(
                    new[] { "application/octet-stream" });
            });

            // Adding the DbContext references
            services.AddDbContext<SQLiteTestDbContext>(options =>
                options.UseSqlite("./TestDB.db"));
        }
...
</code>```

my DbContext which is in use.
This DbContext is stored in my Blazor Server component

using DB_SQLite;
using DB_SQLite.SQL_Models;
using System.Collections.Generic;
using Microsoft.EntityFrameworkCore;

namespace BlazorWeb.Server.Data
{
    public class SQLiteTestDbContext : DbContext
    {
        #region Constructor

        // Default parameterless Constructor
        public SQLiteTestDbContext(DbContextOptions options)
            : base(options)
        {

        }

        #endregion

        public DbSet<ObjectModel> Objects { get; set; }

        protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
            => optionsBuilder.UseSqlite("Data Source=./TestDB.db");

        protected override void OnModelCreating(ModelBuilder modelBuilder)
        {
            #region Configure Object

            modelBuilder.Entity<ObjectModel>().HasData(LoadObjects());
            base.OnModelCreating(modelBuilder);

            #endregion
        }

        #region Seeding

        private List<ObjectModel> LoadObjects()
        {
            return new List<ObjectModel>
            {
                new ObjectModel() { Id = 1, Name = "Schraube", TagName = "Werkzeug" ,PreviewImage = "null"},
                new ObjectModel() { Id = 2, Name = "Gabelstapler", TagName = "Fahrzeug" ,PreviewImage = "null"},
                new ObjectModel() { Id = 3, Name = "Zange", TagName = "Werkzeug" , PreviewImage = "null"},
                new ObjectModel() { Id = 4, Name = "Sechskantschraube", TagName = "Werkzeug", PreviewImage = "null"},
            };
        }

        #endregion
    }
}

```

Im also creating some fake data into the database in the DbContext Class.

答:
In your Startup.cs class declare an instance of IConfiguration as a field and initialize it in the constructor.

public class Startup
{
    private IConfiguration Configuration { get; }

    public Startup()
    {
        var configurationBuilder = new ConfigurationBuilder()
            .AddJsonFile("appsettings.json", true, false);

        Configuration = configurationBuilder.Build();
    }

    // Class continues
}
```

<p>Then in your <code>ConfigureServices()</code> method, you can use the following to declare your <code>IConfiguration</code> instance as a singleton service, which allows you to inject it and use it other classes.</p>

<pre class="lang-cs prettyprint-override"><code>services.AddSingleton(Configuration);
</code>```

You actually do not need to specify your database connection string in your DbContext class since you have specified it in your service collection.

So in your Startup.cs, you would now do

services.AddDbContext<SQLiteTestDbContext>
    (options => options.UseSqlite(Configuration["ConnectionStrings:SQLiteTestConnection"]));
```

You may need to reference the following packages

Microsoft.Extensions.Configuration

Microsoft.Extensions.Configuration.FileExtensions

Microsoft.Extensions.Configuration.Json

Body:
How can I set up a connection string in my ASP.NET Core blazor WebAssembly Server component where I created the appsettings.json.

{
  "ConnectionStrings": {
    "SQLiteTestConnection": "Data Source=./TestDB.db",
  }
}

Right now it looks like this but I cant create the database via Update-Database.

Startup.cs:

...
 public void ConfigureServices(IServiceCollection services)
        {
            services.AddMvc();
            services.AddResponseCompression(opts =>
            {
                opts.MimeTypes = ResponseCompressionDefaults.MimeTypes.Concat(
                    new[] { "application/octet-stream" });
            });

            // Adding the DbContext references
            services.AddDbContext<SQLiteTestDbContext>(options =>
                options.UseSqlite("./TestDB.db"));
        }
...

my DbContext which is in use.
This DbContext is stored in my Blazor Server component

using DB_SQLite;
using DB_SQLite.SQL_Models;
using System.Collections.Generic;
using Microsoft.EntityFrameworkCore;

namespace BlazorWeb.Server.Data
{
    public class SQLiteTestDbContext : DbContext
    {
        #region Constructor

        // Default parameterless Constructor
        public SQLiteTestDbContext(DbContextOptions options)
            : base(options)
        {

        }

        #endregion

        public DbSet<ObjectModel> Objects { get; set; }

        protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
            => optionsBuilder.UseSqlite("Data Source=./TestDB.db");

        protected override void OnModelCreating(ModelBuilder modelBuilder)
        {
            #region Configure Object

            modelBuilder.Entity<ObjectModel>().HasData(LoadObjects());
            base.OnModelCreating(modelBuilder);

            #endregion
        }

        #region Seeding

        private List<ObjectModel> LoadObjects()
        {
            return new List<ObjectModel>
            {
                new ObjectModel() { Id = 1, Name = "Schraube", TagName = "Werkzeug" ,PreviewImage = "null"},
                new ObjectModel() { Id = 2, Name = "Gabelstapler", TagName = "Fahrzeug" ,PreviewImage = "null"},
                new ObjectModel() { Id = 3, Name = "Zange", TagName = "Werkzeug" , PreviewImage = "null"},
                new ObjectModel() { Id = 4, Name = "Sechskantschraube", TagName = "Werkzeug", PreviewImage = "null"},
            };
        }

        #endregion
    }
}

Im also creating some fake data into the database in the DbContext Class.

Body:
In your Startup.cs class declare an instance of IConfiguration as a field and initialize it in the constructor.

public class Startup
{
    private IConfiguration Configuration { get; }

    public Startup()
    {
        var configurationBuilder = new ConfigurationBuilder()
            .AddJsonFile("appsettings.json", true, false);

        Configuration = configurationBuilder.Build();
    }

    // Class continues
}

Then in your ConfigureServices() method, you can use the following to declare your IConfiguration instance as a singleton service, which allows you to inject it and use it other classes.

services.AddSingleton(Configuration);

You actually do not need to specify your database connection string in your DbContext class since you have specified it in your service collection.

So in your Startup.cs, you would now do

services.AddDbContext<SQLiteTestDbContext>
    (options => options.UseSqlite(Configuration["ConnectionStrings:SQLiteTestConnection"]));

You may need to reference the following packages

Microsoft.Extensions.Configuration

Microsoft.Extensions.Configuration.FileExtensions

Microsoft.Extensions.Configuration.Json


问:
The getter 'length' was called on null
I trying to retrieve my data from API server and present it in my mobile application using flutter .. but i got error

The getter 'length' was called on null

Any advice plz ... thanks

my code is

```<code>import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'dart:core';
import 'dart:convert';
import 'package:http/http.dart' as http;
import 'package:json/add.dart';

void main() => runApp(MyApp());

Future<List> getData() async {
  String url = 'http://192.168.0.55:4000/api/contacts';
  http.Response response = await http.get(url);
  return json.decode(response.body);
}

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    SystemChrome.setPreferredOrientations([DeviceOrientation.portraitUp]);
    return MaterialApp(
      routes: <String, WidgetBuilder>{
        '/Add': (BuildContext context) => new Add(),
      },
      home: HomePage(),
    );
  }
}

class HomePage extends StatefulWidget {
  @override
  HomePageState createState() {
    return new HomePageState();
  }
}

class HomePageState extends State<HomePage> {
  List data;

  void getList() async {
    this.data = (await getData());
    print(data);
  }

  @override
  void initState() {
    getList();
  }

  Widget build(BuildContext context) {
    return new Scaffold(
      appBar: AppBar(
        centerTitle: true,
        title: new Text("Chat"),
      ),
      body: new Center(
        child: new ListView.builder(
            itemCount: data.length,
            itemBuilder: (BuildContext context, int position) {
              return new ListTile(
                title: new Text('${data[position]['name']}'),
              );
            }),
      ),
      floatingActionButton: FloatingActionButton(
          child: Icon(Icons.person_add),
          onPressed: () {
            Navigator.of(context).pushNamed('/Add');
          }),
    );
  }
}
</code>```

Output Console

```Performing hot restart...
Syncing files to device Android SDK built for x86...
Restarted application in 4,410ms.
I/flutter (10119): ══╡ EXCEPTION CAUGHT BY WIDGETS LIBRARY ╞═══════════════════════════════════════════════════════════
I/flutter (10119): The following NoSuchMethodError was thrown building HomePage(dirty, state: HomePageState#80635):
I/flutter (10119): The getter 'length' was called on null.
I/flutter (10119): Receiver: null
I/flutter (10119): Tried calling: length
I/flutter (10119):
I/flutter (10119): When the exception was thrown, this was the stack:
I/flutter (10119): #0      Object.noSuchMethod (dart:core/runtime/libobject_patch.dart:50:5)
I/flutter (10119): #1      HomePageState.build (package:json/main.dart:59:29)
I/flutter (10119): #2      StatefulElement.build (package:flutter/src/widgets/framework.dart:3809:27)
I/flutter (10119): #3      ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3721:15)
I/flutter (10119): #4      Element.rebuild (package:flutter/src/widgets/framework.dart:3547:5)
I/flutter (10119): #5      ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:3701:5)
I/flutter (10119): #6      StatefulElement._firstBuild (package:flutter/src/widgets/framework.dart:3848:11)
I/flutter (10119): #7      ComponentElement.mount (package:flutter/src/widgets/framework.dart:3696:5)
I/flutter (10119): #8      Element.inflateWidget (package:flutter/src/widgets/framework.dart:2950:14)
I/flutter (10119): #9      Element.updateChild (package:flutter/src/widgets/framework.dart:2753:12)
I/flutter (10119): #10     SingleChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:4860:14)
I/flutter (10119): #11     Element.inflateWidget (package:flutter/src/widgets/framework.dart:2950:14)
I/flutter (10119): #12     Element.updateChild (package:flutter/src/widgets/framework.dart:2753:12)
I/flutter (10119): #13     ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3732:16)
I/flutter (10119): #14     Element.rebuild (package:flutter/src/widgets/framework.dart:3547:5)
I/flutter (10119): #15     ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:3701:5)
I/flutter (10119): #16     ComponentElement.mount (package:flutter/src/widgets/framework.dart:3696:5)
I/flutter (10119): #17     Element.inflateWidget (package:flutter/src/widgets/framework.dart:2950:14)
I/flutter (10119): #18     Element.updateChild (package:flutter/src/widgets/framework.dart:2753:12)
I/flutter (10119): #19     SingleChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:4860:14)
I/flutter (10119): #20     Element.inflateWidget (package:flutter/src/widgets/framework.dart:2950:14)
I/flutter (10119): #21     Element.updateChild (package:flutter/src/widgets/framework.dart:2753:12)
I/flutter (10119): #22     SingleChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:4860:14)
I/flutter (10119): #23     Element.inflateWidget (package:flutter/src/widgets/framework.dart:2950:14)
I/flutter (10119): #24     Element.updateChild (package:flutter/src/widgets/framework.dart:2753:12)
I/flutter (10119): #25     SingleChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:4860:14)
I/flutter (10119): #26     Element.inflateWidget (package:flutter/src/widgets/framework.dart:2950:14)
I/flutter (10119): #27     Element.updateChild (package:flutter/src/widgets/framework.dart:2753:12)
I/flutter (10119): #28     SingleChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:4860:14)
I/flutter (10119): #29     Element.inflateWidget (package:flutter/src/widgets/framework.dart:2950:14)
I/flutter (10119): #30     Element.updateChild (package:flutter/src/widgets/framework.dart:2753:12)
I/flutter (10119): #31     ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3732:16)
I/flutter (10119): #32     Element.rebuild (package:flutter/src/widgets/framework.dart:3547:5)
I/flutter (10119): #33     ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:3701:5)
I/flutter (10119): #34     StatefulElement._firstBuild (package:flutter/src/widgets/framework.dart:3848:11)
I/flutter (10119): #35     ComponentElement.mount (package:flutter/src/widgets/framework.dart:3696:5)
I/flutter (10119): #36     Element.inflateWidget (package:flutter/src/widgets/framework.dart:2950:14)
I/flutter (10119): #37     Element.updateChild (package:flutter/src/widgets/framework.dart:2753:12)
I/flutter (10119): #38     ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3732:16)
I/flutter (10119): #39     Element.rebuild (package:flutter/src/widgets/framework.dart:3547:5)
I/flutter (10119): #40     ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:3701:5)
I/flutter (10119): #41     ComponentElement.mount (package:flutter/src/widgets/framework.dart:3696:5)
I/flutter (10119): #42     Element.inflateWidget (package:flutter/src/widgets/framework.dart:2950:14)
I/flutter (10119): #43     Element.updateChild (package:flutter/src/widgets/framework.dart:2753:12)
I/flutter (10119): #44     ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3732:16)
I/flutter (10119): #45     Element.rebuild (package:flutter/src/widgets/framework.dart:3547:5)
I/flutter (10119): #46     ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:3701:5)
I/flutter (10119): #47     StatefulElement._firstBuild (package:flutter/src/widgets/framework.dart:3848:11)
I/flutter (10119): #48     ComponentElement.mount (package:flutter/src/widgets/framework.dart:3696:5)
I/flutter (10119): #49     Element.inflateWidget (package:flutter/src/widgets/framework.dart:2950:14)
I/flutter (10119): #50     Element.updateChild (package:flutter/src/widgets/framework.dart:2753:12)
I/flutter (10119): #51     SingleChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:4860:14)
I/flutter (10119): #52     Element.inflateWidget (package:flutter/src/widgets/framework.dart:2950:14)
I/flutter (10119): #53     Element.updateChild (package:flutter/src/widgets/framework.dart:2753:12)
I/flutter (10119): #54     ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3732:16)
I/flutter (10119): #55     Element.rebuild (package:flutter/src/widgets/framework.dart:3547:5)
I/flutter (10119): #56     ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:3701:5)
I/flutter (10119): #57     ComponentElement.mount (package:flutter/src/widgets/framework.dart:3696:5)
I/flutter (10119): #58     Element.inflateWidget (package:flutter/src/widgets/framework.dart:2950:14)
I/flutter (10119): #59     Element.updateChild (package:flutter/src/widgets/framework.dart:2753:12)
I/flutter (10119): #60     SingleChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:4860:14)
I/flutter (10119): #61     Element.inflateWidget (package:flutter/src/widgets/framework.dart:2950:14)
I/flutter (10119): #62     Element.updateChild (package:flutter/src/widgets/framework.dart:2753:12)
I/flutter (10119): #63     ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3732:16)
I/flutter (10119): #64     Element.rebuild (package:flutter/src/widgets/framework.dart:3547:5)
I/flutter (10119): #65     ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:3701:5)
I/flutter (10119): #66     StatefulElement._firstBuild (package:flutter/src/widgets/framework.dart:3848:11)
I/flutter (10119): #67     ComponentElement.mount (package:flutter/src/widgets/framework.dart:3696:5)
I/flutter (10119): #68     Element.inflateWidget (package:flutter/src/widgets/framework.dart:2950:14)
I/flutter (10119): #69     Element.updateChild (package:flutter/src/widgets/framework.dart:2753:12)
I/flutter (10119): #70     ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3732:16)
I/flutter (10119): #71     Element.rebuild (package:flutter/src/widgets/framework.dart:3547:5)
I/flutter (10119): #72     ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:3701:5)
I/flutter (10119): #73     ComponentElement.mount (package:flutter/src/widgets/framework.dart:3696:5)
I/flutter (10119): #74     Element.inflateWidget (package:flutter/src/widgets/framework.dart:2950:14)
I/flutter (10119): #75     Element.updateChild (package:flutter/src/widgets/framework.dart:2753:12)
I/flutter (10119): #76     SingleChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:4860:14)
I/flutter (10119): #77     Element.inflateWidget (package:flutter/src/widgets/framework.dart:2950:14)
I/flutter (10119): #78     Element.updateChild (package:flutter/src/widgets/framework.dart:2753:12)
I/flutter (10119): #79     ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3732:16)
I/flutter (10119): #80     Element.rebuild (package:flutter/src/widgets/framework.dart:3547:5)
I/flutter (10119): #81     ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:3701:5)
I/flutter (10119): #82     ComponentElement.mount (package:flutter/src/widgets/framework.dart:3696:5)
I/flutter (10119): #83     Element.inflateWidget (package:flutter/src/widgets/framework.dart:2950:14)
I/flutter (10119): #84     Element.updateChild (package:flutter/src/widgets/framework.dart:2753:12)
I/flutter (10119): #85     ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3732:16)
I/flutter (10119): #86     Element.rebuild (package:flutter/src/widgets/framework.dart:3547:5)
I/flutter (10119): #87     ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:3701:5)
I/flutter (10119): #88     StatefulElement._firstBuild (package:flutter/src/widgets/framework.dart:3848:11)
I/flutter (10119): #89     ComponentElement.mount (package:flutter/src/widgets/framework.dart:3696:5)
I/flutter (10119): #90     Element.inflateWidget (package:flutter/src/widgets/framework.dart:2950:14)
I/flutter (10119): #91     Element.updateChild (package:flutter/src/widgets/framework.dart:2753:12)
I/flutter (10119): #92     ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3732:16)
I/flutter (10119): #93     Element.rebuild (package:flutter/src/widgets/framework.dart:3547:5)
I/flutter (10119): #94     ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:3701:5)
I/flutter (10119): #95     StatefulElement._firstBuild (package:flutter/src/widgets/framework.dart:3848:11)
I/flutter (10119): #96     ComponentElement.mount (package:flutter/src/widgets/framework.dart:3696:5)
I/flutter (10119): #97     Element.inflateWidget (package:flutter/src/widgets/framework.dart:2950:14)
I/flutter (10119): #98     MultiChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:4965:32)
I/flutter (10119): #99     Element.inflateWidget (package:flutter/src/widgets/framework.dart:2950:14)
I/flutter (10119): #100    Element.updateChild (package:flutter/src/widgets/framework.dart:2753:12)
I/flutter (10119): #101    _TheatreElement.mount (package:flutter/src/widgets/overlay.dart:493:16)
I/flutter (10119): #102    Element.inflateWidget (package:flutter/src/widgets/framework.dart:2950:14)
I/flutter (10119): #103    Element.updateChild (package:flutter/src/widgets/framework.dart:2753:12)
I/flutter (10119): #104    ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3732:16)
I/flutter (10119): #105    Element.rebuild (package:flutter/src/widgets/framework.dart:3547:5)
I/flutter (10119): #106    ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:3701:5)
I/flutter (10119): #107    StatefulElement._firstBuild (package:flutter/src/widgets/framework.dart:3848:11)
I/flutter (10119): #108    ComponentElement.mount (package:flutter/src/widgets/framework.dart:3696:5)
I/flutter (10119): #109    Element.inflateWidget (package:flutter/src/widgets/framework.dart:2950:14)
I/flutter (10119): #110    Element.updateChild (package:flutter/src/widgets/framework.dart:2753:12)
I/flutter (10119): #111    ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3732:16)
I/flutter (10119): #112    Element.rebuild (package:flutter/src/widgets/framework.dart:3547:5)
I/flutter (10119): #113    ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:3701:5)
I/flutter (10119): #114    ComponentElement.mount (package:flutter/src/widgets/framework.dart:3696:5)
I/flutter (10119): #115    Element.inflateWidget (package:flutter/src/widgets/framework.dart:2950:14)
I/flutter (10119): #116    Element.updateChild (package:flutter/src/widgets/framework.dart:2753:12)
I/flutter (10119): #117    SingleChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:4860:14)
I/flutter (10119): #118    Element.inflateWidget (package:flutter/src/widgets/framework.dart:2950:14)
I/flutter (10119): #119    Element.updateChild (package:flutter/src/widgets/framework.dart:2753:12)
I/flutter (10119): #120    ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3732:16)
I/flutter (10119): #121    Element.rebuild (package:flutter/src/widgets/framework.dart:3547:5)
I/flutter (10119): #122    ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:3701:5)
I/flutter (10119): #123    StatefulElement._firstBuild (package:flutter/src/widgets/framework.dart:3848:11)
I/flutter (10119): #124    ComponentElement.mount (package:flutter/src/widgets/framework.dart:3696:5)
I/flutter (10119): #125    Element.inflateWidget (package:flutter/src/widgets/framework.dart:2950:14)
I/flutter (10119): #126    Element.updateChild (package:flutter/src/widgets/framework.dart:2753:12)
I/flutter (10119): #127    SingleChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:4860:14)
I/flutter (10119): #128    Element.inflateWidget (package:flutter/src/widgets/framework.dart:3547:5)
I/flutter (10119): #163    ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:3701:5)
I/flutter (10119): #164    ComponentElement.mount (package:flutter/src/widgets/framework.dart:3696:5)
I/flutter (10119): #165    Element.inflateWidget (package:flutter/src/widgets/framework.dart:2950:14)
I/flutter (10119): #166    Element.updateChild (package:flutter/src/widgets/framework.dart:2753:12)
I/flutter (10119): #167    ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3732:16)
I/flutter (10119): #168    Element.rebuild (package:flutter/src/widgets/framework.dart:3547:5)
I/flutter (10119): #169    ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:3701:5)
I/flutter (10119): #170    ComponentElement.mount (package:flutter/src/widgets/framework.dart:3696:5)
I/flutter (10119): #171    Element.inflateWidget (package:flutter/src/widgets/framework.dart:2950:14)
I/flutter (10119): #172    Element.updateChild (package:flutter/src/widgets/framework.dart:2753:12)
I/flutter (10119): #173    ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3732:16)
I/flutter (10119): #174    Element.rebuild (package:flutter/src/widgets/framework.dart:3547:5)
I/flutter (10119): #175    ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:3701:5)
I/flutter (10119): #176    ComponentElement.mount (package:flutter/src/widgets/framework.dart:3696:5)
I/flutter (10119): #177    Element.inflateWidget (package:flutter/src/widgets/framework.dart:2950:14)
I/flutter (10119): #178    Element.updateChild (package:flutter/src/widgets/framework.dart:2753:12)
I/flutter (10119): #179    SingleChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:4860:14)
I/flutter (10119): #180    Element.inflateWidget (package:flutter/src/widgets/framework.dart:2950:14)
I/flutter (10119): #181    Element.updateChild (package:flutter/src/widgets/framework.dart:2753:12)
I/flutter (10119): #182    ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3732:16)
I/flutter (10119): #183    Element.rebuild (package:flutter/src/widgets/framework.dart:3547:5)
I/flutter (10119): #184    ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:3701:5)
I/flutter (10119): #185    StatefulElement._firstBuild (package:flutter/src/widgets/framework.dart:3848:11)
I/flutter (10119): #186    ComponentElement.mount (package:flutter/src/widgets/framework.dart:3696:5)
I/flutter (10119): #187    Element.inflateWidget (package:flutter/src/widgets/framework.dart:2753:12)
I/flutter (10119): #202    ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3732:16)
I/flutter (10119): #203    Element.rebuild (package:flutter/src/widgets/framework.dart:3547:5)
I/flutter (10119): #204    ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:3701:5)
I/flutter (10119): #205    ComponentElement.mount (package:flutter/src/widgets/framework.dart:3696:5)
I/flutter (10119): #206    Element.inflateWidget (package:flutter/src/widgets/framework.dart:2950:14)
I/flutter (10119): #207    Element.updateChild (package:flutter/src/widgets/framework.dart:2753:12)
I/flutter (10119): #208    ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3732:16)
I/flutter (10119): #209    Element.rebuild (package:flutter/src/widgets/framework.dart:3547:5)
I/flutter (10119): #210    ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:3701:5)
I/flutter (10119): #211    ComponentElement.mount (package:flutter/src/widgets/framework.dart:3696:5)
I/flutter (10119): #212    Element.inflateWidget (package:flutter/src/widgets/framework.dart:2950:14)
I/flutter (10119): #213    Element.updateChild (package:flutter/src/widgets/framework.dart:2753:12)
I/flutter (10119): #214    ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3732:16)
I/flutter (10119): #215    Element.rebuild (package:flutter/src/widgets/framework.dart:3547:5)
I/flutter (10119): #216    ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:3701:5)
I/flutter (10119): #217    ComponentElement.mount (package:flutter/src/widgets/framework.dart:3696:5)
I/flutter (10119): #218    Element.inflateWidget (package:flutter/src/widgets/framework.dart:2950:14)
I/flutter (10119): #219    Element.updateChild (package:flutter/src/widgets/framework.dart:2753:12)
I/flutter (10119): #220    ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3732:16)
I/flutter (10119): #221    Element.rebuild (package:flutter/src/widgets/framework.dart:3547:5)
I/flutter (10119): #222    ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:3701:5)
I/flutter (10119): #223    StatefulElement._firstBuild (package:flutter/src/widgets/framework.dart:3848:11)
I/flutter (10119): #224    ComponentElement.mount (package:flutter/src/widgets/framework.dart:3696:5)
I/flutter (10119): #225    Element.inflateWidget (package:flutter/src/widgets/framework.dart:2950:14)
I/flutter (10119): #226    Element.updateChild (package:flutter/src/widgets/framework.dart:2753:12)
I/flutter (10119): #227    ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3732:16)
I/flutter (10119): #228    Element.rebuild (package:flutter/src/widgets/framework.dart:3547:5)
I/flutter (10119): #229    ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:3701:5)
I/flutter (10119): #230    ComponentElement.mount (package:flutter/src/widgets/framework.dart:3696:5)
I/flutter (10119): #231    Element.inflateWidget (package:flutter/src/widgets/framework.dart:2950:14)
I/flutter (10119): #232    Element.updateChild (package:flutter/src/widgets/framework.dart:2753:12)
I/flutter (10119): #233    ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3732:16)
I/flutter (10119): #234    Element.rebuild (package:flutter/src/widgets/framework.dart:3547:5)
I/flutter (10119): #235    ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:3701:5)
I/flutter (10119): #236    StatefulElement._firstBuild (package:flutter/src/widgets/framework.dart:3848:11)
I/flutter (10119): #237    ComponentElement.mount (package:flutter/src/widgets/framework.dart:3696:5)
I/flutter (10119): #238    Element.inflateWidget (package:flutter/src/widgets/framework.dart:2950:14)
I/flutter (10119): #239    Element.updateChild (package:flutter/src/widgets/framework.dart:2753:12)
I/flutter (10119): #240    ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3732:16)
I/flutter (10119): #241    Element.rebuild (package:flutter/src/widgets/framework.dart:3547:5)
I/flutter (10119): #242    ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:3701:5)
I/flutter (10119): #243    ComponentElement.mount (package:flutter/src/widgets/framework.dart:3696:5)
I/flutter (10119): #244    Element.inflateWidget (package:flutter/src/widgets/framework.dart:2950:14)
I/flutter (10119): #245    Element.updateChild (package:flutter/src/widgets/framework.dart:2753:12)
I/flutter (10119): #246    RenderObjectToWidgetElement._rebuild (package:flutter/src/widgets/binding.dart:909:16)
I/flutter (10119): #247    RenderObjectToWidgetElement.mount (package:flutter/src/widgets/binding.dart:880:5)
I/flutter (10119): #248    RenderObjectToWidgetAdapter.attachToRenderTree.<anonymous closure> (package:flutter/src/widgets/binding.dart:826:17)
I/flutter (10119): #249    BuildOwner.buildScope (package:flutter/src/widgets/framework.dart:2266:19)
I/flutter (10119): #250    RenderObjectToWidgetAdapter.attachToRenderTree (package:flutter/src/widgets/binding.dart:825:13)
I/flutter (10119): #251    _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding&PaintingBinding&SemanticsBinding&RendererBinding&WidgetsBinding.attachRootWidget (package:flutter/src/widgets/binding.dart:712:7)
I/flutter (10119): #252    runApp (package:flutter/src/widgets/binding.dart:756:7)
I/flutter (10119): #253    main (package:json/main.dart:8:16)
I/flutter (10119): #254    _startIsolate.<anonymous closure> (dart:isolate/runtime/libisolate_patch.dart:289:19)
I/flutter (10119): #255    _RawReceivePortImpl._handleMessage (dart:isolate/runtime/libisolate_patch.dart:171:12)
I/flutter (10119): ════════════════════════════════════════════════════════════════════════════════════════════════════
I/flutter (10119): [{_id: 5c55e837b1dee7326c4ba39d, create_date: 2019-02-02T18:57:59.406Z, name: Tariq, gender: male, email: ta@gmail.com, phone: 07954622145, __v: 0}, {_id: 5c55e86cb1dee7326c4ba39e, create_date: 2019-02-02T18:58:52.346Z, name: He, gender: Female, email: h@gmail.com, phone: 075554622145, __v: 0}, {_id: 5c55e890b1dee7326c4ba39f, create_date: 2019-02-02T18:59:28.108Z, name: Sh, gender: Female, email: sh@gmail.com, phone: 075654622145, __v: 0}, {_id: 5c584f60af32d00dec0facae, create_date: 2019-02-04T14:42:40.036Z, name: Emad, gender: male, email: emad@gmail.com, __v: 0}, {_id: 5c585236af32d00dec0facaf, create_date: 2019-02-04T14:54:46.734Z, name: Fa, gender: Female, email: Fa@gmail.com, phone: 075654622145, __v: 0}, {_id: 5c58605bcf4f4c3008e50a04, create_date: 2019-02-04T15:55:07.696Z, name: Fa, gender: Female, email: f @gmail.com, phone: 075654622145, __v: 0}]
```

when i run the code i got the data in the console, but the UI for mobile APP . i get the error
output

答:
Answer by ABHIMANGAL MS was perfect for me.
We made a list data at the top of our page like:

```<code>list data;
</code>```

This was null obv. We then ran json under it to get our data from an api and populate data with that info.
However the page would first load data while empty then make the api call.

Making data: list data = []; removed the error it would throw up for a second before loading the json data. so thank you !!!

Title: The getter 'length' was called on null

Body:
I trying to retrieve my data from API server and present it in my mobile application using flutter .. but i got error

The getter 'length' was called on null

Any advice plz ... thanks

my code is

import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'dart:core';
import 'dart:convert';
import 'package:http/http.dart' as http;
import 'package:json/add.dart';

void main() => runApp(MyApp());

Future<List> getData() async {
  String url = 'http://192.168.0.55:4000/api/contacts';
  http.Response response = await http.get(url);
  return json.decode(response.body);
}

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    SystemChrome.setPreferredOrientations([DeviceOrientation.portraitUp]);
    return MaterialApp(
      routes: <String, WidgetBuilder>{
        '/Add': (BuildContext context) => new Add(),
      },
      home: HomePage(),
    );
  }
}

class HomePage extends StatefulWidget {
  @override
  HomePageState createState() {
    return new HomePageState();
  }
}

class HomePageState extends State<HomePage> {
  List data;

  void getList() async {
    this.data = (await getData());
    print(data);
  }

  @override
  void initState() {
    getList();
  }

  Widget build(BuildContext context) {
    return new Scaffold(
      appBar: AppBar(
        centerTitle: true,
        title: new Text("Chat"),
      ),
      body: new Center(
        child: new ListView.builder(
            itemCount: data.length,
            itemBuilder: (BuildContext context, int position) {
              return new ListTile(
                title: new Text('${data[position]['name']}'),
              );
            }),
      ),
      floatingActionButton: FloatingActionButton(
          child: Icon(Icons.person_add),
          onPressed: () {
            Navigator.of(context).pushNamed('/Add');
          }),
    );
  }
}

Output Console

Performing hot restart...
Syncing files to device Android SDK built for x86...
Restarted application in 4,410ms.
I/flutter (10119): ══╡ EXCEPTION CAUGHT BY WIDGETS LIBRARY ╞═══════════════════════════════════════════════════════════
I/flutter (10119): The following NoSuchMethodError was thrown building HomePage(dirty, state: HomePageState#80635):
I/flutter (10119): The getter 'length' was called on null.
I/flutter (10119): Receiver: null
I/flutter (10119): Tried calling: length
I/flutter (10119):
I/flutter (10119): When the exception was thrown, this was the stack:
I/flutter (10119): #0      Object.noSuchMethod (dart:core/runtime/libobject_patch.dart:50:5)
I/flutter (10119): #1      HomePageState.build (package:json/main.dart:59:29)
I/flutter (10119): #2      StatefulElement.build (package:flutter/src/widgets/framework.dart:3809:27)
I/flutter (10119): #3      ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3721:15)
I/flutter (10119): #4      Element.rebuild (package:flutter/src/widgets/framework.dart:3547:5)
I/flutter (10119): #5      ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:3701:5)
I/flutter (10119): #6      StatefulElement._firstBuild (package:flutter/src/widgets/framework.dart:3848:11)
I/flutter (10119): #7      ComponentElement.mount (package:flutter/src/widgets/framework.dart:3696:5)
I/flutter (10119): #8      Element.inflateWidget (package:flutter/src/widgets/framework.dart:2950:14)
I/flutter (10119): #9      Element.updateChild (package:flutter/src/widgets/framework.dart:2753:12)
I/flutter (10119): #10     SingleChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:4860:14)
I/flutter (10119): #11     Element.inflateWidget (package:flutter/src/widgets/framework.dart:2950:14)
I/flutter (10119): #12     Element.updateChild (package:flutter/src/widgets/framework.dart:2753:12)
I/flutter (10119): #13     ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3732:16)
I/flutter (10119): #14     Element.rebuild (package:flutter/src/widgets/framework.dart:3547:5)
I/flutter (10119): #15     ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:3701:5)
I/flutter (10119): #16     ComponentElement.mount (package:flutter/src/widgets/framework.dart:3696:5)
I/flutter (10119): #17     Element.inflateWidget (package:flutter/src/widgets/framework.dart:2950:14)
I/flutter (10119): #18     Element.updateChild (package:flutter/src/widgets/framework.dart:2753:12)
I/flutter (10119): #19     SingleChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:4860:14)
I/flutter (10119): #20     Element.inflateWidget (package:flutter/src/widgets/framework.dart:2950:14)
I/flutter (10119): #21     Element.updateChild (package:flutter/src/widgets/framework.dart:2753:12)
I/flutter (10119): #22     SingleChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:4860:14)
I/flutter (10119): #23     Element.inflateWidget (package:flutter/src/widgets/framework.dart:2950:14)
I/flutter (10119): #24     Element.updateChild (package:flutter/src/widgets/framework.dart:2753:12)
I/flutter (10119): #25     SingleChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:4860:14)
I/flutter (10119): #26     Element.inflateWidget (package:flutter/src/widgets/framework.dart:2950:14)
I/flutter (10119): #27     Element.updateChild (package:flutter/src/widgets/framework.dart:2753:12)
I/flutter (10119): #28     SingleChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:4860:14)
I/flutter (10119): #29     Element.inflateWidget (package:flutter/src/widgets/framework.dart:2950:14)
I/flutter (10119): #30     Element.updateChild (package:flutter/src/widgets/framework.dart:2753:12)
I/flutter (10119): #31     ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3732:16)
I/flutter (10119): #32     Element.rebuild (package:flutter/src/widgets/framework.dart:3547:5)
I/flutter (10119): #33     ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:3701:5)
I/flutter (10119): #34     StatefulElement._firstBuild (package:flutter/src/widgets/framework.dart:3848:11)
I/flutter (10119): #35     ComponentElement.mount (package:flutter/src/widgets/framework.dart:3696:5)
I/flutter (10119): #36     Element.inflateWidget (package:flutter/src/widgets/framework.dart:2950:14)
I/flutter (10119): #37     Element.updateChild (package:flutter/src/widgets/framework.dart:2753:12)
I/flutter (10119): #38     ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3732:16)
I/flutter (10119): #39     Element.rebuild (package:flutter/src/widgets/framework.dart:3547:5)
I/flutter (10119): #40     ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:3701:5)
I/flutter (10119): #41     ComponentElement.mount (package:flutter/src/widgets/framework.dart:3696:5)
I/flutter (10119): #42     Element.inflateWidget (package:flutter/src/widgets/framework.dart:2950:14)
I/flutter (10119): #43     Element.updateChild (package:flutter/src/widgets/framework.dart:2753:12)
I/flutter (10119): #44     ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3732:16)
I/flutter (10119): #45     Element.rebuild (package:flutter/src/widgets/framework.dart:3547:5)
I/flutter (10119): #46     ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:3701:5)
I/flutter (10119): #47     StatefulElement._firstBuild (package:flutter/src/widgets/framework.dart:3848:11)
I/flutter (10119): #48     ComponentElement.mount (package:flutter/src/widgets/framework.dart:3696:5)
I/flutter (10119): #49     Element.inflateWidget (package:flutter/src/widgets/framework.dart:2950:14)
I/flutter (10119): #50     Element.updateChild (package:flutter/src/widgets/framework.dart:2753:12)
I/flutter (10119): #51     SingleChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:4860:14)
I/flutter (10119): #52     Element.inflateWidget (package:flutter/src/widgets/framework.dart:2950:14)
I/flutter (10119): #53     Element.updateChild (package:flutter/src/widgets/framework.dart:2753:12)
I/flutter (10119): #54     ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3732:16)
I/flutter (10119): #55     Element.rebuild (package:flutter/src/widgets/framework.dart:3547:5)
I/flutter (10119): #56     ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:3701:5)
I/flutter (10119): #57     ComponentElement.mount (package:flutter/src/widgets/framework.dart:3696:5)
I/flutter (10119): #58     Element.inflateWidget (package:flutter/src/widgets/framework.dart:2950:14)
I/flutter (10119): #59     Element.updateChild (package:flutter/src/widgets/framework.dart:2753:12)
I/flutter (10119): #60     SingleChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:4860:14)
I/flutter (10119): #61     Element.inflateWidget (package:flutter/src/widgets/framework.dart:2950:14)
I/flutter (10119): #62     Element.updateChild (package:flutter/src/widgets/framework.dart:2753:12)
I/flutter (10119): #63     ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3732:16)
I/flutter (10119): #64     Element.rebuild (package:flutter/src/widgets/framework.dart:3547:5)
I/flutter (10119): #65     ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:3701:5)
I/flutter (10119): #66     StatefulElement._firstBuild (package:flutter/src/widgets/framework.dart:3848:11)
I/flutter (10119): #67     ComponentElement.mount (package:flutter/src/widgets/framework.dart:3696:5)
I/flutter (10119): #68     Element.inflateWidget (package:flutter/src/widgets/framework.dart:2950:14)
I/flutter (10119): #69     Element.updateChild (package:flutter/src/widgets/framework.dart:2753:12)
I/flutter (10119): #70     ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3732:16)
I/flutter (10119): #71     Element.rebuild (package:flutter/src/widgets/framework.dart:3547:5)
I/flutter (10119): #72     ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:3701:5)
I/flutter (10119): #73     ComponentElement.mount (package:flutter/src/widgets/framework.dart:3696:5)
I/flutter (10119): #74     Element.inflateWidget (package:flutter/src/widgets/framework.dart:2950:14)
I/flutter (10119): #75     Element.updateChild (package:flutter/src/widgets/framework.dart:2753:12)
I/flutter (10119): #76     SingleChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:4860:14)
I/flutter (10119): #77     Element.inflateWidget (package:flutter/src/widgets/framework.dart:2950:14)
I/flutter (10119): #78     Element.updateChild (package:flutter/src/widgets/framework.dart:2753:12)
I/flutter (10119): #79     ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3732:16)
I/flutter (10119): #80     Element.rebuild (package:flutter/src/widgets/framework.dart:3547:5)
I/flutter (10119): #81     ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:3701:5)
I/flutter (10119): #82     ComponentElement.mount (package:flutter/src/widgets/framework.dart:3696:5)
I/flutter (10119): #83     Element.inflateWidget (package:flutter/src/widgets/framework.dart:2950:14)
I/flutter (10119): #84     Element.updateChild (package:flutter/src/widgets/framework.dart:2753:12)
I/flutter (10119): #85     ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3732:16)
I/flutter (10119): #86     Element.rebuild (package:flutter/src/widgets/framework.dart:3547:5)
I/flutter (10119): #87     ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:3701:5)
I/flutter (10119): #88     StatefulElement._firstBuild (package:flutter/src/widgets/framework.dart:3848:11)
I/flutter (10119): #89     ComponentElement.mount (package:flutter/src/widgets/framework.dart:3696:5)
I/flutter (10119): #90     Element.inflateWidget (package:flutter/src/widgets/framework.dart:2950:14)
I/flutter (10119): #91     Element.updateChild (package:flutter/src/widgets/framework.dart:2753:12)
I/flutter (10119): #92     ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3732:16)
I/flutter (10119): #93     Element.rebuild (package:flutter/src/widgets/framework.dart:3547:5)
I/flutter (10119): #94     ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:3701:5)
I/flutter (10119): #95     StatefulElement._firstBuild (package:flutter/src/widgets/framework.dart:3848:11)
I/flutter (10119): #96     ComponentElement.mount (package:flutter/src/widgets/framework.dart:3696:5)
I/flutter (10119): #97     Element.inflateWidget (package:flutter/src/widgets/framework.dart:2950:14)
I/flutter (10119): #98     MultiChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:4965:32)
I/flutter (10119): #99     Element.inflateWidget (package:flutter/src/widgets/framework.dart:2950:14)
I/flutter (10119): #100    Element.updateChild (package:flutter/src/widgets/framework.dart:2753:12)
I/flutter (10119): #101    _TheatreElement.mount (package:flutter/src/widgets/overlay.dart:493:16)
I/flutter (10119): #102    Element.inflateWidget (package:flutter/src/widgets/framework.dart:2950:14)
I/flutter (10119): #103    Element.updateChild (package:flutter/src/widgets/framework.dart:2753:12)
I/flutter (10119): #104    ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3732:16)
I/flutter (10119): #105    Element.rebuild (package:flutter/src/widgets/framework.dart:3547:5)
I/flutter (10119): #106    ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:3701:5)
I/flutter (10119): #107    StatefulElement._firstBuild (package:flutter/src/widgets/framework.dart:3848:11)
I/flutter (10119): #108    ComponentElement.mount (package:flutter/src/widgets/framework.dart:3696:5)
I/flutter (10119): #109    Element.inflateWidget (package:flutter/src/widgets/framework.dart:2950:14)
I/flutter (10119): #110    Element.updateChild (package:flutter/src/widgets/framework.dart:2753:12)
I/flutter (10119): #111    ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3732:16)
I/flutter (10119): #112    Element.rebuild (package:flutter/src/widgets/framework.dart:3547:5)
I/flutter (10119): #113    ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:3701:5)
I/flutter (10119): #114    ComponentElement.mount (package:flutter/src/widgets/framework.dart:3696:5)
I/flutter (10119): #115    Element.inflateWidget (package:flutter/src/widgets/framework.dart:2950:14)
I/flutter (10119): #116    Element.updateChild (package:flutter/src/widgets/framework.dart:2753:12)
I/flutter (10119): #117    SingleChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:4860:14)
I/flutter (10119): #118    Element.inflateWidget (package:flutter/src/widgets/framework.dart:2950:14)
I/flutter (10119): #119    Element.updateChild (package:flutter/src/widgets/framework.dart:2753:12)
I/flutter (10119): #120    ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3732:16)
I/flutter (10119): #121    Element.rebuild (package:flutter/src/widgets/framework.dart:3547:5)
I/flutter (10119): #122    ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:3701:5)
I/flutter (10119): #123    StatefulElement._firstBuild (package:flutter/src/widgets/framework.dart:3848:11)
I/flutter (10119): #124    ComponentElement.mount (package:flutter/src/widgets/framework.dart:3696:5)
I/flutter (10119): #125    Element.inflateWidget (package:flutter/src/widgets/framework.dart:2950:14)
I/flutter (10119): #126    Element.updateChild (package:flutter/src/widgets/framework.dart:2753:12)
I/flutter (10119): #127    SingleChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:4860:14)
I/flutter (10119): #128    Element.inflateWidget (package:flutter/src/widgets/framework.dart:3547:5)
I/flutter (10119): #163    ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:3701:5)
I/flutter (10119): #164    ComponentElement.mount (package:flutter/src/widgets/framework.dart:3696:5)
I/flutter (10119): #165    Element.inflateWidget (package:flutter/src/widgets/framework.dart:2950:14)
I/flutter (10119): #166    Element.updateChild (package:flutter/src/widgets/framework.dart:2753:12)
I/flutter (10119): #167    ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3732:16)
I/flutter (10119): #168    Element.rebuild (package:flutter/src/widgets/framework.dart:3547:5)
I/flutter (10119): #169    ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:3701:5)
I/flutter (10119): #170    ComponentElement.mount (package:flutter/src/widgets/framework.dart:3696:5)
I/flutter (10119): #171    Element.inflateWidget (package:flutter/src/widgets/framework.dart:2950:14)
I/flutter (10119): #172    Element.updateChild (package:flutter/src/widgets/framework.dart:2753:12)
I/flutter (10119): #173    ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3732:16)
I/flutter (10119): #174    Element.rebuild (package:flutter/src/widgets/framework.dart:3547:5)
I/flutter (10119): #175    ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:3701:5)
I/flutter (10119): #176    ComponentElement.mount (package:flutter/src/widgets/framework.dart:3696:5)
I/flutter (10119): #177    Element.inflateWidget (package:flutter/src/widgets/framework.dart:2950:14)
I/flutter (10119): #178    Element.updateChild (package:flutter/src/widgets/framework.dart:2753:12)
I/flutter (10119): #179    SingleChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:4860:14)
I/flutter (10119): #180    Element.inflateWidget (package:flutter/src/widgets/framework.dart:2950:14)
I/flutter (10119): #181    Element.updateChild (package:flutter/src/widgets/framework.dart:2753:12)
I/flutter (10119): #182    ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3732:16)
I/flutter (10119): #183    Element.rebuild (package:flutter/src/widgets/framework.dart:3547:5)
I/flutter (10119): #184    ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:3701:5)
I/flutter (10119): #185    StatefulElement._firstBuild (package:flutter/src/widgets/framework.dart:3848:11)
I/flutter (10119): #186    ComponentElement.mount (package:flutter/src/widgets/framework.dart:3696:5)
I/flutter (10119): #187    Element.inflateWidget (package:flutter/src/widgets/framework.dart:2753:12)
I/flutter (10119): #202    ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3732:16)
I/flutter (10119): #203    Element.rebuild (package:flutter/src/widgets/framework.dart:3547:5)
I/flutter (10119): #204    ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:3701:5)
I/flutter (10119): #205    ComponentElement.mount (package:flutter/src/widgets/framework.dart:3696:5)
I/flutter (10119): #206    Element.inflateWidget (package:flutter/src/widgets/framework.dart:2950:14)
I/flutter (10119): #207    Element.updateChild (package:flutter/src/widgets/framework.dart:2753:12)
I/flutter (10119): #208    ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3732:16)
I/flutter (10119): #209    Element.rebuild (package:flutter/src/widgets/framework.dart:3547:5)
I/flutter (10119): #210    ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:3701:5)
I/flutter (10119): #211    ComponentElement.mount (package:flutter/src/widgets/framework.dart:3696:5)
I/flutter (10119): #212    Element.inflateWidget (package:flutter/src/widgets/framework.dart:2950:14)
I/flutter (10119): #213    Element.updateChild (package:flutter/src/widgets/framework.dart:2753:12)
I/flutter (10119): #214    ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3732:16)
I/flutter (10119): #215    Element.rebuild (package:flutter/src/widgets/framework.dart:3547:5)
I/flutter (10119): #216    ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:3701:5)
I/flutter (10119): #217    ComponentElement.mount (package:flutter/src/widgets/framework.dart:3696:5)
I/flutter (10119): #218    Element.inflateWidget (package:flutter/src/widgets/framework.dart:2950:14)
I/flutter (10119): #219    Element.updateChild (package:flutter/src/widgets/framework.dart:2753:12)
I/flutter (10119): #220    ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3732:16)
I/flutter (10119): #221    Element.rebuild (package:flutter/src/widgets/framework.dart:3547:5)
I/flutter (10119): #222    ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:3701:5)
I/flutter (10119): #223    StatefulElement._firstBuild (package:flutter/src/widgets/framework.dart:3848:11)
I/flutter (10119): #224    ComponentElement.mount (package:flutter/src/widgets/framework.dart:3696:5)
I/flutter (10119): #225    Element.inflateWidget (package:flutter/src/widgets/framework.dart:2950:14)
I/flutter (10119): #226    Element.updateChild (package:flutter/src/widgets/framework.dart:2753:12)
I/flutter (10119): #227    ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3732:16)
I/flutter (10119): #228    Element.rebuild (package:flutter/src/widgets/framework.dart:3547:5)
I/flutter (10119): #229    ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:3701:5)
I/flutter (10119): #230    ComponentElement.mount (package:flutter/src/widgets/framework.dart:3696:5)
I/flutter (10119): #231    Element.inflateWidget (package:flutter/src/widgets/framework.dart:2950:14)
I/flutter (10119): #232    Element.updateChild (package:flutter/src/widgets/framework.dart:2753:12)
I/flutter (10119): #233    ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3732:16)
I/flutter (10119): #234    Element.rebuild (package:flutter/src/widgets/framework.dart:3547:5)
I/flutter (10119): #235    ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:3701:5)
I/flutter (10119): #236    StatefulElement._firstBuild (package:flutter/src/widgets/framework.dart:3848:11)
I/flutter (10119): #237    ComponentElement.mount (package:flutter/src/widgets/framework.dart:3696:5)
I/flutter (10119): #238    Element.inflateWidget (package:flutter/src/widgets/framework.dart:2950:14)
I/flutter (10119): #239    Element.updateChild (package:flutter/src/widgets/framework.dart:2753:12)
I/flutter (10119): #240    ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3732:16)
I/flutter (10119): #241    Element.rebuild (package:flutter/src/widgets/framework.dart:3547:5)
I/flutter (10119): #242    ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:3701:5)
I/flutter (10119): #243    ComponentElement.mount (package:flutter/src/widgets/framework.dart:3696:5)
I/flutter (10119): #244    Element.inflateWidget (package:flutter/src/widgets/framework.dart:2950:14)
I/flutter (10119): #245    Element.updateChild (package:flutter/src/widgets/framework.dart:2753:12)
I/flutter (10119): #246    RenderObjectToWidgetElement._rebuild (package:flutter/src/widgets/binding.dart:909:16)
I/flutter (10119): #247    RenderObjectToWidgetElement.mount (package:flutter/src/widgets/binding.dart:880:5)
I/flutter (10119): #248    RenderObjectToWidgetAdapter.attachToRenderTree.<anonymous closure> (package:flutter/src/widgets/binding.dart:826:17)
I/flutter (10119): #249    BuildOwner.buildScope (package:flutter/src/widgets/framework.dart:2266:19)
I/flutter (10119): #250    RenderObjectToWidgetAdapter.attachToRenderTree (package:flutter/src/widgets/binding.dart:825:13)
I/flutter (10119): #251    _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding&PaintingBinding&SemanticsBinding&RendererBinding&WidgetsBinding.attachRootWidget (package:flutter/src/widgets/binding.dart:712:7)
I/flutter (10119): #252    runApp (package:flutter/src/widgets/binding.dart:756:7)
I/flutter (10119): #253    main (package:json/main.dart:8:16)
I/flutter (10119): #254    _startIsolate.<anonymous closure> (dart:isolate/runtime/libisolate_patch.dart:289:19)
I/flutter (10119): #255    _RawReceivePortImpl._handleMessage (dart:isolate/runtime/libisolate_patch.dart:171:12)
I/flutter (10119): ════════════════════════════════════════════════════════════════════════════════════════════════════
I/flutter (10119): [{_id: 5c55e837b1dee7326c4ba39d, create_date: 2019-02-02T18:57:59.406Z, name: Tariq, gender: male, email: ta@gmail.com, phone: 07954622145, __v: 0}, {_id: 5c55e86cb1dee7326c4ba39e, create_date: 2019-02-02T18:58:52.346Z, name: He, gender: Female, email: h@gmail.com, phone: 075554622145, __v: 0}, {_id: 5c55e890b1dee7326c4ba39f, create_date: 2019-02-02T18:59:28.108Z, name: Sh, gender: Female, email: sh@gmail.com, phone: 075654622145, __v: 0}, {_id: 5c584f60af32d00dec0facae, create_date: 2019-02-04T14:42:40.036Z, name: Emad, gender: male, email: emad@gmail.com, __v: 0}, {_id: 5c585236af32d00dec0facaf, create_date: 2019-02-04T14:54:46.734Z, name: Fa, gender: Female, email: Fa@gmail.com, phone: 075654622145, __v: 0}, {_id: 5c58605bcf4f4c3008e50a04, create_date: 2019-02-04T15:55:07.696Z, name: Fa, gender: Female, email: f @gmail.com, phone: 075654622145, __v: 0}]

when i run the code i got the data in the console, but the UI for mobile APP . i get the error
output

Body:
Answer by ABHIMANGAL MS was perfect for me.
We made a list data at the top of our page like:

list data;

This was null obv. We then ran json under it to get our data from an api and populate data with that info.
However the page would first load data while empty then make the api call.

Making data: list data = []; removed the error it would throw up for a second before loading the json data. so thank you !!!


问:
Random Iteration order from Set.of(...)
Hi I am learning the new features of Java 9  and was reading new Collections API's . I am not sure why I am getting random iteration order while creating an immutable set from two instances of JDK .

```<code>JDK 1: jshell> Set.of("a","b","c")
       $96 ==> [a, b, c]

JDK2 : jshell> Set.of("a","b","c")
       $68 ==> [a, c, b]
</code>```

I don't see the same for List.of() overloads.Can I do some customisation like changing some system properties to guarantee a consistent ordering here ?

答:
As Eran already explained, the iteration order of a Set is not specified.

To avoid that other programs rely on the iteration order, the JVM will create a salt at startup and use that to randomize the iteration order of their internal Set and Map implementations:

```<code>/**
 * A "salt" value used for randomizing iteration order. This is initialized once
 * and stays constant for the lifetime of the JVM. It need not be truly random, but
 * it needs to vary sufficiently from one run to the next so that iteration order
 * will vary between JVM runs.
 */
private static final long SALT32L;
</code>```

Source

In short: They did additional work to make the iteration order "random", so things will break if people start to rely on the order.

And some programs do rely on the iteration order of HashSet for example - which makes it hard to improve HashSet now without breaking programs that rely on the order.

Title: Random Iteration order from Set.of(...)

Body:
Hi I am learning the new features of Java 9  and was reading new Collections API's . I am not sure why I am getting random iteration order while creating an immutable set from two instances of JDK .

JDK 1: jshell> Set.of("a","b","c")
       $96 ==> [a, b, c]

JDK2 : jshell> Set.of("a","b","c")
       $68 ==> [a, c, b]

I don't see the same for List.of() overloads.Can I do some customisation like changing some system properties to guarantee a consistent ordering here ?

Body:
As Eran already explained, the iteration order of a Set is not specified.

To avoid that other programs rely on the iteration order, the JVM will create a salt at startup and use that to randomize the iteration order of their internal Set and Map implementations:

/**
 * A "salt" value used for randomizing iteration order. This is initialized once
 * and stays constant for the lifetime of the JVM. It need not be truly random, but
 * it needs to vary sufficiently from one run to the next so that iteration order
 * will vary between JVM runs.
 */
private static final long SALT32L;

Source

In short: They did additional work to make the iteration order "random", so things will break if people start to rely on the order.

And some programs do rely on the iteration order of HashSet for example - which makes it hard to improve HashSet now without breaking programs that rely on the order.


问:
Java - Adding items from arraylist to JTable when button clicked
I was trying to write the GUI for my program. I have a Product class in which I store price and names of the products in an arraylist. I also have an Order arraylist which consists of the orders given to each waiter.I put all my products in a JComboBox and added an action listener to each to show the price of each product when clicked by updating the text of a JLable. Then there is a JSpinner to get the quantity of the products selected. And lastly there is an "Add" button that I wanted to use to update the Jtable with product name and its quantity and its total price while also adding that product to the arraylist of Orders. I have no idea how populate JTable and couldn't understand much from other answers because they were using netbeans. I thought of just using a simple JLabe but also I couldn't understand how to update the text and add a new line to the label after I select and add each product. Can you explain how I can achieve this? part of my code looks like this</p>
```<code>box1.addActionListener(new ActionListener() {

    @Override
    public void actionPerformed(ActionEvent e) {
        Product prod = (Product) box1.getSelectedItem();
        price.setText(String.valueOf(prod.getSellingPrice()));

        add.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                int numbs = (Integer) spinner.getValue();
                for (int i = 0; i <= numbs; i++) {
                    order.addProduct(prod);
                }
                JLabel label = new JLabel();
                lists.add(label);
                label.setText(prod.getName() + " " + numbs + " " + numbs * prod.getSellingPrice());
            }
        });
    }
});
</code>```

答:
If I understand your question correctly, you want a JTable in your gui, which shows the orders (or other data possibly) if a button is clicked.

Firstable, I would advise you to check out

https://docs.oracle.com/javase/tutorial/uiswing/components/table.html

as they explain the use of the JTable very well.

Anyway, to answer your question:

Firstable, you have to create a table and add it to your gui:

```<code>//creating a new JTable without any data and one column 'Orders'
//you might wanna declare the JTable before that, since it will be referred to in the refresh() method
JTable table = new JTable(new String[][]{{""}}, new String[]{"Orders"});
//creating a scrollpane to put the table in, in case the table data exeeds the table
JScrollPane scrollPane = new JScrollPane();
//here you would e.g. set the bounds of the scrollpane etc
scrollPane.setBounds(x,y,w,h)
//setting the table in the scrollpane
scrollPane.setViewportView(table);
//adding the scrollpane to your contentPane
contentPane.add(scrollPane);
</code>```

Now you want to refresh the table, if a button is pressed, so I would put a reference to the following method in the actionlistener of the button:

```<code>//the method to refresh the table containing the orders (or possibly other data)
void refresh(List<String> orders) {
    //creating a new TableModel for the table
    DefaultTableModel model = new DefaultTableModel();
    //set the data in the model to the data that was given, new Object[]{0} points to the 1st column
    model.setDataVector(getDataVector(data), new Object[]{"Orders});
    //set the model of the table to the model we just created
    table.setModel(model);
}
</code>```

Since model.setDataVecor() takes rows and not columns as its first parameter, you have to make the list of data fitting as a data vector, for example with the following method:

```<code>Object[][] getDataVector(List<String> data){
    Object[][] vector = new Object[data.size()][1];
    for(int i=0; i<data.size(); i++){
        vector[i][0] = data.get(i);
    }
    return vector;
 }
</code>```

Body:
I was trying to write the GUI for my program. I have a Product class in which I store price and names of the products in an arraylist. I also have an Order arraylist which consists of the orders given to each waiter.I put all my products in a JComboBox and added an action listener to each to show the price of each product when clicked by updating the text of a JLable. Then there is a JSpinner to get the quantity of the products selected. And lastly there is an "Add" button that I wanted to use to update the Jtable with product name and its quantity and its total price while also adding that product to the arraylist of Orders. I have no idea how populate JTable and couldn't understand much from other answers because they were using netbeans. I thought of just using a simple JLabe but also I couldn't understand how to update the text and add a new line to the label after I select and add each product. Can you explain how I can achieve this? part of my code looks like this

box1.addActionListener(new ActionListener() {

    @Override
    public void actionPerformed(ActionEvent e) {
        Product prod = (Product) box1.getSelectedItem();
        price.setText(String.valueOf(prod.getSellingPrice()));

        add.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                int numbs = (Integer) spinner.getValue();
                for (int i = 0; i <= numbs; i++) {
                    order.addProduct(prod);
                }
                JLabel label = new JLabel();
                lists.add(label);
                label.setText(prod.getName() + " " + numbs + " " + numbs * prod.getSellingPrice());
            }
        });
    }
});

Body:
If I understand your question correctly, you want a JTable in your gui, which shows the orders (or other data possibly) if a button is clicked.

Firstable, I would advise you to check out

https://docs.oracle.com/javase/tutorial/uiswing/components/table.html

as they explain the use of the JTable very well.

Anyway, to answer your question:

Firstable, you have to create a table and add it to your gui:

//creating a new JTable without any data and one column 'Orders'
//you might wanna declare the JTable before that, since it will be referred to in the refresh() method
JTable table = new JTable(new String[][]{{""}}, new String[]{"Orders"});
//creating a scrollpane to put the table in, in case the table data exeeds the table
JScrollPane scrollPane = new JScrollPane();
//here you would e.g. set the bounds of the scrollpane etc
scrollPane.setBounds(x,y,w,h)
//setting the table in the scrollpane
scrollPane.setViewportView(table);
//adding the scrollpane to your contentPane
contentPane.add(scrollPane);

Now you want to refresh the table, if a button is pressed, so I would put a reference to the following method in the actionlistener of the button:

//the method to refresh the table containing the orders (or possibly other data)
void refresh(List<String> orders) {
    //creating a new TableModel for the table
    DefaultTableModel model = new DefaultTableModel();
    //set the data in the model to the data that was given, new Object[]{0} points to the 1st column
    model.setDataVector(getDataVector(data), new Object[]{"Orders});
    //set the model of the table to the model we just created
    table.setModel(model);
}

Since model.setDataVecor() takes rows and not columns as its first parameter, you have to make the list of data fitting as a data vector, for example with the following method:

Object[][] getDataVector(List<String> data){
    Object[][] vector = new Object[data.size()][1];
    for(int i=0; i<data.size(); i++){
        vector[i][0] = data.get(i);
    }
    return vector;
 }


问:
Prism EventAggregator. Receive the event and send it again
In my project I have three ViewModels (for example, ViewModelA, ViewModelB and ViewModelC).

I need to write the following logic.

The ViewModelA sends the value to ViewModelB using the EventAggregator from Prism.

The ViewModelB receives the value and sends it to ViewModelC.

The ViewModelC receives the value and doing something.

Here is the code:

```<code>// The data that will be send using the event aggregator.
class EventData : PubSubEvent<int>
{
}

class ViewModelA
{
    IEventAggregator m_eventAggregator;

    public ViewModelA(IEventAggregator eventAggregator)
    {
        m_eventAggregator = eventAggregator;

        // Publish some value.
        eventAggregator.GetEvent<EventData>().Publish(10);
    }
}

class ViewModelB
{
    IEventAggregator m_eventAggregator;

    public ViewModelB(IEventAggregator eventAggregator)
    {
        m_eventAggregator = eventAggregator;

        eventAggregator.GetEvent<EventData>().Subscribe(OnDataReceived);
    }

    void OnDataReceived(int value)
    {
        // Here I want to send the value to the ViewModelC. How can I do it?
    }
}
</code>```

PS: it is the part of the big project. So, please don’t suggest sending from ViewModelA to ViewModelC directly, without the ViewModelB.

答:
The event aggregator works in a way that everybody can listen to every event. So, if you want to send from A to B (and then from B to C), you need two distinct "private" events.

A:

```<code> eventAggregator.Publish<AtoB>( value );
</code>```

B:

```<code> eventAggregator.Subscribe<AtoB>( x => {
                                           var y = process(x);
                                           eventAggregator.Publish<BtoC>( y );
                                       } );
</code>```

C:

```<code> eventAggregator.Subscribe<BtoC>( x => whatever( x ) );
</code>```

Side-note: what you publish and subscribe is the event type, not the payload type. The naming of your event (EventData) is a bit awkward, because one will confuse it with the payload. A better name would be DataEvent... or, here, RawDataEvent and ProcessedDataEvent.

Side-note 2: obviously, the event aggregator is not intended for non-broadcast messages. You can force it (either using distinct event types or, for example, by including a destination-id in the payload), but I'd prefer a messaging system that's designed for point-to-point messages.

Body:
In my project I have three ViewModels (for example, ViewModelA, ViewModelB and ViewModelC).

I need to write the following logic.

The ViewModelA sends the value to ViewModelB using the EventAggregator from Prism.

The ViewModelB receives the value and sends it to ViewModelC.

The ViewModelC receives the value and doing something.

Here is the code:

// The data that will be send using the event aggregator.
class EventData : PubSubEvent<int>
{
}

class ViewModelA
{
    IEventAggregator m_eventAggregator;

    public ViewModelA(IEventAggregator eventAggregator)
    {
        m_eventAggregator = eventAggregator;

        // Publish some value.
        eventAggregator.GetEvent<EventData>().Publish(10);
    }
}

class ViewModelB
{
    IEventAggregator m_eventAggregator;

    public ViewModelB(IEventAggregator eventAggregator)
    {
        m_eventAggregator = eventAggregator;

        eventAggregator.GetEvent<EventData>().Subscribe(OnDataReceived);
    }

    void OnDataReceived(int value)
    {
        // Here I want to send the value to the ViewModelC. How can I do it?
    }
}

PS: it is the part of the big project. So, please don’t suggest sending from ViewModelA to ViewModelC directly, without the ViewModelB.

Body:
The event aggregator works in a way that everybody can listen to every event. So, if you want to send from A to B (and then from B to C), you need two distinct "private" events.

A:

 eventAggregator.Publish<AtoB>( value );

B:

 eventAggregator.Subscribe<AtoB>( x => {
                                           var y = process(x);
                                           eventAggregator.Publish<BtoC>( y );
                                       } );

C:

 eventAggregator.Subscribe<BtoC>( x => whatever( x ) );

Side-note: what you publish and subscribe is the event type, not the payload type. The naming of your event (EventData) is a bit awkward, because one will confuse it with the payload. A better name would be DataEvent... or, here, RawDataEvent and ProcessedDataEvent.

Side-note 2: obviously, the event aggregator is not intended for non-broadcast messages. You can force it (either using distinct event types or, for example, by including a destination-id in the payload), but I'd prefer a messaging system that's designed for point-to-point messages.


问:
Pandas and HDF5
I have an .hdf5 file that contains multiple datasets (signal,filtered_signal,metadata). Each dataset was created by using a Pandas dataframes.

```<code>store = pd.HDFStore(event_file_path, mode="w")
store.put("signal", signal_df)
store.put("filtered_signal", filtered_signal_df)
store.put("metadata", pd.DataFrame(event_metadata_df, index=[0]))
store.close()
</code>```

This works perfectly. Now I want to add a column to the 'metadata' dataset.
This is what I was trying:

```<code>event_metadata_df = pd.read_hdf(event_file_path, key='metadata')
event_metadata_df['prediction'] = [prediction]
store = pd.HDFStore(event_file_path, mode="w")
store.put("metadata", pd.DataFrame(event_metadata_df, index=[0]))
store.close()
</code>```

This does indeed "update" the 'metadata' dataset, however, it drops the other two datasets from the file.

Is there a way to update a single dataset and keep the rest of the file intact?

答:
The second time you open the file you should use append-mode. From the docs: "an existing file is opened for reading and writing, and if the file does not exist it is created."

So open it like this the second time:

```<code>store = pd.HDFStore(event_file_path, mode="a")
</code>```

Title: Pandas and HDF5

Body:
I have an .hdf5 file that contains multiple datasets (signal,filtered_signal,metadata). Each dataset was created by using a Pandas dataframes.

store = pd.HDFStore(event_file_path, mode="w")
store.put("signal", signal_df)
store.put("filtered_signal", filtered_signal_df)
store.put("metadata", pd.DataFrame(event_metadata_df, index=[0]))
store.close()

This works perfectly. Now I want to add a column to the 'metadata' dataset.
This is what I was trying:

event_metadata_df = pd.read_hdf(event_file_path, key='metadata')
event_metadata_df['prediction'] = [prediction]
store = pd.HDFStore(event_file_path, mode="w")
store.put("metadata", pd.DataFrame(event_metadata_df, index=[0]))
store.close()

This does indeed "update" the 'metadata' dataset, however, it drops the other two datasets from the file.

Is there a way to update a single dataset and keep the rest of the file intact?

Body:
The second time you open the file you should use append-mode. From the docs: "an existing file is opened for reading and writing, and if the file does not exist it is created."

So open it like this the second time:

store = pd.HDFStore(event_file_path, mode="a")