Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

type 'Null' is not a subtype of type 'String' #13

Open
amkfat opened this issue Jan 24, 2022 · 1 comment
Open

type 'Null' is not a subtype of type 'String' #13

amkfat opened this issue Jan 24, 2022 · 1 comment

Comments

@amkfat
Copy link

amkfat commented Jan 24, 2022

i'm using a new version of flutter
i get this error: type 'Null' is not a subtype of type 'String'

at the 3rd this line of the code (plan_services.dart):

  Plan createPlan(String name) {
    final model = _repository.create();
    print('my name $name');                                           //the name in not null here
    final plan = Plan.fromModel(model)..name = name;            //error here
    savePlan(plan);
    return plan;
  }

after debugging, i got name=null here (plan.dart)

  Plan.fromModel(Model model)
      : id = model.id,
        name = model.data['name'],             //the name is null here
        tasks = model.data['task']
                ?.map<Task>((task) => Task.fromModel(task))
                ?.toList() ??
            <Task>[];

can you explain why? thank you

@rajat-packt
Copy link

Hey @amkfat can you please also provide the chapter and page number of the exercise you are following? We will try to reach out to author and provide you with an explanation and resolution for your queries.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants