Target of URI doesn't exist: 'package:flutter/material.dart' - flutter

I've just set up my Windows 11 for Flutter development,
So I updated flutter SDK, and placed it in my Documents. After, I got this:
Target of URI doesn't exist: 'package:flutter/material.dart'.
The function 'runApp' isn't defined.
Classes can only extend other classes.
The name 'WidgetBuilder' isn't a type so it can't be used as a type argument.
Undefined class 'Widget'.
Undefined class 'BuildContext'.
The method 'MaterialApp' isn't defined for the type 'MyApp'.
The method 'ThemeData' isn't defined for the type 'MyApp'.
Undefined name 'Colors'.
The method doesn't override an inherited method.
What is an error? It's difficult to me.

Try running the following command in terminal:
flutter pub get

Related

Why getting The method 'contains' isn't defined for the type 'String'. flutter

I am using contains method for a string in dart but getting an error like this.
can anyone tell me what is wrong with using .contains for a string in dart
This is my code
String isPdf = "https://www.africau.edu/images/default/sample.pdf";
isPdf.contains("pdf");
Error occurs
The method 'contains' isn't defined for the type 'String'.
Try correcting the name to the name of an existing method, or defining a method named 'contains'.
In vscode quickfix tells me that
change the 'contains' method to 'oscontains'.

The method pickImage isn't defined for the class

Error: The method 'pickImage' isn't defined for the class 'ImagePicker'.
How do you solve this problem, please?
Either you are using the old version of Image_picker or
you have a name conflict. Make sure to neither name your files
image_picker.dart or name your class ImagePicker.

The getter 'instance' isn't defined for the type 'FirebaseMessaging'

The getter 'instance' isn't defined for the type 'FirebaseMessaging'. Try importing the library that defines 'instance', correcting the name to the name of an existing getter, or defining a getter or field named 'instance'.
I am trying to implement this sample codehttps://github.com/FirebaseExtended/flutterfire/blob/master/packages/firebase_messaging/firebase_messaging/example/lib/main.dart
But it is showing above mentioned error. How to fix it?
firebase_messaging: ^7.0.3import 'package:firebase_messaging/firebase_messaging.dart';
The getter 'instance' is not available on firebase_messaging: ^7.x.x , you will need to upgrade to version 8

Flutter "argument type not assignable" Error with two identical types

Flutter shows me this error, but the two types are identical.
[CartItem it's just a simple model; there was a conflict since another widget had the same name but I resolved it using "as" in the import statement]
The argument type List<CartItems> (where CartItem is defined in /Users/marco/Documenti Locali/shop_app/lib/providers/cart.dart)' can't be assigned to the parameter type List<CartItems> (where CartItem is defined in /Users/marco/Documenti Locali/shop_app/lib/providers/cart.dart)'.dartargument_type_not_assignable
list.dart(56, 16): List is defined in /Users/marco/flutter/bin/cache/pkg/sky_engine/lib/core/list.dart
cart.dart(3, 7): CartItem is defined in /Users/marco/Documenti Locali/shop_app/lib/providers/cart.dart
list.dart(56, 16): List is defined in /Users/marco/flutter/bin/cache/pkg/sky_engine/lib/core/list.dart
cart.dart(3, 7): CartItem is defined in /Users/marco/Documenti Locali/shop_app/lib/providers/cart.dart
Peek Problem (⌥F8)
No quick fixes available
It was a double slash in the import statement that generated this strange error.
you should use the library prefix in the usage too so if your namespace is
import 'package:app/xxxx/shop_app/lib/providers/cart.dart as shop_cart;
you should specify it in the generic List as well such as;
List shopCarts = etc...;
Check your import statement at the top of file even if you mistyped a directory folder name as 'Caps or Small' you can get this error.

DbProviderFactories.GetFactory Method (DbConnection) missing

According to MSDN there is an overload of GetFactory(DbConnection) in .NET 4. However, I can't invoke it - fails at compile time saying:
error BC30518: Overload resolution failed because no accessible 'GetFactory' can be called with these arguments:
'Public Shared Function GetFactory(providerRow As System.Data.DataRow) As System.Data.Common.DbProviderFactory': Value of type 'System.Data.Common.DbConnection' cannot be converted to 'System.Data.DataRow'.
'Public Shared Function GetFactory(providerInvariantName As String) As System.Data.Common.DbProviderFactory': Value of type 'System.Data.Common.DbConnection' cannot be converted to 'String'.
Is there something wrong with my .NET FW or is it a typo in documentation?
You can call the "GetFactory" method using the following solution:
https://msdn.microsoft.com/en-us/library/dd0w4a2z%28v=vs.110%29.aspx
DbProviderFactory factory =
DbProviderFactories.GetFactory(providerName);