Issue I’m trying to create a Flutter widget that can be initialized by various parameters, something like this class MyWidget extends StatefulWidget { final int? id; final String? username; MyWidget({this.id, this.username}); @override _MyWidgetState createState() => _MyWidgetState(); } class _MyWidgetState extends
Continue readingThe return type 'LoginPage' isn't a 'void', as required by the closure's context
Issue so, if user is null.. page is move into login page Widget build(BuildContext context) { AuthServices.userStream.listen((User? user) { if (user == null) { return LoginPage(); } }); } Solution AuthServices.userStream.listen((User? user) { if (user == null) { return login();
Continue readingShould we source control the .mocks.dart files created by build_runner for mockito
Issue Because of null safety in dart, we had to update our codes test. We are using mockito for mocking the dependecies for the given class. As per their docs, we decided to use the build_runner method to generate Mock
Continue readingWhy is one way of json to object working and the other throwing null error? Dart/Flutter null safety trouble
Issue I’m learning how to use json, not used to Dart null safety & I don’t like it so far. But I will have no choice but to adapt to it. I’m trying to parse my json object list into
Continue readingUsing a List in Flutters null safety is confusing me
Issue I’m trying to migrate an existing, small Flutter app to Flutter 2.12. The null safety thing is new and still confusing to me. For the most part I have been successful in resolving the errors from the migration, but
Continue readingFlutter null-safety conditionals in object methods
Issue I’m just working through this whole null-safety mode with my Flutter project and unsure what the difference is with ? and ! in calls to object methods. For example, the hint was to add a ! conditional. Here’s an
Continue readingHow to migrate List fold to null saftey
Issue this code runs fine without null safety: void main() { final a = X(22.5); final b = X(22.5); List<X> x = [a, b]; var tot = x.fold(0.0, (a, b) => a + b.dist); print(tot); } class X { final
Continue readingHow to fix "The method 'containsKey' can't be unconditionally invoked because the receiver can be 'null'." in Null Safety?
Issue I am migrating my app to Null Safety and learning the new approaches, but I got stuck with "The method ‘containsKey’ can’t be unconditionally invoked because the receiver can be ‘null’." when checking if a field exists on firebase
Continue readingRadioListTile onchange value is object? type
Issue I am trying to make multiple choice questions using RadioListTile. RadioListTile( value: 1, groupValue: 1, onChanged: (val) { print("Value"); print(val.runtimeType); setSelectedRadio(val); }, title: Text(snapshot.data!.data()["questions"]["question $i"]["option 1"]), ); The error I am getting is The argument type ‘Object?’ can’t be
Continue readingI have 3 issues from migrating to null-safety
Issue I migrated to null-safety today and I have 3 issues that I don’t know how to fix. Below, I have provided the errors and the code that each error refers to. I do not know how to fix these
Continue reading