0

My code by using js Package from flutter :


@JS()
library callable_function;
import 'package:js/js.dart';
import 'package:flutter/material.dart';

  @JS('someData')
  external set _functionName(void Function() f);

  ......

 void _someDartFunction() {
    print('Some data from Dart');
  }

    @override
  void initState() {
    _functionName = allowInterop(_someDartFunction);
    // TODO: implement initState
    super.initState();
  }

And I call the function from window : window.someData();

I get this error: window.someData() is not a function.

But When I tried it from the console it runs. I think the js file loaded before the dart file!

0 Answers0