diff --git a/poc/flutter-poc/lib/poc_simulation.dart b/poc/flutter-poc/lib/poc_simulation.dart index a7badc3..e3a9d48 100644 --- a/poc/flutter-poc/lib/poc_simulation.dart +++ b/poc/flutter-poc/lib/poc_simulation.dart @@ -82,9 +82,8 @@ bool isPocSessionDeadStop({ required List sessionDeadAuthIds, }) { if (result.status != 'AUTH') return false; - final isSessionDead = sessionDeadAuthIds.any( - (id) => step is PocSimHostStep && step.auth == id, - ); + final isSessionDead = + step is PocSimHostStep && sessionDeadAuthIds.contains(step.auth); final detail = result.detail ?? ''; return isSessionDead && (detail.contains('invalid_grant') || @@ -199,10 +198,11 @@ PocSimStep? _parseStep(Map m) { Future runPocSimStep( MorphClient morph, PocSimulationConfig cfg, - PocSimStep step, -) async { + PocSimStep step, [ + http.Client? httpClient, +]) async { return switch (step) { - PocSimFetchStep s => _runFetch(s, cfg.mockApiBaseUrl), + PocSimFetchStep s => _runFetch(s, cfg.mockApiBaseUrl, httpClient), PocSimHostStep s => _runHost(morph, s), PocSimLogoutStep s => _runLogout(morph, s), }; diff --git a/poc/flutter-poc/lib/widgets/simulation_panel.dart b/poc/flutter-poc/lib/widgets/simulation_panel.dart index 8efe9d5..448d277 100644 --- a/poc/flutter-poc/lib/widgets/simulation_panel.dart +++ b/poc/flutter-poc/lib/widgets/simulation_panel.dart @@ -1,4 +1,5 @@ import 'package:flutter/material.dart'; +import 'package:http/http.dart' as http; import 'package:morph_core/morph_core.dart'; import '../poc_simulation.dart'; @@ -24,6 +25,13 @@ class _SimulationPanelState extends State { bool _probe404Enabled = false; final List _results = []; String _sessionDeadMessage = ''; + final http.Client _httpClient = http.Client(); + + @override + void dispose() { + _httpClient.close(); + super.dispose(); + } List get _autoSteps => widget.cfg.steps .where((s) => @@ -47,7 +55,7 @@ class _SimulationPanelState extends State { for (final step in _autoSteps) { if (!mounted) break; - final result = await runPocSimStep(widget.morph, widget.cfg, step); + final result = await runPocSimStep(widget.morph, widget.cfg, step, _httpClient); if (!mounted) break; setState(() => _results.add(result));