How best to convert old Dart code that triggers "parameter can't be 'null' but the implicit default value is 'null'." error?

Issue Take the following non-null safe Dart code: class RoundedButton extends StatelessWidget { RoundedButton({this.title, this.color, @required this.onPressed}); final Color color; final String title; final Function onPressed; @override Widget build(BuildContext context) { return Padding( padding: EdgeInsets.symmetric(vertical: 16.0), child: Material( elevation: 5.0,

Continue reading

Method 'showBottomSheet' cannot be called on 'ScaffoldState?' because it is potentially null

Issue Hello I’m getting this error when I tried to run the code lib/layout/home_layout.dart:54:36: Error: Method ‘showBottomSheet’ cannot be called on ‘ScaffoldState?’ because it is potentially null. – ‘ScaffoldState’ is from ‘package:flutter/src/material/scaffold.dart’ (‘/C:/src/flutter/packages/flutter/lib/src/material/scaffold.dart’). Try calling using ?. instead. scaffoldKey.currentState.showBottomSheet( ^^^^^^^^^^^^^^^

Continue reading

I have a problem with Null Safety an the problem is 'Null check operator used on a null value'

Issue It happened when getting some data from firebase and decoding them using model, and here is the method: UserModel? userModel; void getUser() { emit(GetUserLoadingsState()); FirebaseFirestore.instance.collection(‘users’).doc(uId).get().then((value) { userModel = UserModel.fromJson(value.data()!); emit(GetUserSuccessState()); }).catchError((error) { emit(GetUserErrorState(error.toString())); }); } Calling the method return

Continue reading

A value of type 'StreamSink<dynamic>' can't be returned from the function 'assessmentSink'

Issue class AssessmentBloc { late AssessmentRepository _genRepository; late StreamController assessmentController; late StreamController submitAssessmentController; StreamSink<ApiResponse<AssessmentModel>> get assessmentSink => assessmentController.sink; StreamSink<ApiResponse<AssessmentResult>> get submitSink => submitAssessmentController.sink; AssessmentBloc() { assessmentController = StreamController<ApiResponse<AssessmentModel>>(); submitAssessmentController = StreamController<ApiResponse<AssessmentResult>>(); _genRepository = AssessmentRepository(); } dispose() { assessmentController?.close(); submitAssessmentController?.close(); }

Continue reading