Skip to content

Commit

Permalink
snippetEditingControllerGetter refinement (#24617)
Browse files Browse the repository at this point in the history
  • Loading branch information
darkhan.nausharipov committed Jan 19, 2023
1 parent 93798ea commit d261b2a
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,17 +31,19 @@ class CodeRunner extends ChangeNotifier {
SnippetEditingController? snippetEditingController;

CodeRunner({
required ValueGetter<SnippetEditingController> snippetEditingController,
required ValueGetter<SnippetEditingController>
snippetEditingControllerGetter,
CodeRepository? codeRepository,
}) : _codeRepository = codeRepository,
_snippetEditingControllerGetter = snippetEditingController;
_snippetEditingControllerGetter = snippetEditingControllerGetter;

RunCodeResult? _result;
StreamSubscription<RunCodeResult>? _runSubscription;
DateTime? _runStartDate;
DateTime? _runStopDate;

String? get pipelineOptions => snippetEditingController?.pipelineOptions;
String? get pipelineOptions =>
_snippetEditingControllerGetter().pipelineOptions;
RunCodeResult? get result => _result;
DateTime? get runStartDate => _runStartDate;
DateTime? get runStopDate => _runStopDate;
Expand All @@ -52,7 +54,7 @@ class CodeRunner extends ChangeNotifier {
String get resultLogOutput => resultLog + resultOutput;

bool get isExampleChanged {
return snippetEditingController?.isChanged ?? false;
return _snippetEditingControllerGetter().isChanged;
}

void clearResult() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ class PlaygroundController with ChangeNotifier {

codeRunner = CodeRunner(
codeRepository: codeRepository,
snippetEditingController: () => snippetEditingController!,
snippetEditingControllerGetter: requireSnippetEditingController,
)..addListener(notifyListeners);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ Future<void> main() async {
});

test('Initial value of pipelineOptions should be empty string', () {
expect(controller.codeRunner.pipelineOptions, null);
controller.setSdk(Sdk.go);
expect(controller.codeRunner.pipelineOptions, '');
});
Expand Down

0 comments on commit d261b2a

Please sign in to comment.