Flutter web client

Hello,
I’m trying an example from this video:

With Windows and Android builds, everything works as expected, but the Web build throws an exception:

Launching lib\main.dart on Chrome in debug mode…
Waiting for connection from debug service on Chrome…
This app is linked to the debug service: ws://127.0.0.1:50589/wJQmqiahdfA=/ws
Debug service listening on ws://127.0.0.1:50589/wJQmqiahdfA=/ws
Debug service listening on ws://127.0.0.1:50589/wJQmqiahdfA=/ws
ChromeProxyService: Failed to evaluate expression ‘StackTrace’: InternalError: Expression evaluation in async frames is not supported. No frame with index 30…
Error: Unexpected null value.
dart-sdk/lib/internal/js_dev_runtime/private/ddc_runtime/errors.dart 288:49 throw
dart-sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/operations.dart 606:63 nullCheck
packages/servicestack/web_client.dart 577:63 handleError
dart-sdk/lib/_internal/js_dev_runtime/patch/async_patch.dart 84:54 runBody
dart-sdk/lib/_internal/js_dev_runtime/patch/async_patch.dart 123:5 _async
packages/servicestack/web_client.dart 573:14 handleError
packages/servicestack/web_client.dart 384:20 sendRequest
dart-sdk/lib/_internal/js_dev_runtime/patch/async_patch.dart 60:31
dart-sdk/lib/async/zone.dart 1666:54 runBinary
dart-sdk/lib/async/future_impl.dart 162:22 handleError
dart-sdk/lib/async/future_impl.dart 796:46 handleError
dart-sdk/lib/async/future_impl.dart 817:13 _propagateToListeners
dart-sdk/lib/async/future_impl.dart 592:5 [_completeError]
dart-sdk/lib/async/future_impl.dart 683:7 callback
dart-sdk/lib/async/schedule_microtask.dart 40:11 _microtaskLoop
dart-sdk/lib/async/schedule_microtask.dart 49:5 _startMicrotaskLoop
dart-sdk/lib/_internal/js_dev_runtime/patch/async_patch.dart 177:15

Is web supported platform for flutter applications?

It looks like a null ref in the web_client when handling an error response. Can you confirm which version of the servicestack Dart package you are using in your project?

Also, can you use the browser dev tools to extract the response that is related to this error to help us reproduce the problem?

all code is generated with:

x new vue-js BookingsApp

and:

x mix flutter

pubspec.yaml:

name: bookingsapp_flutter
description: A new Flutter project.
publish_to: 'none' # Remove this line if you wish to publish to pub.dev


version: 1.0.0+1

environment:
  sdk: '>=3.0.5 <4.0.0'

dependencies:
  flutter:
    sdk: flutter

  cupertino_icons: ^1.0.2
  servicestack: ^2.0.3

dev_dependencies:
  flutter_test:
    sdk: flutter
  
  flutter_lints: ^2.0.0

flutter:
  uses-material-design: true

OK, problem was with CorsFeature:

public class AppHost : AppHostBase, IHostingStartup
{
    public void Configure(IWebHostBuilder builder) => builder
        .ConfigureServices(services => {
            // Configure ASP.NET Core IOC Dependencies
        });

    public AppHost() : base("BookingsApp", typeof(MyServices).Assembly) {}

    public override void Configure(Container container)
    {
        SetConfig(new HostConfig {
        });
        
        Plugins.Add(new CorsFeature(new[] {
            "http://localhost:5173", //vite dev            
        }, allowCredentials:true));

    }
}

It works with this configuration:

Plugins.Add(new CorsFeature(new[] {
            "http://localhost:5173", //vite dev
            "http://localhost:62949",
        }, allowCredentials:true));
2 Likes