Issue There are so many properties in the RaisedButton whose equivalent I can’t find yet in the ElevatedButton. So, how can I convert or replicate a RaisedButton (with all the properties) to the new ElevatedButton? Like: RaisedButton( onPressed: () {},
Continue readingWhy can a nullable value still be considered nullable inside the scope of an if statement that checks for nullability?
Issue Consider this demo: void test(int? n) { if (n != null) { // let’s make sure n is not null ++n; // ok; n is assumed to be non-null if (n < 0) { n = n.abs(); // ok;
Continue readingDropdownButton error: The argument type 'void Function(String)' can't be assigned to the parameter type 'void Function(String?)?'
Issue I started seeing this error in my DropdownButton after migrating to null safety. DropdownButton<String>( value: myValue, onChanged: (String string) { // Error print(string); }, items: [ DropdownMenuItem( value: ‘foo’, child: Text(‘Foo’), ), DropdownMenuItem( value: ‘bar’, child: Text(‘Bar’), ), ],
Continue readingWhy snapshot.data returns null in FutureBuilder?
Issue void main() { FutureBuilder<bool>( future: f(), builder: (_, AsyncSnapshot<bool> snapshot) { bool data = snapshot.data; // Error return Container(); }, ); } Future<bool> f() async => true; I used bool in all the places and hence my snapshot.data should
Continue readingFlow analysis doesn't work when using setState
Issue void f() { String string; setState(() { string = fooCondition ? ‘foo’ : ‘bar’; }); string.toUpperCase(); // Error } If I remove the setState condition, the flow analysis work! I could put my setState below (blank setState(() {}) but
Continue readingWhat's the difference between ? and ! in collections like Map, List and Set?
Issue What’s the difference between ? and ! when used in a collection in Dart? Say, I have: var list = [1, 2]; Now, I can either use print(list?[0]); // prints 1 or print(list![0]); // also prints 1 Both of
Continue readingShorthand of checking the nullability of a bool variable used in an if condition
Issue Future<bool?> f() async => true; void main() async { final proceed = await f(); if (proceed) {…} // Error if (proceed != null && proceed) {…} // Works but too verbose } Is there any shorthand or a better
Continue readingCallBack Function with null safety
Issue I have a widget like this class googleMapComponent extends StatefulWidget { Function(LatLng pos) OnPositionChangeCallback; googleMapComponent({ this.OnPositionChangeCallback,}) using nullsafety i get this error The parameter ‘OnPositionChangeCallback’ can’t have a value of ‘null’ because of its type, but the implicit default
Continue readingHow to do a multi check for null values after Dart null safety?
Issue int? foo, bar, baz; bool get allGood => foo != null && bar != null && baz != null; void f1() { if (allGood) { print(‘${foo.abs()} ${bar.abs()} ${baz.abs()}}’); // Error } } void f2() { if (allGood) { print(‘${foo.ceil()}
Continue readingThe parameter 'firebaseFirestore' can't have a value of 'null' because of its type, but the implicit default value is 'null' in flutter
Issue I declared two variables of type FirebaseFirestore and FireBaseAuth, and now i am facing an error of null safety. I am using a constructor in my class, and passing them as paraeters, with getting an error of – The
Continue reading