Dart 2 is changing the Dart language in many ways, some of which are not backward-compatible.
Questions tagged [dart-2]
60 questions
                    
                    154
                    
            votes
                
                8 answers
            
        What is the correct way to add date picker in flutter app?
In my app I am creating signup page where I need to add DOB. I want to add date picker in that but I am not getting correct way to do this. 
        
        Code Hunter
        
- 10,075
 - 23
 - 72
 - 102
 
                    53
                    
            votes
                
                8 answers
            
        The argument type 'Object' can't be assigned to the parameter type 'ImageProvider
I just updated to Dart2 and Flutter sdk: '>=2.12.0 <3.0.0' and now this if statement breaks:
 decoration: new BoxDecoration(
              shape: BoxShape.circle,
              color: Colors.blueAccent,
              border: Border.all(
            …
        
        JoergP
        
- 1,349
 - 2
 - 13
 - 28
 
                    33
                    
            votes
                
                11 answers
            
        pub global activate command - $HOME/.pub-cache/bin not on path
I was trying to install dart2 recently, but when I try to install pub global activate stagehand, it comes with a warning. 
Warning: Pub installs executables into $HOME/.pub-cache/bin, which is not on your path.
You can fix that by adding this to…
        
        Kevin
        
- 477
 - 1
 - 5
 - 13
 
                    28
                    
            votes
                
                2 answers
            
        How do I declare 64bit unsigned int in dart/flutter?
For an app, I need a 64bit unsigned int. Looking at dart documentation I did not see how to exactly go about declaring one.
Can anyone tell me how this is done? I will use this "64bit unsigned int" in bitwise operation.
        
        Ragas
        
- 3,005
 - 6
 - 25
 - 42
 
                    16
                    
            votes
                
                7 answers
            
        Cannot focus on TextField in new page after navigating in Flutter
For some reason, I cannot focus on a TextField after on the next page after navigating. The keyboard would automatically dismiss when the TextField is selected. If I set autofocus: true on the TextField, then the keyboard will infinitely popup and…
        
        Pybanana
        
- 351
 - 1
 - 2
 - 6
 
                    12
                    
            votes
                
                4 answers
            
        Upload & fetch media files from AWS S3 in Flutter
My flutter app is using firebase as a backend but I need to store media files (photos & videos) in my s3 bucket. The mission is to upload the media retrieved from the image picker into s3 & get back the url, which can then be stored as a string in…
        
        Endemic
        
- 370
 - 1
 - 2
 - 15
 
                    12
                    
            votes
                
                2 answers
            
        Bidirectional communication with isolates in Dart 2
I'm trying isolates and I'm wondering how could I spawn some of them doing heavy computations that, when the root Isolate ask them for their current computing value they respond it, "on demand".
As far as I know, the only object that can be used as…
        
        Nico Rodsevich
        
- 2,393
 - 2
 - 22
 - 32
 
                    11
                    
            votes
                
                2 answers
            
        Callback with generic type parameter in Dart
I'm trying to define a callback function that needs to accept a generic parameter and return a value of the same type. Keep in mind that the following example is an oversimplified version of what I actually need.
final T Function(T value) self =… 
        
        skreborn
        
- 2,133
 - 2
 - 16
 - 27
 
                    11
                    
            votes
                
                1 answer
            
        How to typedef a generic function?
I have a generic static method that looks like this:
static build() {
    return (GenericClass param) => MyClass(param);
}
So far I have tried:
typedef F = MyClass Function(GenericClass param);
but it says that:
The return type…     
        
        arielnmz
        
- 8,354
 - 9
 - 38
 - 66
 
                    9
                    
            votes
                
                3 answers
            
        Flutter NetworkImage handle 403 error
In my Flutter mobile app while loading profile image of users through NetworkImage(), I am getting 403 status code in response.
How can I handle this by displaying an Image from my assets folder in case of 403 status code or if image URL is broken…
        
        Thanthu
        
- 4,399
 - 34
 - 43
 
                    7
                    
            votes
                
                1 answer
            
        Null-aware function call?
Dart has some null-aware operators, i.e. it is possible to do
var obj;
obj?.foo(); // foo is only called if obj != null.
Is this also possible for functions that are stored or passed to variables? The usual pattern is
typedef void SomeFunc();
void…
        
        Eiko
        
- 25,601
 - 15
 - 56
 - 71
 
                    7
                    
            votes
                
                2 answers
            
        When is const optional in Dart 2?
In Dart Object() constructor is declared as const so:
identical(const Object(), const Object()); //true
I know that in Dart 2 the keyword const is optional and I thought that the previous statement was equivalent to:
identical(Object(), Object());…
        
        user1756508
        
- 109
 - 5
 
                    5
                    
            votes
                
                2 answers
            
        What is the difference among .cast() and List.from() and List.castFrom()
List foo -> List bar
I can use three method
1.List bar = foo.cast()
2.List bar = List.castFrom(foo)
3.List bar = List.from(foo)
What is the difference?
    
        
        Taz
        
- 1,737
 - 1
 - 15
 - 30
 
                    5
                    
            votes
                
                0 answers
            
        Dart2JS Cannot get async code to run when converted from Dart to Javascript
main() async {
  print('Hello World');
  await getAsyncString().then((hello) => print(hello));
}
Future getAsyncString() async {
  return 'Hello Async World';
}
This is my code example, index.dart. It is in my web folder.
I run webdev… 
        
        John Franke
        
- 1,444
 - 19
 - 23
 
                    5
                    
            votes
                
                5 answers
            
        Could not find a generator for route "home-page" in the _MaterialAppState
I am getting exception when I trying to navigate from one view to another in flutter app. 
I/flutter ( 2199): ══╡ EXCEPTION CAUGHT BY GESTURE ╞═══════════════════════════════════════════════════════════════════
I/flutter ( 2199): The following…
        
        Code Hunter
        
- 10,075
 - 23
 - 72
 - 102