mardi 26 octobre 2021

TypeError: Cannot read properties of undefined (reading 'app') {Flutter web app}

I tried to connect my web app to firestore and try to run my web app but I can't. Please help me to solve my problem and grow my start-up faster. This is the error Showing error like this: TypeError: Cannot read properties of undefined (reading 'app')

How can I fix this problem?

**

My Flutter (index.html) code blew.

**

<!DOCTYPE html>
<html>
<head>
  <!--
    If you are serving your web app in a path other than the root, change the
    href value below to reflect the base path you are serving from.

    The path provided below has to start and end with a slash "/" in order for
    it to work correctly.

    For more details:
    * https://developer.mozilla.org/en-US/docs/Web/HTML/Element/base

    This is a placeholder for base href that will be replaced by the value of
    the `--base-href` argument provided to `flutter build`.
  -->
  <base href="$FLUTTER_BASE_HREF">

  <meta charset="UTF-8">
  <meta content="IE=Edge" http-equiv="X-UA-Compatible">
  <meta name="description" content="A new Flutter project.">

  <!-- iOS meta tags & icons -->
  <meta name="apple-mobile-web-app-capable" content="yes">
  <meta name="apple-mobile-web-app-status-bar-style" content="black">
  <meta name="apple-mobile-web-app-title" content="jaitun_admin">
  <link rel="apple-touch-icon" href="icons/Icon-192.png">

  <title>jaitun_admin</title>
  <link rel="manifest" href="manifest.json">
</head>
<body>
  <!-- This script installs service_worker.js to provide PWA functionality to
       application. For more information, see:
       https://developers.google.com/web/fundamentals/primers/service-workers -->
  <script src="https://www.gstatic.com/firebasejs/9.0.1/firebase-app.js"></script>
  <script src="https://www.gstatic.com/firebasejs/9.0.1/firebase-analytics.js"></script>
  <script src="https://www.gstatic.com/firebasejs/9.0.1/firebase-firestore.js"></script>
  <script src="https://www.gstatic.com/firebasejs/9.0.1/firebase-auth.js"></script>
  

  <script>

const firebaseConfig = {
  apiKey: "AIzaSyDmv2oj8958mbUg07FW316IxOAiOdYhPTg",
  authDomain: "jaituncustomaer.firebaseapp.com",
  databaseURL: "https://jaituncustomaer-default-rtdb.firebaseio.com",
  projectId: "jaituncustomaer",
  storageBucket: "jaituncustomaer.appspot.com",
  messagingSenderId: "771594380318",
  appId: "1:771594380318:web:aa0a3b61483d19dc2bfa0f",
  measurementId: "G-B064R6Q9GJ"
};

// Initialize Firebase
const app = initializeApp(firebaseConfig);
const analytics = getAnalytics(app);
</script>
  <script>
    var serviceWorkerVersion = null;
    var scriptLoaded = false;
    function loadMainDartJs() {
      if (scriptLoaded) {
        return;
      }
      scriptLoaded = true;
      var scriptTag = document.createElement('script');
      scriptTag.src = 'main.dart.js';
      scriptTag.type = 'application/javascript';
      document.body.append(scriptTag);
    }

    if ('serviceWorker' in navigator) {
      // Service workers are supported. Use them.
      window.addEventListener('load', function () {
        // Wait for registration to finish before dropping the <script> tag.
        // Otherwise, the browser will load the script multiple times,
        // potentially different versions.
        var serviceWorkerUrl = 'flutter_service_worker.js?v=' + serviceWorkerVersion;
        navigator.serviceWorker.register(serviceWorkerUrl)
          .then((reg) => {
            function waitForActivation(serviceWorker) {
              serviceWorker.addEventListener('statechange', () => {
                if (serviceWorker.state == 'activated') {
                  console.log('Installed new service worker.');
                  loadMainDartJs();
                }
              });
            }
            if (!reg.active && (reg.installing || reg.waiting)) {
              // No active web worker and we have installed or are installing
              // one for the first time. Simply wait for it to activate.
              waitForActivation(reg.installing || reg.waiting);
            } else if (!reg.active.scriptURL.endsWith(serviceWorkerVersion)) {
              // When the app updates the serviceWorkerVersion changes, so we
              // need to ask the service worker to update.
              console.log('New service worker available.');
              reg.update();
              waitForActivation(reg.installing);
            } else {
              // Existing service worker is still good.
              console.log('Loading app from service worker.');
              loadMainDartJs();
            }
          });

        // If service worker doesn't succeed in a reasonable amount of time,
        // fallback to plaint <script> tag.
        setTimeout(() => {
          if (!scriptLoaded) {
            console.warn(
              'Failed to load app from service worker. Falling back to plain <script> tag.',
            );
            loadMainDartJs();
          }
        }, 4000);
      });
    } else {
      // Service workers not supported. Just drop the <script> tag.
      loadMainDartJs();
    }
  </script>
</body>
</html>



Trying to find a website where you can create a message that will not show until a specific date

does anyone know of the website where you can create a message on the website, and then share the link. The twist is that the message will not show until the date and time you have set when creating the original message.




Do I have to continuously repeat certain elements for them to appear on all documents [I'm fairly new]

So basically, I have a generic top navigation bar that shows where you can go.

ex. Top left = "Title" -some space between it- Other Site

Is it possible for me to type the top nav code in one area for it to forever stay in that area. I have opened up a couple of new documents so it's getting pretty repetitive at this point.

In summary, is there a feature/special thing I can do or do I just have to suck it up and continue the way I'm doing it?




Problem with ListView that located over Google map in Flutter web

I'm trying to implement page with Google map and i put ListView over this map. When i scroll this vertical ListView, map is actually scrolls too. Is there any way to prevent this behaviour and scroll map only when cursor located out of listview boundaries? Thanks[![Scroll conflict behind listview and google map][1]][1]

    /// Layout that describes part with ListView
Positioned.fill(
      child: Align(
        alignment: Alignment.bottomRight,
        child: sessions.maybeWhen(
          orElse: () => const SizedBox.shrink(),
          data: (items) {
            return ConstrainedBox(
              constraints: BoxConstraints(
                maxHeight: items.length <= 3
                    ? items.length * 130
                    : mediaQuery.size.width < 720 ? 150 : mediaQuery.size.height * 0.7,
              ),
              child: ScrollablePositionedList.separated(
                itemScrollController: controller,
                scrollDirection: mediaQuery.size.width < 720
                    ? Axis.horizontal
                    : Axis.vertical,
                padding: EdgeInsets.all(mediaQuery.size.width < 720 ? 5 : 20.0),
                itemCount: items.length,
                separatorBuilder: (_, __) => mediaQuery.size.width < 720
                    ? const SizedBox(width: 6.0)
                    : const SizedBox(height: 6.0),
                itemBuilder: (_, i) {
                  return AdaptiveLayout(
                    smallLayout: Align(
                      alignment: Alignment.bottomCenter,
                      child: SizedBox(
                        width: mediaQuery.size.width - 32,
                        height: 100.0,
                        child: SessionCard(
                          session: items[i],
                          selected: selected == items[i],
                          onPressed: () {
                            if (selected == items[i]) {
                              onSelected?.call(null, null);
                            } else {
                              onSelected?.call(items[i], i);
                            }
                          },
                        ),
                      ),
                    ),
                    largeLayout: FractionallySizedBox(
                      widthFactor: 0.4,
                      alignment: Alignment.bottomRight,
                      child: SessionCard(
                        session: items[i],
                        selected: selected == items[i],
                        onPressed: () {
                          if (selected == items[i]) {
                            onSelected?.call(null, null);
                          } else {
                            onSelected?.call(items[i], i);
                          }
                        },
                      ),
                    ),
                  );
                },
              ),
            );
          },
        ),
      ),
    );

///Part with Stack that contains map and ListView
AdaptiveLayout(
      smallLayout: Scaffold(
        body: Stack(
          children: [
            MapWidget(
              onMapCreated: onMapCreated,
              onMarkerSelected: onSessionSelected,
            ),
            // const SearchBar(),
            MapToolbar(
              controller: mapController.value,
              handlePermission: () async {
                final provider = ref.read(positionProvider.notifier);
                if (await (provider.handlePermission(context))) {
                  provider.getCurrentLocation();
                }
              },
            ),
            ValueListenableBuilder<dynamic>(
              valueListenable: selectedSession, /// Contains ListView
              builder: (_, value, __) {
                return SessionCards(
                  onSelected: onSessionSelected,
                  selected: value,
                  controller: scrollController.value,
                );
              },
            ),
            ValueListenableBuilder<bool>(
              valueListenable: showLoading,
              builder: (_, value, __) {
                return LoadingOverlay(
                  showing: value,
                );
              },
            ),
          ],
        ),
      ),



Exclude widget from scrolling in flutter

I was looking for design inspiration for my website and came across a very interesting design, this one (in web view).

What intrigued me, was how the brand name text (DYNAMIC STUDIOS) kept its static position, while the rest of the "widgets" -both in front and behind the text- were included in the scrolling.

My question is: how could we implement this feature with Flutter?

If we only had items in front or behind the Text, then with a simple Stack and SingleChildScrollView that could have easily been done. But how can you "Stack" an item in between "a scroll view"?


Showcased Website was found from the article 12 unique examples of photography portfolio websites.




Where can I set the "Cache-Control" or "ETag" headers for my website?

My website has a cache problem where my ETag's aren't getting generated correctly when a change is made to my website.

I've searched all over the internet, and there are tons of resources explaining WHAT the "ETag" header is for, but there's almost nothing explaining WHERE to set it.

Is there some configuration file I put it in? Some articles mentioned setting ETag generation rules in the .htaccess file, but isn't that just for Apache servers?

Any help is appreciated.

My web app is built with webpack, contained with Docker, and hosted with Kubernetes (using an nginx ingress server).




Changing pages disables navbar menu on Ruby on Rails

I have this problem. When the screen width goes below 1024px, the navbar changes to a responsive navbar that activates when a burger menu is clicked, this is made using javascript (it is being correctly compiled, the file is imported in application.js). This functionality works fine, but when I change pages (from home to store for example) it stops working, and I can't find the reason. Here's the code:

/* Javascript file */


document.addEventListener('DOMContentLoaded', () => {
  let responsiveMenu = document.querySelector('.responsive-navbar');
  let body = document.querySelector('body');
  let burgerBtn = document.querySelector('.burger-menu');
  let responsiveLinks = document.querySelectorAll('.responsive-menu-links')
  burgerBtn.addEventListener('click', () => {
    burgerBtn.classList.toggle('cross')
    responsiveMenu.classList.toggle('menu-open');
    body.classList.toggle('disable-scroll');
    responsiveLinks.forEach(link => {
      link.classList.toggle('trigger-anim')
    })
  })
})

/* _navbar.html.erb partial */

<div class="navbar-header">
  <div class="navbar-menu">
    <%=link_to 'Inicio', root_path%>
    <a href="">ustedes</a>
    <a href="">contacto</a>
    <a href="">sobre mi</a>
    <%=link_to 'Tienda', store_path%>
  </div>
  <div class="burger-menu">
    <span></span>
    <span></span>
    <span></span>
  </div>
  <div class="responsive-navbar">
  <div class="menu-background"></div>
  <div class="menu-links">
     <%=link_to 'Inicio', root_path, class: 'responsive-menu-links'%>
      <a href="" class="responsive-menu-links">ustedes</a>
      <a href="" class="responsive-menu-links">contacto</a>
      <a href="" class="responsive-menu-links">sobre mi</a>
      <%=link_to 'Tienda', store_path, class: 'responsive-menu-links'%>
  </div>
</div>
  <div class="navbar-items">
    <div class="logo">
    </div>
  </div>
</div>

/* styles */

.trigger-anim {
  animation: scaleIn .2s forwards;
}
.menu-open {
  width: 100vw !important;
  a {
    opacity: 1 !important;
  }
}

.disable-scroll {
  overflow: hidden;

  .home-container {
    height: 100vh !important;
    overflow: hidden !important;
  }
}

.cross {
  span {
    &:nth-of-type(1) {
      transform: rotate(40deg) translateY(20px);
    }
    &:nth-of-type(2) {
      transform: translateX(500px);
      opacity: 0;
    }
    &:nth-of-type(3) {
      transform: rotate(-40deg) translateY(-20px);
    }
  }
}