rekabhq / background_locator

A Flutter plugin for updating location in background.
MIT License
288 stars 329 forks source link

Fix NPE by making bool parameter @required #179

Closed komape closed 3 years ago

komape commented 3 years ago

This PR fixes the issue described in #175.

Alternatively the parameter could get a default value assigned but I wasn't sure if true or false is better.

mehdok commented 3 years ago

@komape Thank you for your contribution;

komape commented 3 years ago

@mehdok But then you get the following warning:

The type parameter 'autoStop' is annotated with @required but only named parameters without a default value can be annotated with it.
Remove @required.dart(invalid_required_named_param)

What do you prefer?

@required autoStop,

or

autoStop = false,
komape commented 3 years ago

If the parameter is marked as @required, everyone who updates their background_locator will receive a warning if they don't set this parameter. In my opinion, this is enough.

mehdok commented 3 years ago

You are right, but this parameter is really an optional one, it should be false unless the user wants it to be true. so I think it's better to remove the @required and just provide a default value for it:

bool autoStop = false
komape commented 3 years ago

Done.