dart-lang / web

Lightweight browser API bindings built around JS static interop.
https://pub.dev/packages/web
BSD 3-Clause "New" or "Revised" License
134 stars 23 forks source link

append to Head Element not working for me #321

Closed amrgetment closed 6 hours ago

amrgetment commented 6 hours ago

I have flavors and I change google-signin-client_id based on flavor but appending a new Meta element to the Head Element is not working for me

is it a bug or my mistake?

import 'package:web/web.dart';

void addGoogleSigningMeta() {
  // <meta name="google-signin-client_id" content=".apps.googleusercontent.com">

  final HTMLMetaElement metaElement = HTMLMetaElement()
    ..name = 'google-signin-client_id'
    ..content = flavor.googleWebClientId;

  document.head?.append(metaElement);

  print('Added google-signin-client_id meta tag');
}
kevmoo commented 6 hours ago

Is it a runtime error or a no-op? Can you add a print to check if the head property is non-null? (Better to use .head!.append to get a runtime error than a silent failure)

amrgetment commented 6 hours ago

it is my bad, it was a different error due to the wrong client id

│ [error] | 21:40:30 925ms | Assertion failed: file:///Users/amr/.pub-cache/hosted/pub.dev/google_sign_in_web-0.12.4+3/lib/google_sign_in_web.dart:144:9 │ appClientId != null │ "ClientID not set. Either set it on a <meta name=\"google-signin-client_id\" content=\"CLIENT_ID\" /> tag, or pass clientId when initializing GoogleSignIn" │ Assertion failed: file:///Users/amr/.pub-cache/hosted/pub.dev/google_sign_in_web-0.12.4+3/lib/google_sign_in_web.dart:144:9 │ appClientId != null │ "ClientID not set. Either set it on a <meta name=\"google-signin-client_id\" content=\"CLIENT_ID\" /> tag, or pass clientId when initializing GoogleSignIn" └────────────────────────────────────────────────────────────────────────────────────────────────────────────── ┌────────────────────────────────────────────────────────────────────────────────────────────────────────────── │ [critical] | 21:40:30 925ms | Assertion failed: file:///Users/amr/.pub-cache/hosted/pub.dev/google_sign_in_web-0.12.4+3/lib/google_sign_in_web.dart:144:9 │ appClientId != null │ "ClientID not set. Either set it on a <meta name=\"google-signin-client_id\" content=\"CLIENT_ID\" /> tag, or pass clientId when initializing GoogleSignIn" └──────────────────────────────────────────────────────────────────────────────────────────────────────────────

amrgetment commented 6 hours ago

Thanks for your fast help

I can build with wasm, I wonder can I launch the app with wasm --web-renderer skwasm --wasm

kevmoo commented 6 hours ago

Drop the --web-renderer bit. --wasm should be enough.

amrgetment commented 6 hours ago

Thanks a lot for your great support