Skip to content

OptionalMethodChannel hangs on the web #66380

@goderbauer

Description

@goderbauer
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';

void main() {
  runApp(TestApp());
}

class TestApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        body: Center(
          child: RaisedButton(
            onPressed: () {
              print('calling method');
              OptionalMethodChannel('foo').invokeMethod('bar').then((_) {
                print('Done');
              });
            },
            child: Text('push'),
          ),
        ),
      ),
    );
  }
}

When calling a method channel, that's not implemented on the native side, OptionalMethodChannels are documented to return null. This works as expected on mobile. However, on the web, the code above just hangs.

This is a problem for apps that use state restoration, which relies on the fact that if the platform is not implementing the state restoration channel, state restoration is turned off.

/cc @yjbanov

Metadata

Metadata

Assignees

Labels

P1High-priority issues at the top of the work listc: performanceRelates to speed or footprint issues (see "perf:" labels)engineflutter/engine related. See also e: labels.platform-webWeb applications specifically

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions