Flutter-> Error: The argument type 'Column' can't be assigned to the parameter type 'Widget?' - flutter

I just upgrade my flutter version few days ago. Now i got error in Column widget.
Here is my error.
And here is my pubspec.yaml
HELP ME TO SOLVE THIS.

This error is misleading, just simplify your column as suggested in the comments by stacktrace2234 to see what really is going on.
Did you update it from a non null safety to a null safety dart version?

Related

type 'Null' is not a subtype of type 'DataList' in type cast flutter

======== Exception caught by widgets library =======================================================
The following _CastError was thrown building ItemTags(dirty, dependencies: [DataListInherited], state: _ItemTagsState#a7193):
type 'Null' is not a subtype of type 'DataList' in type cast
The relevant error-causing widget was:
ItemTags ItemTags:file:///C:/Users/hp/AndroidStudioProjects/edufly/lib/pages/edit_product/components/edit_product_form.dart:172:22
Your code tries to assign a null to a variable or parameter that expects DataList. Since in such cases DataList or one of its subclass is mandatory, anything else will trigger a similar error. Since null (the unknown) is not a subclass of DataList, you get this error.
In order to solve this problem, you will need to find line 172 of :///C:/Users/hp/AndroidStudioProjects/edufly/lib/pages/edit_product/components/edit_product_form.dart and carefully review the possible reasons of this anomaly. Once you have understood why a null is being passed, you will be able to either logically fix the error, or handle the edge-case accordingly.
You are getting null objects in your DataList.
I got this when I was using the flutter_tags plug in (the null-safe v1 version).
I fixed it by replacing Tags and ItemTags with the Flutter built in ActionChip widget.
Other benefits besides it working and being built in is that the API is much simpler too.
I wrapped my ActionChip's in a Wrap widget.

How can solve the error in flutter_paystack?

Type mismatch: inferred type is Activity? but Activity was expected
Type mismatch: inferred type is BinaryMessenger? but BinaryMessenger was expected
I think this might be that the library is not yet optimized to support Flutter 3 which came out recently. Try to communicate with the devs on their github this error and they might be able to fix it
add this to your pubspec.yaml file, this will solve it for now.
flutter_paystack:
git:
url: https://github.com/definitelyme/flutter_paystack.git
ref: a4a33c3dd0a12f46d655a2e63d11e9f20ba82d01

What is << Type? variableName >> syntax in dart?

I found a syntax in a code Like this:
String? variableName;
I want to know what the use of the question mark here
The question mark allows the variable to be null or makes the variable nullable.
Dart Documentation
That syntax belongs to null-safety
Null-Safety Guide
It is the indicator that this variable might be null.
For more information, see the Dart documentation on null safety

Dart/Flutter linter rule: the type to index a map should be the key type of map?

For example, I have Map<int, int> m;. Then I can write down m['hello'] without any compile-time error, but of course, cannot find any element at runtime. I hope it will produce an error (or warning) at compile-time or lint time.
This is a big problem in many cases. For example, when I refactor Map<A, int> m into Map<B, int> m, I want to have compile-time errors for all accesses like m[some_var_of_type_A], instead of no compile-time errors and suddenly it explodes at runtime. As another example, the de-serialized JSON is of type Map<String, ...> but the key is actually a int. So it is tempting to do var userId=42; deserializedJson[userId] but only to find errors. Actually need to do deserializedJson[userId.toString()].
You know, dart's type system is so strong (even null safe!), and I really enjoy it since it catchs a LOT of bugs at compile-time. So I hope this problem can also be addressed at compile-time.
Thanks for any suggestions!
There currently is no lint to warn about doing lookups on a Map with arguments of the wrong type. This has been requested in https://github.com/dart-lang/linter/issues/1307.
Also see https://github.com/dart-lang/sdk/issues/37392, which requests a type-checked alternative to Map.operator []. In the meantime, Dart's extension mechanism allows anyone to easily add such an alternative themselves. For example, package:basics provides a type-checked Map.get extension.
NOTE:
The original answer was wrong and has been edited to:
point out the right/better answer
explain why the original answer was wrong
Thank you #jamesdlin for pointing this out.
Better answer
As pointed by #jamesdlin in his answer, the lint rule mentioned in the question has been requested in the flutter Github issues, and not in production yet.
Original Answer (wrong but kind of related to the question)
Why it is wrong:
The question was asking about the lint rule when using an index of Map. The answer however gave the lint rule about initializing a map using the wrong index (By the wrong index, I mean different data type).
Below is the answer:
There is a lint rule for this.
For example, if you define a Map like this ->
final Map<String, String> m = {
1: 'some random value',
};
It shows an error right away and this won't compile. This is the error ->
Error: A value of type 'int' can't be assigned to a variable of type 'String'.
1: 'error because index is of type String but assigned value is of type int',
^
Error: Compilation failed.
See the official docs where this lint rule, map_key_type_not_assignable is defined.
I have tested this in dartpad and vs code. Both IDEs show this error.
There could be some issues in your IDE configuration if you're not seeing this lint error.
As for your question, there is already a lint rule for this as explained above.

Flutter compile error: non-null value must be returned since the return type 'String' doesn't allow null - displayString

My tests are failing to compile and run in a Dart only project that is referenced by my Flutter project. I'm receiving the following error message
Failed to precompile test:test:
../../../../../../../../../.pub-cache/hosted/pub.dartlang.org/analyzer-1.0.0/lib/src/error/best_practices_verifier.dart:1952:14: Error: A non-null value must be returned since the return type 'String' doesn't allow null.
String get displayString {
Any ideas please?
Flutter 2.2.1 (current stable channel)
Tools • Dart 2.13.1
(I've asked the question in Flutter's github here also)
https://github.com/flutter/flutter/issues/83683
There was a component using analyzer version 1.0.0
Upgrading this component to use analyzer version 1.7 or above seemed to fix the problem for me.
go to this file: flutter/.pub-cache/hosted/pub.dartlang.org/analyzer-1.5.0/lib/src/error/best_practices_verifier.dart:1978:14.
and add below:-
default:
return '';
Please check the function displayString to make sure that it returns non-null string variable. There are some use cases that I guess you might face with
Use "required" if you get the variable from parameters (ex: String displayString(required String var)).
If the variable is optional parameter, then you need to check if it is null or not. Then, you could "return var!;" to let the function knows that you already confirmed the variable content.
If you want to return nullable String, then you should change the function to "String? displayString".