Explore all Tutorial open source software, libraries, packages, source code, cloud functions and APIs.

Explore Related Topics

Popular New Releases in Tutorial

leetcode

新书出版

wtfjs

v1.22.1

intro.js

v5.1.0

algorithms

v0.1.4

LeetCode-Go

1.7.0

Popular Libraries in Tutorial

freeCodeCamp

by freeCodeCamp doticonjavascriptdoticon

star image 344419 doticonBSD-3-Clause

freeCodeCamp.org's open-source codebase and curriculum. Learn to code for free.

javascript-algorithms

by trekhleb doticonjavascriptdoticon

star image 138596 doticonMIT

📝 Algorithms and data structures implemented in JavaScript with explanations and links to further readings

CS-Notes

by CyC2018 doticonjavadoticon

star image 137910 doticon

:books: 技术面试必备基础知识、Leetcode、计算机操作系统、计算机网络、系统设计

Python

by TheAlgorithms doticonpythondoticon

star image 117097 doticonMIT

All Algorithms implemented in Python

interviews

by kdn251 doticonjavadoticon

star image 53816 doticonMIT

Everything you need to know to get the job.

Java

by TheAlgorithms doticonjavadoticon

star image 45287 doticonMIT

All Algorithms implemented in Java

Web-Dev-For-Beginners

by microsoft doticonjavascriptdoticon

star image 44908 doticonMIT

24 Lessons, 12 Weeks, Get Started as a Web Developer

leetcode

by azl397985856 doticonjavascriptdoticon

star image 43986 doticonNOASSERTION

LeetCode Solutions: A Record of My Problem Solving Journey.( leetcode题解,记录自己的leetcode解题之路。)

build-web-application-with-golang

by astaxie doticongodoticon

star image 38531 doticonBSD-3-Clause

A golang ebook intro how to build a web with golang

Trending New libraries in Tutorial

Web-Dev-For-Beginners

by microsoft doticonjavascriptdoticon

star image 44908 doticonMIT

24 Lessons, 12 Weeks, Get Started as a Web Developer

hello-algorithm

by geekxh doticonjavadoticon

star image 29811 doticon

🌍 针对小白的算法训练 | 包括四部分:①.算法基础 ②.力扣图解 ③.大厂面经 ④.CS_汇总 | 附:1、千本开源电子书 2、百张技术思维导图(项目花了上百小时,希望可以点 star 支持,🌹感谢~)

algorithm-pattern

by greyireland doticongodoticon

star image 12016 doticon

算法模板,最科学的刷题方式,最快速的刷题路径,你值得拥有~

algorithm-base

by chefyuan doticonjavadoticon

star image 8824 doticonMIT

专门为刚开始刷题的同学准备的算法基地,没有最细只有更细,立志用动画将晦涩难懂的算法说的通俗易懂!

basic-computer-games

by coding-horror doticoncsharpdoticon

star image 8118 doticonUnlicense

An updated version of the classic "Basic Computer Games" book, with well-written examples in a variety of common MEMORY SAFE, SCRIPTING programming languages. See https://coding-horror.github.io/basic-computer-games/

The-Complete-FAANG-Preparation

by AkashSingh3031 doticonjupyter notebookdoticon

star image 7378 doticonMIT

This repository contains all the DSA (Data-Structures, Algorithms, 450 DSA by Love Babbar Bhaiya, FAANG Questions), Technical Subjects (OS + DBMS + SQL + CN + OOPs) Theory+Questions, FAANG Interview questions, and Miscellaneous Stuff (Programming MCQs, Puzzles, Aptitude, Reasoning). The Programming languages used for demonstration are C++, Python, and Java.

easy_rust

by Dhghomon doticonshelldoticon

star image 6065 doticonMIT

Rust explained using easy English

LeetCode

by yuanguangxin doticonjavadoticon

star image 5890 doticon

LeetCode刷题记录与面试整理

content

by mdn doticonhtmldoticon

star image 4840 doticonNOASSERTION

The content behind MDN Web Docs

Top Authors in Tutorial

1

PacktPublishing

126 Libraries

star icon4879

2

SAP-samples

90 Libraries

star icon1933

3

apachecn

53 Libraries

star icon23678

4

microsoft

48 Libraries

star icon67554

5

googlearchive

35 Libraries

star icon2030

6

tutsplus

35 Libraries

star icon463

7

udacity

33 Libraries

star icon12103

8

raywenderlich

33 Libraries

star icon25961

9

SAP-archive

30 Libraries

star icon594

10

aws-samples

29 Libraries

star icon4333

1

126 Libraries

star icon4879

2

90 Libraries

star icon1933

3

53 Libraries

star icon23678

4

48 Libraries

star icon67554

5

35 Libraries

star icon2030

6

35 Libraries

star icon463

7

33 Libraries

star icon12103

8

33 Libraries

star icon25961

9

30 Libraries

star icon594

10

29 Libraries

star icon4333

Trending Kits in Tutorial


Java is a high-level, class-based, object-oriented programming language that is designed to have as few implementation dependencies as possible. 


In this kit, we build a basic Java Programming application to calculate interests of deposits, account transactions and other functionalities of a sample account in the Banking domain.

Knowlege resources on Java-basics

Support


For any support, you can reach us at OpenWeaver Community Support

kandi 1-Click Install

JavaScript libraries are collections of pre-written code that can be used to create web applications. They provide functions, features, and resources.


It makes the development process faster and easier They often create dynamic, interactive experiences on websites and applications. JavaScript libraries are used for various tasks, such as DOM manipulation, AJAX requests, data analysis and visualization, client-side storage, and more. It includes Creating Interactive Tours, Enhancing Customer Experience, Creating Interactive Tutorials, and Improving User Onboarding.  


Let us look at some of these famous libraries. 

webpack

  • Offers advanced features such as code-splitting, hot module replacement (HMR), tree-shaking, and dynamic loading.
  • Provides plugins and loaders that can be used to customize how code is transformed and bundled.
  • Allows to combine multiple modules into a single bundle.

mocha

  • Provides an asynchronous testing interface.
  • Supports a wide variety of testing styles with its flexible syntax.
  • Allows developers to create custom test interfaces and reporters.

intro.js

  • Supports auto-scroll and scroll-hijacking.
  • Allows developers to create custom tours in any language.
  • Provides a modern and lightweight interface, with a minimalistic design.

bower

  • Supports versioning and resolution of dependencies. 
  • Provides command line interface making it easy to instantly search, install, and manage packages in a project. 
  • Allows to manage both front-end and back-end packages. 

grunt

  • Provides wide range of plugins and third-party integrations.
  • Provides built-in support for popular frameworks and libraries.
  • Allows developers to easily configure and create tasks for automating common development workflows.

knockout

  • Provides an easy-to-use two-way data-binding system.
  • Provides a powerful templating system that makes it easy to display complex data structures. 
  • Provides a declarative binding syntax that simplifies linking the data to the HTML elements on the page. 

shepherd

  • Allows developers to create step-by-step product tours and walkthroughs intuitively.
  • Provides options for targeting specific users, including localization and different themes.
  • Supports integration with other libraries and frameworks, such as React and Vue.

mixitup

  • Provides built-in support for powerful animation effects.
  • Allows developers to create custom sorting and filtering rules.
  • Supports integration with external API's, allowing pulling in data from other sources. 

hopscotch

  • Is highly accessible, i.e., it is easy for people with disabilities to use.
  • Offers comprehensive documentation, making it easy for developers to get up and running quickly.
  • Is device-agnostic, meaning it works across different devices and browsers.

joyride

  • Provides a built-in feature called “Progress Indicator,” which allows the user to see their progress through the tour.  
  • A built-in analytics system provides valuable insights into how users interact with the tour. 
  • Allows developers to easily add triggers and custom CSS to enhance the user experience. 


Python is a popular programming language that is used in many different fields, including data science, web development, and artificial intelligence.


It was first released in 1991 and has since become one of the most popular programming languages due to its simplicity and ease of use. This kit has a simple News Scrapper which creates a CSV of top ten news in various categories that can be very helpful in data monitoring, extraction and machine learning applications.

For a detailed tutorial on installing & executing the solution as well as learning resources including training & certification opportunities, please visit the OpenWeaver Community

Kit Solution Source

Python Repositories with Example Exercises

Python CLI programs as examples. This list has programs useful for someone who is a beginner and also someone willing to go advance level.

Support

If you need help using this kit, you may reach us at the OpenWeaver Community.

kandi 1-Click Install

class Question:

def __init__(self, prompt, options, correct_option):

self.prompt = prompt

self.options = options

self.correct_option = correct_option


def ask_question(self):

print(self.prompt)

for i, option in enumerate(self.options, 1):

print(f"{i}. {option}")

user_answer = input("Enter the number of your answer: ")

return int(user_answer) == self.correct_option



def run_quiz(questions):

score = 0

for question in questions:

if question.ask_question():

print("Correct!\n")

score += 1

else:

print("Incorrect. The correct answer was option", question.correct_option, "\n")


print("You got", score, "out of", len(questions), "questions correct.")



# Define your questions here

question1 = Question("What is the capital of France?", ["Paris", "Rome", "Berlin", "Madrid"], 1)

question2 = Question("What is the largest planet in our solar system?", ["Jupiter", "Mars", "Venus", "Saturn"], 1)

question3 = Question("What is 2 + 2?", ["3", "4", "5", "6"], 2)


# Add more questions if desired


questions = [question1, question2, question3]


# Run the quiz

run_quiz(questions)


Data Analysis is a process for obtaining raw data and subsequently converting it into information useful for decision-making by users. The need for analyzing data to utilize it in different application areas has been in great demand. This kit has been curated with ✅ Easy to use open source repos to get you started ✅ popular and easy to use Data Analysis specific libraries ✅ Collection of Data Analysis resources - blogs, books, tutorials, and more ✅ Example program on Data Analysis in Jupyter (Recording of the training session provided)

Pandas for Data Analysis

Pandas adds data structures and tools designed to work with table-like data (in the form of Series and Data Frames)

Python Libraries for Mathematical Computations

NumPy allows to easily perform advanced mathematical and statistical operations on multidimensional arrays and matrices.

Kit Solution source Link

Here's a project with the installer, source code, and step-by-step tutorial that you can build in under 30 mins. Example project on Weight Conversion in python Link for getting started with Python Kit Basics of Python Programming

<iframe width="560" height="315" src="https://www.youtube.com/embed/9Sq_7Gj-PxE" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" allowfullscreen></iframe>


Build AI Model for Breast Cancer Prediction - YouTube



There are many benefits of using a dedicated leetcode repo. The most obvious one is that you can create your own version of the leetcode in any language you want.

You can add new features, remove other features and make it more convenient to use. LeetCode is a popular website for solving programming challenges. It has many practice repos like Leetcode-pattern, Leetcode-Go, and vscode-leetcode which provides you with practice problems to solve. This repo would be like an online playground where people can practice these libraries and use them in real-world scenarios without worrying about syntax errors or browser compatibility issues because everything will be handled by the server itself. Another benefit of having such a repo is that if someone wants to practice some problem without having internet connection then they can do so by downloading the repository and running it locally on their machine. Popular open source leetcode repo for developers include

interviews:  

  • It is a Java library used in Tutorial, Learning, Example Codes applications.  
  • It helps to test problem-solving, coding skill, and understanding of JavaScript concepts.  
  • It provides an assessment of a candidate's capabilities.

LeetCode-Go:  

  • It helps to practice coding problems on LeetCode using the Go language.  
  • It often focuses on algorithms and data structures.  
  • This cross-language experience can be valuable when working with JavaScript or other languages.

vscode-leetcode:  

  • It enhances the experience of practicing coding problems on LeetCode.  
  • It provides features like code snippets and test case management. Also, it provides a seamless coding environment.  
  • It offers a dedicated environment for solving problems. This makes it easier to focus on coding.

leetcode-patterns:  

  • The LeetCode patterns in JavaScript practice repositories.  
  • It plays a crucial role in enhancing coding skills.  
  • It solves algorithmic problems by identifying common patterns and techniques.

leetcode:  

  • It can be valuable for JavaScript practice.  
  • It offers algorithmic challenges that enhance problem-solving skills.  
  • It serves as a demonstration of your coding skills and dedication to improvement.

LeetCode:  

  • It is valuable for JavaScript practice as it offers real-world coding challenges.  
  • It allows you to showcase coding skills to potential employers and build a portfolio.  
  • It enhances problem-solving skills and algorithmic understanding.

leetcode-cli:  

  • It enables you to run test cases. It ensures your solutions work before submitting them on the LeetCode platform.  
  • The LeetCode CLI (Command Line Interface) can be valuable in JavaScript practice repositories.  
  • It is efficient problem-solving for portfolio enhancement and community engagement.

LeetCode-Solutions:  

  • It helps in Tutorial, Learning, Example Codes, LeetCode applications.  
  • It enhances your problem-solving skills.  
  • LeetCode solutions in a public repository allow others to review and provide feedback.

leetcode-editor:  

  • It is often a reference to tools or extensions.   
  • It solves LeetCode problems within a code editor.  
  • It is often integrated with code editors, allowing code writing and testing your code.

leetcode-patterns:  

  • It plays an important role in enhancing your coding skills.   
  • It contains curated sets of problems categorized based on common patterns or techniques.  
  • It provides a structured approach to learning algorithms and data structures.

FAQ  

1.What is a JavaScript Practice Repos library?  

The JavaScript Practice Repos library is a collection of repositories on platforms. Those platforms are like GitHub, containing JavaScript exercises, challenges, and projects. It helps individuals enhance their coding skills.  

  

2.How do I find JavaScript Practice Repositories?  

You can search on GitHub or other code-sharing platforms using keywords. Those keywords are like "JavaScript practice," "JavaScript exercises," or "JavaScript projects." You can explore curated lists that compile such repositories.  

  

3.Why should I use JavaScript Practice Repositories?  

Practice repositories provide hands-on coding experience. It helps you to apply theoretical knowledge to real-world scenarios. They cover a range of difficulty levels. It makes them suitable for both beginners and experienced developers.  

  

4.Can you recommend some popular JavaScript Practice Repos?  

Some popular JavaScript practice repositories include:  

  • freeCodeCamp and JavaScript30 by Wes Bos  
  • Exercism JavaScript Track  

These repositories offer diverse challenges and projects.  

  

5.How do I contribute to a JavaScript Practice Repo?  

Fork the repository and make changes in your fork. It creates a pull request to propose your contributions. Follow the guidelines provided by the repository. It ensures your code adheres to best practices.

Redux is a powerful JavaScript library. Complex web applications use it to manage application state. It provides a predictable state container.  


It helps centralize and manage an application's state in a consistent manner. At its core, Redux follows the principles of unidirectional data flow. This approach promotes a more maintainable and scalable architecture. 

Key components of Redux include: 


  • Store: The central hub of Redux, which holds the application's state. It lets in get right of entry to to the nation through getState(). It updates the state via dispatch(action). It registers listeners via subscribe(listener). 
  • Actions: Plain JavaScript objects that represent events or changes in the application state. The Redux store dispatches actions to trigger state updates. 
  • Reducers are pure functions. They specify how the application's country modifications in reaction to actions. Each reducer takes the current state and an action as input and returns the next state. 
  • Middleware extends Redux's capabilities. It enables features like asynchronous actions, logging, and more. Middleware intercepts dispatched actions before they reach the reducers, allowing for extra processing. 

Redux promotes a single source of truth for application state. This makes it easier to debug, test, and reason about the behavior of an application. It emphasizes immutability. It ensures that state mutations occur in a controlled manner. Developers often use Redux with frameworks like React, Angular, and Vue.js. They can also use it with any JavaScript framework or library. 

Redux offers a robust solution for managing application state. It's especially useful in large-scale applications. It has complex requirements for managing data flow and state. 

react-redux-firebase:  

  • React Redux Firebase is a library that integrates Firebase with Redux and Reacts.  
  • React Redux Firebase handles the authentication state within the Redux store.  
  • It provides higher-order components that enable integration between Redux and Firebase data.  

react-router-redux:  

  • react-router-redux was a library that provided integration between React Router and Redux.  
  • react-router-redux provided a set of utilities for synchronizing the states React Router Redux.  
  • react-router-redux relied on Redux middleware to intercept and handle navigation actions.  

react-redux-form:  

  • React Redux Form is a library that integrates Redux with forms in React applications.  
  • React Redux Form integrates with Redux, allowing you to store form data and state in the Redux store.  
  • React Redux Form integrates with Redux DevTools Extension.  

redux-tutorial: 

  • Clear step-by-step guide for beginners to learn Redux concepts. 
  • Provides practical examples for better understanding Redux principles. 
  • Covers advanced Redux topics such as middleware and async actions. 

redux-in-chinese: 

  • Comprehensive Redux documentation translated into Chinese for wider accessibility. 
  • Helps Chinese-speaking developers understand Redux concepts and usage. 
  • Provides localized examples and tutorials for a smoother learning experience. 

redux-auth-wrapper: 

  • Simplifies integration of authentication logic into Redux powered React applications. 
  • Offers higher-order components (HOCs) for managing authenticated routes. 
  • Supports custom authentication strategies and user role handling. 

redux-code: 

  • Provides a centralized repository for sharing Redux-related code snippets and examples. 
  • Offers a wide range of reusable Redux patterns and utilities. 
  • Enables developers to find and install common Redux functionalities. 

FAQ 

1. What is Redux, and why should I use it in my JavaScript applications? 

Redux is a JavaScript library. The developers designed it to manage application state in complex web applications. It provides a predictable state container. It centralizes and manages the application state in a consistent manner. Using Redux promotes maintainable and scalable architecture. It follows the principles of unidirectional data flow. 


2.How does Redux differ from other state management solutions? Redux differs from other state management solutions. It promotes a single source of truth for application state. This simplifies debugging, testing, and reasoning about application behavior. It emphasizes immutability and pure functions. This ensures predictable state changes and facilitates easier debugging. 

 

3.What are actions and reducers in Redux? 

Actions are plain JavaScript objects. They represent events or changes in the application state. The Redux store dispatches them to trigger state updates. Reducers are pure functions. They specify how the application's country adjusts in reaction to actions. Each reducer takes the current state and an action as input and returns the next state. 


4.What role does middleware play in Redux? 

Middleware in Redux extends its capabilities. It enables features like asynchronous actions, logging, and more. Middleware intercepts dispatched actions before they reach the reducers, allowing for more processing. This enables functionalities such as handling asynchronous operations in a Redux application. 


5.Can any JavaScript framework or library use Redux? 

You can use Redux with any JavaScript framework or library, not limited to React, Angular, or Vue.js. Its flexibility allows developers to integrate it into their preferred frontend stack. Redux's principles of unidirectional data flow and predictable state management can benefit applications. This is true regardless of the underlying technology stack. 

Trending Discussions on Tutorial

Instead change the require of index.js, to a dynamic import() which is available in all CommonJS modules

Invalid CSS value error while Customizing Bootstrap 5 colors with sass 3

How do I resolve error message: &quot;Inheritance from an interface with '@JvmDefault' members is only allowed with -Xjvm-default option&quot;

Why does this Cairo program put powers of 2 in the memory?

Android sdkmanager not found. Update to the latest Android SDK and ensure that the cmdline-tools are installed to resolve this

TypeError: load() missing 1 required positional argument: 'Loader' in Google Colab

How can I configure Hardhat to work with RSK regtest blockchain?

Flutter (2.5) - A splash screen was provided to Flutter, but this is deprecated

What to use instead of TaskException for ReviewManager Api?

FirebaseOptions cannot be null when creating the default app

QUESTION

Instead change the require of index.js, to a dynamic import() which is available in all CommonJS modules

Asked 2022-Apr-05 at 06:25

Trying to work with node/javascript/nfts, I am a noob and followed along a tutorial, but I get this error:

1error [ERR_REQUIRE_ESM]: require() of ES Module [...] is not supported. Instead change the require of index.js [ in my file...]  to a dynamic import() which is available in all CommonJS modules
2

My understanding is that they've updated the node file, so i need a different code than that in the tutorial, but i don't know which one I'm supposed to change, where and to what. Please be as specific as you can

1error [ERR_REQUIRE_ESM]: require() of ES Module [...] is not supported. Instead change the require of index.js [ in my file...]  to a dynamic import() which is available in all CommonJS modules
2const FormData = require('form-data');
3const fetch = require('node-fetch');
4const path = require(&quot;path&quot;)
5const basePath = process.cwd();
6const fs = require(&quot;fs&quot;);
7
8fs.readdirSync(`${basePath}/build/images`).foreach(file).forEach(file =&gt; {
9    const formData = new FormData();
10    const fileStream = fs.createReadStream(`${basePath}/build/images/${file}`);
11    formData.append('file',fileStream);
12
13    let url = 'https://api.nftport.xyz/v0/files';
14
15    let options = {
16      method: 'POST',
17      headers: {
18        Authorization: '[...]',
19      },
20      body: formData
21    };
22    
23    fetch(url, options)
24      .then(res =&gt; res.json())
25      .then(json =&gt; {
26       const fileName = path.parse(json.file_name).name;
27       let rawdata = fs.readFileSync(`${basePath}/build/json/${fileName}.json`);
28       let metaData = JSON.parse(rawdata);
29
30       metaData.file_url = json.ipfs_url;
31
32       fs.writeFileSync(`${basePath}/build/json${fileName}.json`, JSON.stringify(metaData, null, 2));
33
34       console.log(`${json.file_name} uploaded &amp; ${fileName}.json updated!`);
35      })
36      .catch(err =&gt; console.error('error:' + err));
37})
38
39

ANSWER

Answered 2021-Dec-31 at 10:07

It is because of the node-fetch package. As recent versions of this package only support ESM, you have to downgrade it to an older version node-fetch@2.6.1 or lower.

npm i node-fetch@2.6.1

This should solve the issue.

Source https://stackoverflow.com/questions/70541068

QUESTION

Invalid CSS value error while Customizing Bootstrap 5 colors with sass 3

Asked 2022-Mar-22 at 12:49

I want to change bootstrap's default theme-colors with SASS , the problem is when I change a color and compile , it gives me invalid CSS value error.

I've read the docs and saw some tutorials on YouTube but I can't see where is the problem

I'm using bootstrap 5.1.0 , sass 3 this is my scss file:

1@import &quot;../../node_modules/bootstrap/scss/variables&quot;;
2
3$theme-colors: (
4&quot;primary&quot;: //some color here,
5);
6
7@import &quot;../../node_modules/bootstrap/scss/bootstrap&quot;;
8

and this is the error I get in terminal

1@import &quot;../../node_modules/bootstrap/scss/variables&quot;;
2
3$theme-colors: (
4&quot;primary&quot;: //some color here,
5);
6
7@import &quot;../../node_modules/bootstrap/scss/bootstrap&quot;;
8PS F:\Coding\projects\sepehr\client\src\styles&gt; sass style.scss custom.css
9Error: (&quot;primary&quot;: #0d6efd, &quot;secondary&quot;: #6c757d, &quot;success&quot;: #198754, &quot;info&quot;: #0dcaf0, 
10&quot;warning&quot;: #ffc107, &quot;danger&quot;: #dc3545, &quot;light&quot;: #f8f9fa, &quot;dark&quot;: #212529) isn't a valid 
11CSS value.
121394 │ $theme-colors-rgb: map-loop($theme-colors, to-rgb, &quot;$value&quot;) !default;
14   │                             ^^^^^^^^^^^^^
1516

ANSWER

Answered 2021-Aug-24 at 14:36

You need to import functions and mixins too...

1@import &quot;../../node_modules/bootstrap/scss/variables&quot;;
2
3$theme-colors: (
4&quot;primary&quot;: //some color here,
5);
6
7@import &quot;../../node_modules/bootstrap/scss/bootstrap&quot;;
8PS F:\Coding\projects\sepehr\client\src\styles&gt; sass style.scss custom.css
9Error: (&quot;primary&quot;: #0d6efd, &quot;secondary&quot;: #6c757d, &quot;success&quot;: #198754, &quot;info&quot;: #0dcaf0, 
10&quot;warning&quot;: #ffc107, &quot;danger&quot;: #dc3545, &quot;light&quot;: #f8f9fa, &quot;dark&quot;: #212529) isn't a valid 
11CSS value.
121394 │ $theme-colors-rgb: map-loop($theme-colors, to-rgb, &quot;$value&quot;) !default;
14   │                             ^^^^^^^^^^^^^
1516@import &quot;../../node_modules/bootstrap/scss/functions&quot;;
17@import &quot;../../node_modules/bootstrap/scss/variables&quot;;
18@import &quot;../../node_modules/bootstrap/scss/mixins&quot;;
19

Source https://stackoverflow.com/questions/68909199

QUESTION

How do I resolve error message: &quot;Inheritance from an interface with '@JvmDefault' members is only allowed with -Xjvm-default option&quot;

Asked 2022-Mar-19 at 21:08

I'm new to Android development and I'm currently building my first real app. I'm trying to implement a MVVM architecture and because of that I'm having a viewModel for each fragment and each viewModel has a viewModelFactory. At least, this is how I understood it has to be.

I use the boilerplate code everyone seems to use for the factory:

1class ExampleViewModelFactory(private val exampleDao: ExampleDao) : ViewModelProvider.Factory {
2    override fun &lt;T : ViewModel&gt; create(modelClass: Class&lt;T&gt;): T {
3        if (modelClass.isAssignableFrom(exampleViewModel::class.java)) {
4            @Suppress(&quot;UNCHECKED_CAST&quot;)
5            return ExampleViewModel(exampleDao) as T
6        }
7        throw IllegalArgumentException(&quot;Unknown ViewModel class&quot;)
8    }
9}
10

Now the problem is, that the compiler is giving me the following error:

e: C:\Users\ ...\ExampleViewModel.kt: (64, 7): Inheritance from an interface with '@JvmDefault' members is only allowed with -Xjvm-default option

And this error is produced by the viewModelFactory class I have implemented in the viewModel. I really can't tell what this means and I cant find anything helpful or even related to my specific problem. I basically followed some basic tutorials about creating your first app, but I keep on running into errors like this. In most cases, I was able to fix the problem by myself, but this time it's different.

I know that a lot of you have a lot of experience and knowledge, so I hope that some of you find the time to help me and give me a hint what I can do to fix this.

ANSWER

Answered 2022-Feb-25 at 16:53

It seems like you are either directly or indirectly (through some other library) depending on Lifecycle 2.5.0-alpha01.

As per this issue:

You need to temporarily add following to your build.gradle:

1class ExampleViewModelFactory(private val exampleDao: ExampleDao) : ViewModelProvider.Factory {
2    override fun &lt;T : ViewModel&gt; create(modelClass: Class&lt;T&gt;): T {
3        if (modelClass.isAssignableFrom(exampleViewModel::class.java)) {
4            @Suppress(&quot;UNCHECKED_CAST&quot;)
5            return ExampleViewModel(exampleDao) as T
6        }
7        throw IllegalArgumentException(&quot;Unknown ViewModel class&quot;)
8    }
9}
10tasks.withType(KotlinCompile).configureEach {
11    kotlinOptions {
12        freeCompilerArgs += [
13                &quot;-Xjvm-default=all&quot;,
14        ]
15    }
16}
17

Note that in certain circumstances you may want to use all-compatibility instead of all, learn more about that in Jebrain's blogpost.

Starting with kotlin 1.6.20 you won't need touch build.gradle for more information see KT-47000

Source https://stackoverflow.com/questions/70992947

QUESTION

Why does this Cairo program put powers of 2 in the memory?

Asked 2022-Mar-17 at 18:03

I'm trying to solve this bonus question from the "How Cairo Works" tutorial. I ran the following function, opened the Cairo tracer and saw that the memory is full with powers of 2. Why is that?

1func main():
2    [fp + 1] = 2; ap++
3    [fp] = 5201798304953761792; ap++
4    jmp rel -1
5end
6

enter image description here

ANSWER

Answered 2022-Mar-17 at 15:43

Here are some leading questions that can help you reach the answer. Answers to the questions after a break:

  1. Where does the jmp rel -1 instruction jump to?
  2. What does the target instruction do? What happens after it?
  3. How did this instruction end up in the program section of the memory?

  1. jmp rel -1 is encoded in the memory at addresses 5-6. When it is executed, we have pc = 5, thus after the jump we will execute the instruction at pc = 4, which is 0x48307fff7fff8000.
  2. This bytecode encodes the instruction [ap] = [ap - 1] + [ap - 1]; ap++ (to check, you can manually decode the flags and offsets, or simply write a cairo program with this instruction and see what it compiles to). After it is executed, pc is increased by 1, so we again execute jmp rel -1, and so on in an infinite loop. It should be clear why this fills the memory with powers of 2 (the first 2, at address 10, was written by the [fp + 1] = 2; ap++ instruction).
  3. The instruction [fp] = 5201798304953761792; ap++ has an immediate argument (the right hand side, 5201798304953761792). Instructions with immediate arguments are encoded as two field elements in the memory, the first encoding the general instruction (e.g. [fp] = imm; ap++), and the second being the immediate value itself. This immediate value is thus written in address 4, and indeed 5201798304953761792 is the same as 0x48307fff7fff8000. Similarly, the 2 at address 2 is the immediate argument of the instruction [fp + 1] = 2, and the -1 at address 6 is the immediate of jmp rel -1.

To summarize, this strange behavior is due to the relative jump moving to an address of an immediate value and parsing it as a standalone instruction. Normally this wouldn't occur, since pc is incremented by 2 after executing an instruction with an immediate value, and by 1 when executing an instruction without one, so it always continues to the next compiled instruction. The unlabeled jump was necessary here to reach this unexpected program counter.

Source https://stackoverflow.com/questions/71500794

QUESTION

Android sdkmanager not found. Update to the latest Android SDK and ensure that the cmdline-tools are installed to resolve this

Asked 2022-Mar-09 at 06:57

I was following a tutorial to install an android emulator, without android studio, and I was told to run the command- flutter doctor. Upon running this, I got this error-

1X Android license status unknown.
2      Run `flutter doctor --android-licenses` to accept the SDK licenses.
3

So I tried running flutter doctor --android-licenses, and I got this error-

1X Android license status unknown.
2      Run `flutter doctor --android-licenses` to accept the SDK licenses.
3Android sdkmanager not found. Update to the latest Android SDK and ensure that the cmdline-tools are installed to
4resolve this.
5

This is my ANDROID_HOME directory-

enter image description here

And Inside platforms, I have android-32 installed.

I saw some fixes for this, but those were all with android studio. How do I fix this? Thanks in advance!

ANSWER

Answered 2022-Jan-15 at 08:41

I think you need to install cmdLine

please run flutter doctor and share cmd results to help better

Source https://stackoverflow.com/questions/70719767

QUESTION

TypeError: load() missing 1 required positional argument: 'Loader' in Google Colab

Asked 2022-Mar-04 at 11:01

I am trying to do a regular import in Google Colab.
This import worked up until now.
If I try:

1import plotly.express as px
2

or

1import plotly.express as px
2import pingouin as pg
3

I get an error:

1import plotly.express as px
2import pingouin as pg
3---------------------------------------------------------------------------
4TypeError                                 Traceback (most recent call last)
5&lt;ipython-input-19-86e89bd44552&gt; in &lt;module&gt;()
6----&gt; 1 import plotly.express as px
7
89 frames
9/usr/local/lib/python3.7/dist-packages/plotly/express/__init__.py in &lt;module&gt;()
10     13     )
11     14 
12---&gt; 15 from ._imshow import imshow
13     16 from ._chart_types import (  # noqa: F401
14     17     scatter,
15
16/usr/local/lib/python3.7/dist-packages/plotly/express/_imshow.py in &lt;module&gt;()
17      9 
18     10 try:
19---&gt; 11     import xarray
20     12 
21     13     xarray_imported = True
22
23/usr/local/lib/python3.7/dist-packages/xarray/__init__.py in &lt;module&gt;()
24      1 import pkg_resources
25      2 
26----&gt; 3 from . import testing, tutorial, ufuncs
27      4 from .backends.api import (
28      5     load_dataarray,
29
30/usr/local/lib/python3.7/dist-packages/xarray/tutorial.py in &lt;module&gt;()
31     11 import numpy as np
32     12 
33---&gt; 13 from .backends.api import open_dataset as _open_dataset
34     14 from .backends.rasterio_ import open_rasterio as _open_rasterio
35     15 from .core.dataarray import DataArray
36
37/usr/local/lib/python3.7/dist-packages/xarray/backends/__init__.py in &lt;module&gt;()
38      4 formats. They should not be used directly, but rather through Dataset objects.
39      5 
40----&gt; 6 from .cfgrib_ import CfGribDataStore
41      7 from .common import AbstractDataStore, BackendArray, BackendEntrypoint
42      8 from .file_manager import CachingFileManager, DummyFileManager, FileManager
43
44/usr/local/lib/python3.7/dist-packages/xarray/backends/cfgrib_.py in &lt;module&gt;()
45     14     _normalize_path,
46     15 )
47---&gt; 16 from .locks import SerializableLock, ensure_lock
48     17 from .store import StoreBackendEntrypoint
49     18 
50
51/usr/local/lib/python3.7/dist-packages/xarray/backends/locks.py in &lt;module&gt;()
52     11 
53     12 try:
54---&gt; 13     from dask.distributed import Lock as DistributedLock
55     14 except ImportError:
56     15     DistributedLock = None
57
58/usr/local/lib/python3.7/dist-packages/dask/distributed.py in &lt;module&gt;()
59      1 # flake8: noqa
60      2 try:
61----&gt; 3     from distributed import *
62      4 except ImportError:
63      5     msg = (
64
65/usr/local/lib/python3.7/dist-packages/distributed/__init__.py in &lt;module&gt;()
66      1 from __future__ import print_function, division, absolute_import
67      2 
68----&gt; 3 from . import config
69      4 from dask.config import config
70      5 from .actor import Actor, ActorFuture
71
72/usr/local/lib/python3.7/dist-packages/distributed/config.py in &lt;module&gt;()
73     18 
74     19 with open(fn) as f:
75---&gt; 20     defaults = yaml.load(f)
76     21 
77     22 dask.config.update_defaults(defaults)
78
79TypeError: load() missing 1 required positional argument: 'Loader'
80

I think it might be a problem with Google Colab or some basic utility package that has been updated, but I can not find a way to solve it.

ANSWER

Answered 2021-Oct-15 at 21:11

Found the problem.
I was installing pandas_profiling, and this package updated pyyaml to version 6.0 which is not compatible with the current way Google Colab imports packages.
So just reverting back to pyyaml version 5.4.1 solved the problem.

For more information check versions of pyyaml here.
See this issue and formal answers in GitHub

##################################################################
For reverting back to pyyaml version 5.4.1 in your code, add the next line at the end of your packages installations:

1import plotly.express as px
2import pingouin as pg
3---------------------------------------------------------------------------
4TypeError                                 Traceback (most recent call last)
5&lt;ipython-input-19-86e89bd44552&gt; in &lt;module&gt;()
6----&gt; 1 import plotly.express as px
7
89 frames
9/usr/local/lib/python3.7/dist-packages/plotly/express/__init__.py in &lt;module&gt;()
10     13     )
11     14 
12---&gt; 15 from ._imshow import imshow
13     16 from ._chart_types import (  # noqa: F401
14     17     scatter,
15
16/usr/local/lib/python3.7/dist-packages/plotly/express/_imshow.py in &lt;module&gt;()
17      9 
18     10 try:
19---&gt; 11     import xarray
20     12 
21     13     xarray_imported = True
22
23/usr/local/lib/python3.7/dist-packages/xarray/__init__.py in &lt;module&gt;()
24      1 import pkg_resources
25      2 
26----&gt; 3 from . import testing, tutorial, ufuncs
27      4 from .backends.api import (
28      5     load_dataarray,
29
30/usr/local/lib/python3.7/dist-packages/xarray/tutorial.py in &lt;module&gt;()
31     11 import numpy as np
32     12 
33---&gt; 13 from .backends.api import open_dataset as _open_dataset
34     14 from .backends.rasterio_ import open_rasterio as _open_rasterio
35     15 from .core.dataarray import DataArray
36
37/usr/local/lib/python3.7/dist-packages/xarray/backends/__init__.py in &lt;module&gt;()
38      4 formats. They should not be used directly, but rather through Dataset objects.
39      5 
40----&gt; 6 from .cfgrib_ import CfGribDataStore
41      7 from .common import AbstractDataStore, BackendArray, BackendEntrypoint
42      8 from .file_manager import CachingFileManager, DummyFileManager, FileManager
43
44/usr/local/lib/python3.7/dist-packages/xarray/backends/cfgrib_.py in &lt;module&gt;()
45     14     _normalize_path,
46     15 )
47---&gt; 16 from .locks import SerializableLock, ensure_lock
48     17 from .store import StoreBackendEntrypoint
49     18 
50
51/usr/local/lib/python3.7/dist-packages/xarray/backends/locks.py in &lt;module&gt;()
52     11 
53     12 try:
54---&gt; 13     from dask.distributed import Lock as DistributedLock
55     14 except ImportError:
56     15     DistributedLock = None
57
58/usr/local/lib/python3.7/dist-packages/dask/distributed.py in &lt;module&gt;()
59      1 # flake8: noqa
60      2 try:
61----&gt; 3     from distributed import *
62      4 except ImportError:
63      5     msg = (
64
65/usr/local/lib/python3.7/dist-packages/distributed/__init__.py in &lt;module&gt;()
66      1 from __future__ import print_function, division, absolute_import
67      2 
68----&gt; 3 from . import config
69      4 from dask.config import config
70      5 from .actor import Actor, ActorFuture
71
72/usr/local/lib/python3.7/dist-packages/distributed/config.py in &lt;module&gt;()
73     18 
74     19 with open(fn) as f:
75---&gt; 20     defaults = yaml.load(f)
76     21 
77     22 dask.config.update_defaults(defaults)
78
79TypeError: load() missing 1 required positional argument: 'Loader'
80!pip install pyyaml==5.4.1
81

It is important to put it at the end of the installation, some of the installations will change the pyyaml version.

Source https://stackoverflow.com/questions/69564817

QUESTION

How can I configure Hardhat to work with RSK regtest blockchain?

Asked 2022-Jan-20 at 08:01

I intend to develop my smart contracts in Hardhat, and to test them on RSK regtest local node. I was able to find a Truffle regtest configuration.

1development: {
2  host: &quot;127.0.0.1&quot;,
3  port: 4444,
4  network_id: &quot;*&quot;
5},
6

What hardhat.config.js configuration do I need to run my tests on RSK regtest?

ANSWER

Answered 2022-Jan-20 at 08:01

To deploy and test your smart contracts on RSK regtest yourhardhat.config.js should look as follows:

1development: {
2  host: &quot;127.0.0.1&quot;,
3  port: 4444,
4  network_id: &quot;*&quot;
5},
6/**
7 * @type import('hardhat/config').HardhatUserConfig
8 */
9require(&quot;@nomiclabs/hardhat-waffle&quot;);
10
11module.exports = {
12  solidity: &quot;0.7.3&quot;,
13  defaultNetwork: &quot;rskregtest&quot;,
14  networks: {
15    rskregtest: {
16      url: &quot;http://localhost:4444/&quot;,
17    },
18  },
19};
20

Then you'll be able to run your tests by typing in the terminal

1development: {
2  host: &quot;127.0.0.1&quot;,
3  port: 4444,
4  network_id: &quot;*&quot;
5},
6/**
7 * @type import('hardhat/config').HardhatUserConfig
8 */
9require(&quot;@nomiclabs/hardhat-waffle&quot;);
10
11module.exports = {
12  solidity: &quot;0.7.3&quot;,
13  defaultNetwork: &quot;rskregtest&quot;,
14  networks: {
15    rskregtest: {
16      url: &quot;http://localhost:4444/&quot;,
17    },
18  },
19};
20% npx hardhat test
21

Source https://stackoverflow.com/questions/70782281

QUESTION

Flutter (2.5) - A splash screen was provided to Flutter, but this is deprecated

Asked 2022-Jan-19 at 05:24

I am new to flutter and recently tried to develop a test app for learning sake with latest version Flutter 2.5. By looking at some tutorial online, I have added flutter_native_splash: ^1.2.3 package for splash screen. And works fine.

However, when I launch app for the first time, it shows following debug message

W/FlutterActivityAndFragmentDelegate(18569): A splash screen was provided to Flutter, but this is deprecated. See flutter.dev/go/android-splash-migration for migration steps.

After visiting the above link, I am not able to understand much what is supposed to be done.

Code in pubspec.yaml

1flutter_native_splash:
2  color: &quot;#FFFFFF&quot;
3  color_dark: &quot;#000000&quot;
4  image: assets/images/splash_720.png
5  android: true
6  ios: true
7  android12: true
8

Also, compileSdkVersion and targetSdkVersion is set to 31 in build.gradle

Please help. Thanks in advance.

ANSWER

Answered 2022-Jan-19 at 05:24
To avoid that warning you just need to remove that API usage from your project. Remove these lines of code from the AndroidManifest.xml file.

Remove these lines of code

Previously, Android Flutter apps would either set io.flutter.embedding.android.SplashScreenDrawable in their application manifest, or implement provideSplashScreen within their Flutter Activity. This would be shown momentarily in between the time after the Android launch screen is shown and when Flutter has drawn the first frame. This is no longer needed and is deprecated – Flutter now automatically keeps the Android launch screen displayed until Flutter has drawn the first frame. Developers should instead remove the usage of these APIs. - source



UPDATE (FLUTTER 2.8.0)

As per the flutter 2.8.0 update, The newly created project doesn't have this warning.

They removed unused API from Androidmanifest.yml but still have belove mentioned code.

They still have these lines of code

Source https://stackoverflow.com/questions/69232006

QUESTION

What to use instead of TaskException for ReviewManager Api?

Asked 2022-Jan-11 at 08:45

Trying to follow the google tutorial for in-app reviews and I'm currently stuck with the following piece of code:

1val request = manager.requestReviewFlow()
2request.addOnCompleteListener { task -&gt;
3    if (task.isSuccessful) {
4        // We got the ReviewInfo object
5        val reviewInfo = task.result
6    } else {
7        // There was some problem, log or handle the error code.
8        @ReviewErrorCode val reviewErrorCode = (task.getException() as TaskException).errorCode
9    }
10}
11

When I copy this into my IDE, it doesn't seem to pick up the TaskException. What could I rather use here as an alternative ?

I've added:

1val request = manager.requestReviewFlow()
2request.addOnCompleteListener { task -&gt;
3    if (task.isSuccessful) {
4        // We got the ReviewInfo object
5        val reviewInfo = task.result
6    } else {
7        // There was some problem, log or handle the error code.
8        @ReviewErrorCode val reviewErrorCode = (task.getException() as TaskException).errorCode
9    }
10}
11implementation 'com.google.android.play:core:1.10.0'
12implementation 'com.google.android.play:core-ktx:1.8.1'
13

ANSWER

Answered 2022-Jan-11 at 08:45

I think the documentation has a typo.

The correct exception cast should be this RuntimeExecutionException

I've opened a documentation issue about this


UPDATE: 11/01/2022 (dd/MM/yyyy)

Upgrading your play:core dependency to at least version 1.10.1 will bring you a new custom ReviewException which should replace the RuntimeExecutionException (or at least this is what we think).

Without an official answer the current safest solution is probably the one below:

1val request = manager.requestReviewFlow()
2request.addOnCompleteListener { task -&gt;
3    if (task.isSuccessful) {
4        // We got the ReviewInfo object
5        val reviewInfo = task.result
6    } else {
7        // There was some problem, log or handle the error code.
8        @ReviewErrorCode val reviewErrorCode = (task.getException() as TaskException).errorCode
9    }
10}
11implementation 'com.google.android.play:core:1.10.0'
12implementation 'com.google.android.play:core-ktx:1.8.1'
13val errorCode = when (val exception = task.exception) {
14    is ReviewException -&gt; {
15        exception.errorCode
16    }
17    is RuntimeExecutionException -&gt; {
18        exception.errorCode
19    }
20    else -&gt; {
21        9999
22    }
23}
24

You can use any value in place of 9999 but it is probably better if the integer is not already defined as error code in https://developers.google.com/android/reference/com/google/android/gms/common/api/CommonStatusCodes just to avoid confusion

Source https://stackoverflow.com/questions/68526347

QUESTION

FirebaseOptions cannot be null when creating the default app

Asked 2021-Dec-25 at 09:13

I am trying to try a sample project in Flutter integration email and google based login, and planning to use firebase initialisation for doing it while I have followed all the steps as mentioned in tutorials I am getting this error as soon as firebase is attempted to be initialised.

1&quot;FirebaseOptions cannot be null when creating the default app.&quot;
2    at Object.throw_ [as throw] (http://localhost:7357/dart_sdk.js:5063:11)
3    at Object.assertFailed (http://localhost:7357/dart_sdk.js:4988:15)
4at firebase_core_web.FirebaseCoreWeb.new.initializeApp (http://localhost:7357/packages/firebase_core_web/firebase_core_web.dart.lib.js:252:42)
5    at initializeApp.next (&lt;anonymous&gt;)
6    at http://localhost:7357/dart_sdk.js:40192:33
7    at _RootZone.runUnary (http://localhost:7357/dart_sdk.js:40062:59)
8    at _FutureListener.thenAwait.handleValue (http://localhost:7357/dart_sdk.js:34983:29)
9    at handleValueCallback (http://localhost:7357/dart_sdk.js:35551:49)
10    at Function._propagateToListeners (http://localhost:7357/dart_sdk.js:35589:17)
11    at _Future.new.[_completeWithValue] (http://localhost:7357/dart_sdk.js:35437:23)
12    at async._AsyncCallbackEntry.new.callback (http://localhost:7357/dart_sdk.js:35458:35)
13    at Object._microtaskLoop (http://localhost:7357/dart_sdk.js:40330:13)
14    at _startMicrotaskLoop (http://localhost:7357/dart_sdk.js:40336:13)
15    at http://localhost:7357/dart_sdk.js:35811:9
16

Here is my index.html

1&quot;FirebaseOptions cannot be null when creating the default app.&quot;
2    at Object.throw_ [as throw] (http://localhost:7357/dart_sdk.js:5063:11)
3    at Object.assertFailed (http://localhost:7357/dart_sdk.js:4988:15)
4at firebase_core_web.FirebaseCoreWeb.new.initializeApp (http://localhost:7357/packages/firebase_core_web/firebase_core_web.dart.lib.js:252:42)
5    at initializeApp.next (&lt;anonymous&gt;)
6    at http://localhost:7357/dart_sdk.js:40192:33
7    at _RootZone.runUnary (http://localhost:7357/dart_sdk.js:40062:59)
8    at _FutureListener.thenAwait.handleValue (http://localhost:7357/dart_sdk.js:34983:29)
9    at handleValueCallback (http://localhost:7357/dart_sdk.js:35551:49)
10    at Function._propagateToListeners (http://localhost:7357/dart_sdk.js:35589:17)
11    at _Future.new.[_completeWithValue] (http://localhost:7357/dart_sdk.js:35437:23)
12    at async._AsyncCallbackEntry.new.callback (http://localhost:7357/dart_sdk.js:35458:35)
13    at Object._microtaskLoop (http://localhost:7357/dart_sdk.js:40330:13)
14    at _startMicrotaskLoop (http://localhost:7357/dart_sdk.js:40336:13)
15    at http://localhost:7357/dart_sdk.js:35811:9
16&lt;!DOCTYPE html&gt;
17&lt;html&gt;
18&lt;head&gt;
19  &lt;!--
20    If you are serving your web app in a path other than the root, change the
21    href value below to reflect the base path you are serving from.
22
23    The path provided below has to start and end with a slash &quot;/&quot; in order for
24    it to work correctly.
25
26    For more details:
27    * https://developer.mozilla.org/en-US/docs/Web/HTML/Element/base
28
29    This is a placeholder for base href that will be replaced by the value of
30    the `--base-href` argument provided to `flutter build`.
31  --&gt;
32  &lt;base href=&quot;$FLUTTER_BASE_HREF&quot;&gt;
33
34  &lt;meta charset=&quot;UTF-8&quot;&gt;
35  &lt;meta content=&quot;IE=Edge&quot; http-equiv=&quot;X-UA-Compatible&quot;&gt;
36  &lt;meta name=&quot;description&quot; content=&quot;A new Flutter project.&quot;&gt;
37  &lt;meta name=&quot;google-signin-client_id&quot; content=&quot;619218114547-xxxx.apps.googleusercontent.com&quot;&gt;
38  &lt;!-- iOS meta tags &amp; icons --&gt;
39  &lt;meta name=&quot;apple-mobile-web-app-capable&quot; content=&quot;yes&quot;&gt;
40  &lt;meta name=&quot;apple-mobile-web-app-status-bar-style&quot; content=&quot;black&quot;&gt;
41  &lt;meta name=&quot;apple-mobile-web-app-title&quot; content=&quot;signin_example&quot;&gt;
42  &lt;link rel=&quot;apple-touch-icon&quot; href=&quot;icons/Icon-192.png&quot;&gt;
43  
44  &lt;!-- Favicon --&gt;
45  &lt;link rel=&quot;icon&quot; type=&quot;image/png&quot; href=&quot;favicon.png&quot;/&gt;
46
47  &lt;title&gt;signin_example&lt;/title&gt;
48  &lt;link rel=&quot;manifest&quot; href=&quot;manifest.json&quot;&gt;
49&lt;/head&gt;
50&lt;body&gt;
51  &lt;!-- This script installs service_worker.js to provide PWA functionality to
52       application. For more information, see:
53       https://developers.google.com/web/fundamentals/primers/service-workers --&gt;
54  
55  
56  &lt;script&gt;
57    var serviceWorkerVersion = null;
58    var scriptLoaded = false;
59    function loadMainDartJs() {
60      if (scriptLoaded) {
61        return;
62      }
63      scriptLoaded = true;
64      var scriptTag = document.createElement('script');
65      scriptTag.src = 'main.dart.js';
66      scriptTag.type = 'application/javascript';
67      document.body.append(scriptTag);
68    }
69
70    if ('serviceWorker' in navigator) {
71      // Service workers are supported. Use them.
72      window.addEventListener('load', function () {
73        // Wait for registration to finish before dropping the &lt;script&gt; tag.
74        // Otherwise, the browser will load the script multiple times,
75        // potentially different versions.
76        var serviceWorkerUrl = 'flutter_service_worker.js?v=' + serviceWorkerVersion;
77        navigator.serviceWorker.register(serviceWorkerUrl)
78          .then((reg) =&gt; {
79            function waitForActivation(serviceWorker) {
80              serviceWorker.addEventListener('statechange', () =&gt; {
81                if (serviceWorker.state == 'activated') {
82                  console.log('Installed new service worker.');
83                  loadMainDartJs();
84                }
85              });
86            }
87            if (!reg.active &amp;&amp; (reg.installing || reg.waiting)) {
88              // No active web worker and we have installed or are installing
89              // one for the first time. Simply wait for it to activate.
90              waitForActivation(reg.installing || reg.waiting);
91            } else if (!reg.active.scriptURL.endsWith(serviceWorkerVersion)) {
92              // When the app updates the serviceWorkerVersion changes, so we
93              // need to ask the service worker to update.
94              console.log('New service worker available.');
95              reg.update();
96              waitForActivation(reg.installing);
97            } else {
98              // Existing service worker is still good.
99              console.log('Loading app from service worker.');
100              loadMainDartJs();
101            }
102          });
103
104        // If service worker doesn't succeed in a reasonable amount of time,
105        // fallback to plaint &lt;script&gt; tag.
106        setTimeout(() =&gt; {
107          if (!scriptLoaded) {
108            console.warn(
109              'Failed to load app from service worker. Falling back to plain &lt;script&gt; tag.',
110            );
111            loadMainDartJs();
112          }
113        }, 4000);
114      });
115    } else {
116      // Service workers not supported. Just drop the &lt;script&gt; tag.
117      loadMainDartJs();
118    }
119  &lt;/script&gt;
120  &lt;script type=&quot;module&quot;&gt;
121    // Import the functions you need from the SDKs you need
122    import { initializeApp } from &quot;https://www.gstatic.com/firebasejs/9.6.0/firebase-app.js&quot;;
123    import { getAnalytics } from &quot;https://www.gstatic.com/firebasejs/9.6.0/firebase-analytics.js&quot;;
124    // TODO: Add SDKs for Firebase products that you want to use
125    // https://firebase.google.com/docs/web/setup#available-libraries
126
127    // Your web app's Firebase configuration
128    // For Firebase JS SDK v7.20.0 and later, measurementId is optional
129    const firebaseConfig = {
130      apiKey: &quot;xxx&quot;,
131      authDomain: &quot;xxx&quot;,
132      projectId: &quot;xx&quot;,
133      storageBucket: &quot;exxx&quot;,
134      messagingSenderId: &quot;xxx&quot;,
135      appId: &quot;xxx&quot;,
136      measurementId: &quot;xxx&quot;
137    };
138
139    // Initialize Firebase
140    const app = initializeApp(firebaseConfig);
141    const analytics = getAnalytics(app);
142  &lt;/script&gt;
143&lt;/body&gt;
144&lt;/html&gt;
145

Part of code from main.dart file where firebase initialisation is happening

1&quot;FirebaseOptions cannot be null when creating the default app.&quot;
2    at Object.throw_ [as throw] (http://localhost:7357/dart_sdk.js:5063:11)
3    at Object.assertFailed (http://localhost:7357/dart_sdk.js:4988:15)
4at firebase_core_web.FirebaseCoreWeb.new.initializeApp (http://localhost:7357/packages/firebase_core_web/firebase_core_web.dart.lib.js:252:42)
5    at initializeApp.next (&lt;anonymous&gt;)
6    at http://localhost:7357/dart_sdk.js:40192:33
7    at _RootZone.runUnary (http://localhost:7357/dart_sdk.js:40062:59)
8    at _FutureListener.thenAwait.handleValue (http://localhost:7357/dart_sdk.js:34983:29)
9    at handleValueCallback (http://localhost:7357/dart_sdk.js:35551:49)
10    at Function._propagateToListeners (http://localhost:7357/dart_sdk.js:35589:17)
11    at _Future.new.[_completeWithValue] (http://localhost:7357/dart_sdk.js:35437:23)
12    at async._AsyncCallbackEntry.new.callback (http://localhost:7357/dart_sdk.js:35458:35)
13    at Object._microtaskLoop (http://localhost:7357/dart_sdk.js:40330:13)
14    at _startMicrotaskLoop (http://localhost:7357/dart_sdk.js:40336:13)
15    at http://localhost:7357/dart_sdk.js:35811:9
16&lt;!DOCTYPE html&gt;
17&lt;html&gt;
18&lt;head&gt;
19  &lt;!--
20    If you are serving your web app in a path other than the root, change the
21    href value below to reflect the base path you are serving from.
22
23    The path provided below has to start and end with a slash &quot;/&quot; in order for
24    it to work correctly.
25
26    For more details:
27    * https://developer.mozilla.org/en-US/docs/Web/HTML/Element/base
28
29    This is a placeholder for base href that will be replaced by the value of
30    the `--base-href` argument provided to `flutter build`.
31  --&gt;
32  &lt;base href=&quot;$FLUTTER_BASE_HREF&quot;&gt;
33
34  &lt;meta charset=&quot;UTF-8&quot;&gt;
35  &lt;meta content=&quot;IE=Edge&quot; http-equiv=&quot;X-UA-Compatible&quot;&gt;
36  &lt;meta name=&quot;description&quot; content=&quot;A new Flutter project.&quot;&gt;
37  &lt;meta name=&quot;google-signin-client_id&quot; content=&quot;619218114547-xxxx.apps.googleusercontent.com&quot;&gt;
38  &lt;!-- iOS meta tags &amp; icons --&gt;
39  &lt;meta name=&quot;apple-mobile-web-app-capable&quot; content=&quot;yes&quot;&gt;
40  &lt;meta name=&quot;apple-mobile-web-app-status-bar-style&quot; content=&quot;black&quot;&gt;
41  &lt;meta name=&quot;apple-mobile-web-app-title&quot; content=&quot;signin_example&quot;&gt;
42  &lt;link rel=&quot;apple-touch-icon&quot; href=&quot;icons/Icon-192.png&quot;&gt;
43  
44  &lt;!-- Favicon --&gt;
45  &lt;link rel=&quot;icon&quot; type=&quot;image/png&quot; href=&quot;favicon.png&quot;/&gt;
46
47  &lt;title&gt;signin_example&lt;/title&gt;
48  &lt;link rel=&quot;manifest&quot; href=&quot;manifest.json&quot;&gt;
49&lt;/head&gt;
50&lt;body&gt;
51  &lt;!-- This script installs service_worker.js to provide PWA functionality to
52       application. For more information, see:
53       https://developers.google.com/web/fundamentals/primers/service-workers --&gt;
54  
55  
56  &lt;script&gt;
57    var serviceWorkerVersion = null;
58    var scriptLoaded = false;
59    function loadMainDartJs() {
60      if (scriptLoaded) {
61        return;
62      }
63      scriptLoaded = true;
64      var scriptTag = document.createElement('script');
65      scriptTag.src = 'main.dart.js';
66      scriptTag.type = 'application/javascript';
67      document.body.append(scriptTag);
68    }
69
70    if ('serviceWorker' in navigator) {
71      // Service workers are supported. Use them.
72      window.addEventListener('load', function () {
73        // Wait for registration to finish before dropping the &lt;script&gt; tag.
74        // Otherwise, the browser will load the script multiple times,
75        // potentially different versions.
76        var serviceWorkerUrl = 'flutter_service_worker.js?v=' + serviceWorkerVersion;
77        navigator.serviceWorker.register(serviceWorkerUrl)
78          .then((reg) =&gt; {
79            function waitForActivation(serviceWorker) {
80              serviceWorker.addEventListener('statechange', () =&gt; {
81                if (serviceWorker.state == 'activated') {
82                  console.log('Installed new service worker.');
83                  loadMainDartJs();
84                }
85              });
86            }
87            if (!reg.active &amp;&amp; (reg.installing || reg.waiting)) {
88              // No active web worker and we have installed or are installing
89              // one for the first time. Simply wait for it to activate.
90              waitForActivation(reg.installing || reg.waiting);
91            } else if (!reg.active.scriptURL.endsWith(serviceWorkerVersion)) {
92              // When the app updates the serviceWorkerVersion changes, so we
93              // need to ask the service worker to update.
94              console.log('New service worker available.');
95              reg.update();
96              waitForActivation(reg.installing);
97            } else {
98              // Existing service worker is still good.
99              console.log('Loading app from service worker.');
100              loadMainDartJs();
101            }
102          });
103
104        // If service worker doesn't succeed in a reasonable amount of time,
105        // fallback to plaint &lt;script&gt; tag.
106        setTimeout(() =&gt; {
107          if (!scriptLoaded) {
108            console.warn(
109              'Failed to load app from service worker. Falling back to plain &lt;script&gt; tag.',
110            );
111            loadMainDartJs();
112          }
113        }, 4000);
114      });
115    } else {
116      // Service workers not supported. Just drop the &lt;script&gt; tag.
117      loadMainDartJs();
118    }
119  &lt;/script&gt;
120  &lt;script type=&quot;module&quot;&gt;
121    // Import the functions you need from the SDKs you need
122    import { initializeApp } from &quot;https://www.gstatic.com/firebasejs/9.6.0/firebase-app.js&quot;;
123    import { getAnalytics } from &quot;https://www.gstatic.com/firebasejs/9.6.0/firebase-analytics.js&quot;;
124    // TODO: Add SDKs for Firebase products that you want to use
125    // https://firebase.google.com/docs/web/setup#available-libraries
126
127    // Your web app's Firebase configuration
128    // For Firebase JS SDK v7.20.0 and later, measurementId is optional
129    const firebaseConfig = {
130      apiKey: &quot;xxx&quot;,
131      authDomain: &quot;xxx&quot;,
132      projectId: &quot;xx&quot;,
133      storageBucket: &quot;exxx&quot;,
134      messagingSenderId: &quot;xxx&quot;,
135      appId: &quot;xxx&quot;,
136      measurementId: &quot;xxx&quot;
137    };
138
139    // Initialize Firebase
140    const app = initializeApp(firebaseConfig);
141    const analytics = getAnalytics(app);
142  &lt;/script&gt;
143&lt;/body&gt;
144&lt;/html&gt;
145void main() async {
146  WidgetsFlutterBinding.ensureInitialized();
147  await Firebase.initializeApp();
148  runApp(SignUpApp());
149}
150

Pubsec.yaml file of the project

1&quot;FirebaseOptions cannot be null when creating the default app.&quot;
2    at Object.throw_ [as throw] (http://localhost:7357/dart_sdk.js:5063:11)
3    at Object.assertFailed (http://localhost:7357/dart_sdk.js:4988:15)
4at firebase_core_web.FirebaseCoreWeb.new.initializeApp (http://localhost:7357/packages/firebase_core_web/firebase_core_web.dart.lib.js:252:42)
5    at initializeApp.next (&lt;anonymous&gt;)
6    at http://localhost:7357/dart_sdk.js:40192:33
7    at _RootZone.runUnary (http://localhost:7357/dart_sdk.js:40062:59)
8    at _FutureListener.thenAwait.handleValue (http://localhost:7357/dart_sdk.js:34983:29)
9    at handleValueCallback (http://localhost:7357/dart_sdk.js:35551:49)
10    at Function._propagateToListeners (http://localhost:7357/dart_sdk.js:35589:17)
11    at _Future.new.[_completeWithValue] (http://localhost:7357/dart_sdk.js:35437:23)
12    at async._AsyncCallbackEntry.new.callback (http://localhost:7357/dart_sdk.js:35458:35)
13    at Object._microtaskLoop (http://localhost:7357/dart_sdk.js:40330:13)
14    at _startMicrotaskLoop (http://localhost:7357/dart_sdk.js:40336:13)
15    at http://localhost:7357/dart_sdk.js:35811:9
16&lt;!DOCTYPE html&gt;
17&lt;html&gt;
18&lt;head&gt;
19  &lt;!--
20    If you are serving your web app in a path other than the root, change the
21    href value below to reflect the base path you are serving from.
22
23    The path provided below has to start and end with a slash &quot;/&quot; in order for
24    it to work correctly.
25
26    For more details:
27    * https://developer.mozilla.org/en-US/docs/Web/HTML/Element/base
28
29    This is a placeholder for base href that will be replaced by the value of
30    the `--base-href` argument provided to `flutter build`.
31  --&gt;
32  &lt;base href=&quot;$FLUTTER_BASE_HREF&quot;&gt;
33
34  &lt;meta charset=&quot;UTF-8&quot;&gt;
35  &lt;meta content=&quot;IE=Edge&quot; http-equiv=&quot;X-UA-Compatible&quot;&gt;
36  &lt;meta name=&quot;description&quot; content=&quot;A new Flutter project.&quot;&gt;
37  &lt;meta name=&quot;google-signin-client_id&quot; content=&quot;619218114547-xxxx.apps.googleusercontent.com&quot;&gt;
38  &lt;!-- iOS meta tags &amp; icons --&gt;
39  &lt;meta name=&quot;apple-mobile-web-app-capable&quot; content=&quot;yes&quot;&gt;
40  &lt;meta name=&quot;apple-mobile-web-app-status-bar-style&quot; content=&quot;black&quot;&gt;
41  &lt;meta name=&quot;apple-mobile-web-app-title&quot; content=&quot;signin_example&quot;&gt;
42  &lt;link rel=&quot;apple-touch-icon&quot; href=&quot;icons/Icon-192.png&quot;&gt;
43  
44  &lt;!-- Favicon --&gt;
45  &lt;link rel=&quot;icon&quot; type=&quot;image/png&quot; href=&quot;favicon.png&quot;/&gt;
46
47  &lt;title&gt;signin_example&lt;/title&gt;
48  &lt;link rel=&quot;manifest&quot; href=&quot;manifest.json&quot;&gt;
49&lt;/head&gt;
50&lt;body&gt;
51  &lt;!-- This script installs service_worker.js to provide PWA functionality to
52       application. For more information, see:
53       https://developers.google.com/web/fundamentals/primers/service-workers --&gt;
54  
55  
56  &lt;script&gt;
57    var serviceWorkerVersion = null;
58    var scriptLoaded = false;
59    function loadMainDartJs() {
60      if (scriptLoaded) {
61        return;
62      }
63      scriptLoaded = true;
64      var scriptTag = document.createElement('script');
65      scriptTag.src = 'main.dart.js';
66      scriptTag.type = 'application/javascript';
67      document.body.append(scriptTag);
68    }
69
70    if ('serviceWorker' in navigator) {
71      // Service workers are supported. Use them.
72      window.addEventListener('load', function () {
73        // Wait for registration to finish before dropping the &lt;script&gt; tag.
74        // Otherwise, the browser will load the script multiple times,
75        // potentially different versions.
76        var serviceWorkerUrl = 'flutter_service_worker.js?v=' + serviceWorkerVersion;
77        navigator.serviceWorker.register(serviceWorkerUrl)
78          .then((reg) =&gt; {
79            function waitForActivation(serviceWorker) {
80              serviceWorker.addEventListener('statechange', () =&gt; {
81                if (serviceWorker.state == 'activated') {
82                  console.log('Installed new service worker.');
83                  loadMainDartJs();
84                }
85              });
86            }
87            if (!reg.active &amp;&amp; (reg.installing || reg.waiting)) {
88              // No active web worker and we have installed or are installing
89              // one for the first time. Simply wait for it to activate.
90              waitForActivation(reg.installing || reg.waiting);
91            } else if (!reg.active.scriptURL.endsWith(serviceWorkerVersion)) {
92              // When the app updates the serviceWorkerVersion changes, so we
93              // need to ask the service worker to update.
94              console.log('New service worker available.');
95              reg.update();
96              waitForActivation(reg.installing);
97            } else {
98              // Existing service worker is still good.
99              console.log('Loading app from service worker.');
100              loadMainDartJs();
101            }
102          });
103
104        // If service worker doesn't succeed in a reasonable amount of time,
105        // fallback to plaint &lt;script&gt; tag.
106        setTimeout(() =&gt; {
107          if (!scriptLoaded) {
108            console.warn(
109              'Failed to load app from service worker. Falling back to plain &lt;script&gt; tag.',
110            );
111            loadMainDartJs();
112          }
113        }, 4000);
114      });
115    } else {
116      // Service workers not supported. Just drop the &lt;script&gt; tag.
117      loadMainDartJs();
118    }
119  &lt;/script&gt;
120  &lt;script type=&quot;module&quot;&gt;
121    // Import the functions you need from the SDKs you need
122    import { initializeApp } from &quot;https://www.gstatic.com/firebasejs/9.6.0/firebase-app.js&quot;;
123    import { getAnalytics } from &quot;https://www.gstatic.com/firebasejs/9.6.0/firebase-analytics.js&quot;;
124    // TODO: Add SDKs for Firebase products that you want to use
125    // https://firebase.google.com/docs/web/setup#available-libraries
126
127    // Your web app's Firebase configuration
128    // For Firebase JS SDK v7.20.0 and later, measurementId is optional
129    const firebaseConfig = {
130      apiKey: &quot;xxx&quot;,
131      authDomain: &quot;xxx&quot;,
132      projectId: &quot;xx&quot;,
133      storageBucket: &quot;exxx&quot;,
134      messagingSenderId: &quot;xxx&quot;,
135      appId: &quot;xxx&quot;,
136      measurementId: &quot;xxx&quot;
137    };
138
139    // Initialize Firebase
140    const app = initializeApp(firebaseConfig);
141    const analytics = getAnalytics(app);
142  &lt;/script&gt;
143&lt;/body&gt;
144&lt;/html&gt;
145void main() async {
146  WidgetsFlutterBinding.ensureInitialized();
147  await Firebase.initializeApp();
148  runApp(SignUpApp());
149}
150name: signin_example
151description: A new Flutter project.
152
153# The following line prevents the package from being accidentally published to
154# pub.dev using `flutter pub publish`. This is preferred for private packages.
155publish_to: 'none' # Remove this line if you wish to publish to pub.dev
156
157https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
158version: 1.0.0+1
159
160environment:
161  sdk: &quot;&gt;=2.15.0-268.18.beta &lt;3.0.0&quot;
162
163dependencies:
164  flutter:
165    sdk: flutter
166
167
168  # The following adds the Cupertino Icons font to your application.
169  # Use with the CupertinoIcons class for iOS style icons.
170  cupertino_icons: ^1.0.2
171  firebase_auth: ^3.3.0
172  firebase_core: ^1.10.2
173  google_sign_in: ^5.2.1
174  shared_preferences: ^2.0.9
175
176dev_dependencies:
177  flutter_test:
178    sdk: flutter
179
180  flutter_lints: ^1.0.0
181
182# The following section is specific to Flutter.
183flutter:
184
185  assets:
186    - assets/images/
187
188  uses-material-design: true
189

Can anyone help me understand what is the issue here?

ANSWER

Answered 2021-Dec-25 at 09:13

UPDATE:

For your firebase_core version is seems to be sufficient to pass the FirebaseOptions once you initialize firebase in your flutter code (and you don't need any script tags in your index.html):

1&quot;FirebaseOptions cannot be null when creating the default app.&quot;
2    at Object.throw_ [as throw] (http://localhost:7357/dart_sdk.js:5063:11)
3    at Object.assertFailed (http://localhost:7357/dart_sdk.js:4988:15)
4at firebase_core_web.FirebaseCoreWeb.new.initializeApp (http://localhost:7357/packages/firebase_core_web/firebase_core_web.dart.lib.js:252:42)
5    at initializeApp.next (&lt;anonymous&gt;)
6    at http://localhost:7357/dart_sdk.js:40192:33
7    at _RootZone.runUnary (http://localhost:7357/dart_sdk.js:40062:59)
8    at _FutureListener.thenAwait.handleValue (http://localhost:7357/dart_sdk.js:34983:29)
9    at handleValueCallback (http://localhost:7357/dart_sdk.js:35551:49)
10    at Function._propagateToListeners (http://localhost:7357/dart_sdk.js:35589:17)
11    at _Future.new.[_completeWithValue] (http://localhost:7357/dart_sdk.js:35437:23)
12    at async._AsyncCallbackEntry.new.callback (http://localhost:7357/dart_sdk.js:35458:35)
13    at Object._microtaskLoop (http://localhost:7357/dart_sdk.js:40330:13)
14    at _startMicrotaskLoop (http://localhost:7357/dart_sdk.js:40336:13)
15    at http://localhost:7357/dart_sdk.js:35811:9
16&lt;!DOCTYPE html&gt;
17&lt;html&gt;
18&lt;head&gt;
19  &lt;!--
20    If you are serving your web app in a path other than the root, change the
21    href value below to reflect the base path you are serving from.
22
23    The path provided below has to start and end with a slash &quot;/&quot; in order for
24    it to work correctly.
25
26    For more details:
27    * https://developer.mozilla.org/en-US/docs/Web/HTML/Element/base
28
29    This is a placeholder for base href that will be replaced by the value of
30    the `--base-href` argument provided to `flutter build`.
31  --&gt;
32  &lt;base href=&quot;$FLUTTER_BASE_HREF&quot;&gt;
33
34  &lt;meta charset=&quot;UTF-8&quot;&gt;
35  &lt;meta content=&quot;IE=Edge&quot; http-equiv=&quot;X-UA-Compatible&quot;&gt;
36  &lt;meta name=&quot;description&quot; content=&quot;A new Flutter project.&quot;&gt;
37  &lt;meta name=&quot;google-signin-client_id&quot; content=&quot;619218114547-xxxx.apps.googleusercontent.com&quot;&gt;
38  &lt;!-- iOS meta tags &amp; icons --&gt;
39  &lt;meta name=&quot;apple-mobile-web-app-capable&quot; content=&quot;yes&quot;&gt;
40  &lt;meta name=&quot;apple-mobile-web-app-status-bar-style&quot; content=&quot;black&quot;&gt;
41  &lt;meta name=&quot;apple-mobile-web-app-title&quot; content=&quot;signin_example&quot;&gt;
42  &lt;link rel=&quot;apple-touch-icon&quot; href=&quot;icons/Icon-192.png&quot;&gt;
43  
44  &lt;!-- Favicon --&gt;
45  &lt;link rel=&quot;icon&quot; type=&quot;image/png&quot; href=&quot;favicon.png&quot;/&gt;
46
47  &lt;title&gt;signin_example&lt;/title&gt;
48  &lt;link rel=&quot;manifest&quot; href=&quot;manifest.json&quot;&gt;
49&lt;/head&gt;
50&lt;body&gt;
51  &lt;!-- This script installs service_worker.js to provide PWA functionality to
52       application. For more information, see:
53       https://developers.google.com/web/fundamentals/primers/service-workers --&gt;
54  
55  
56  &lt;script&gt;
57    var serviceWorkerVersion = null;
58    var scriptLoaded = false;
59    function loadMainDartJs() {
60      if (scriptLoaded) {
61        return;
62      }
63      scriptLoaded = true;
64      var scriptTag = document.createElement('script');
65      scriptTag.src = 'main.dart.js';
66      scriptTag.type = 'application/javascript';
67      document.body.append(scriptTag);
68    }
69
70    if ('serviceWorker' in navigator) {
71      // Service workers are supported. Use them.
72      window.addEventListener('load', function () {
73        // Wait for registration to finish before dropping the &lt;script&gt; tag.
74        // Otherwise, the browser will load the script multiple times,
75        // potentially different versions.
76        var serviceWorkerUrl = 'flutter_service_worker.js?v=' + serviceWorkerVersion;
77        navigator.serviceWorker.register(serviceWorkerUrl)
78          .then((reg) =&gt; {
79            function waitForActivation(serviceWorker) {
80              serviceWorker.addEventListener('statechange', () =&gt; {
81                if (serviceWorker.state == 'activated') {
82                  console.log('Installed new service worker.');
83                  loadMainDartJs();
84                }
85              });
86            }
87            if (!reg.active &amp;&amp; (reg.installing || reg.waiting)) {
88              // No active web worker and we have installed or are installing
89              // one for the first time. Simply wait for it to activate.
90              waitForActivation(reg.installing || reg.waiting);
91            } else if (!reg.active.scriptURL.endsWith(serviceWorkerVersion)) {
92              // When the app updates the serviceWorkerVersion changes, so we
93              // need to ask the service worker to update.
94              console.log('New service worker available.');
95              reg.update();
96              waitForActivation(reg.installing);
97            } else {
98              // Existing service worker is still good.
99              console.log('Loading app from service worker.');
100              loadMainDartJs();
101            }
102          });
103
104        // If service worker doesn't succeed in a reasonable amount of time,
105        // fallback to plaint &lt;script&gt; tag.
106        setTimeout(() =&gt; {
107          if (!scriptLoaded) {
108            console.warn(
109              'Failed to load app from service worker. Falling back to plain &lt;script&gt; tag.',
110            );
111            loadMainDartJs();
112          }
113        }, 4000);
114      });
115    } else {
116      // Service workers not supported. Just drop the &lt;script&gt; tag.
117      loadMainDartJs();
118    }
119  &lt;/script&gt;
120  &lt;script type=&quot;module&quot;&gt;
121    // Import the functions you need from the SDKs you need
122    import { initializeApp } from &quot;https://www.gstatic.com/firebasejs/9.6.0/firebase-app.js&quot;;
123    import { getAnalytics } from &quot;https://www.gstatic.com/firebasejs/9.6.0/firebase-analytics.js&quot;;
124    // TODO: Add SDKs for Firebase products that you want to use
125    // https://firebase.google.com/docs/web/setup#available-libraries
126
127    // Your web app's Firebase configuration
128    // For Firebase JS SDK v7.20.0 and later, measurementId is optional
129    const firebaseConfig = {
130      apiKey: &quot;xxx&quot;,
131      authDomain: &quot;xxx&quot;,
132      projectId: &quot;xx&quot;,
133      storageBucket: &quot;exxx&quot;,
134      messagingSenderId: &quot;xxx&quot;,
135      appId: &quot;xxx&quot;,
136      measurementId: &quot;xxx&quot;
137    };
138
139    // Initialize Firebase
140    const app = initializeApp(firebaseConfig);
141    const analytics = getAnalytics(app);
142  &lt;/script&gt;
143&lt;/body&gt;
144&lt;/html&gt;
145void main() async {
146  WidgetsFlutterBinding.ensureInitialized();
147  await Firebase.initializeApp();
148  runApp(SignUpApp());
149}
150name: signin_example
151description: A new Flutter project.
152
153# The following line prevents the package from being accidentally published to
154# pub.dev using `flutter pub publish`. This is preferred for private packages.
155publish_to: 'none' # Remove this line if you wish to publish to pub.dev
156
157https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
158version: 1.0.0+1
159
160environment:
161  sdk: &quot;&gt;=2.15.0-268.18.beta &lt;3.0.0&quot;
162
163dependencies:
164  flutter:
165    sdk: flutter
166
167
168  # The following adds the Cupertino Icons font to your application.
169  # Use with the CupertinoIcons class for iOS style icons.
170  cupertino_icons: ^1.0.2
171  firebase_auth: ^3.3.0
172  firebase_core: ^1.10.2
173  google_sign_in: ^5.2.1
174  shared_preferences: ^2.0.9
175
176dev_dependencies:
177  flutter_test:
178    sdk: flutter
179
180  flutter_lints: ^1.0.0
181
182# The following section is specific to Flutter.
183flutter:
184
185  assets:
186    - assets/images/
187
188  uses-material-design: true
189void main() async {
190  WidgetsFlutterBinding.ensureInitialized();
191  await Firebase.initializeApp(
192    // Replace with actual values
193    options: FirebaseOptions(
194      apiKey: &quot;XXX&quot;,
195      appId: &quot;XXX&quot;,
196      messagingSenderId: &quot;XXX&quot;,
197      projectId: &quot;XXX&quot;,
198    ),
199  );
200  runApp(MyApp());
201}
202

Alternatively, one can also follow the updated official documentation and use the Firebase CLI to automatically create a firebase_options.dart file in your lib folder that will define the correct FirebaseOptions for you. The steps are:

  1. Install Flutterfire CLI:
1&quot;FirebaseOptions cannot be null when creating the default app.&quot;
2    at Object.throw_ [as throw] (http://localhost:7357/dart_sdk.js:5063:11)
3    at Object.assertFailed (http://localhost:7357/dart_sdk.js:4988:15)
4at firebase_core_web.FirebaseCoreWeb.new.initializeApp (http://localhost:7357/packages/firebase_core_web/firebase_core_web.dart.lib.js:252:42)
5    at initializeApp.next (&lt;anonymous&gt;)
6    at http://localhost:7357/dart_sdk.js:40192:33
7    at _RootZone.runUnary (http://localhost:7357/dart_sdk.js:40062:59)
8    at _FutureListener.thenAwait.handleValue (http://localhost:7357/dart_sdk.js:34983:29)
9    at handleValueCallback (http://localhost:7357/dart_sdk.js:35551:49)
10    at Function._propagateToListeners (http://localhost:7357/dart_sdk.js:35589:17)
11    at _Future.new.[_completeWithValue] (http://localhost:7357/dart_sdk.js:35437:23)
12    at async._AsyncCallbackEntry.new.callback (http://localhost:7357/dart_sdk.js:35458:35)
13    at Object._microtaskLoop (http://localhost:7357/dart_sdk.js:40330:13)
14    at _startMicrotaskLoop (http://localhost:7357/dart_sdk.js:40336:13)
15    at http://localhost:7357/dart_sdk.js:35811:9
16&lt;!DOCTYPE html&gt;
17&lt;html&gt;
18&lt;head&gt;
19  &lt;!--
20    If you are serving your web app in a path other than the root, change the
21    href value below to reflect the base path you are serving from.
22
23    The path provided below has to start and end with a slash &quot;/&quot; in order for
24    it to work correctly.
25
26    For more details:
27    * https://developer.mozilla.org/en-US/docs/Web/HTML/Element/base
28
29    This is a placeholder for base href that will be replaced by the value of
30    the `--base-href` argument provided to `flutter build`.
31  --&gt;
32  &lt;base href=&quot;$FLUTTER_BASE_HREF&quot;&gt;
33
34  &lt;meta charset=&quot;UTF-8&quot;&gt;
35  &lt;meta content=&quot;IE=Edge&quot; http-equiv=&quot;X-UA-Compatible&quot;&gt;
36  &lt;meta name=&quot;description&quot; content=&quot;A new Flutter project.&quot;&gt;
37  &lt;meta name=&quot;google-signin-client_id&quot; content=&quot;619218114547-xxxx.apps.googleusercontent.com&quot;&gt;
38  &lt;!-- iOS meta tags &amp; icons --&gt;
39  &lt;meta name=&quot;apple-mobile-web-app-capable&quot; content=&quot;yes&quot;&gt;
40  &lt;meta name=&quot;apple-mobile-web-app-status-bar-style&quot; content=&quot;black&quot;&gt;
41  &lt;meta name=&quot;apple-mobile-web-app-title&quot; content=&quot;signin_example&quot;&gt;
42  &lt;link rel=&quot;apple-touch-icon&quot; href=&quot;icons/Icon-192.png&quot;&gt;
43  
44  &lt;!-- Favicon --&gt;
45  &lt;link rel=&quot;icon&quot; type=&quot;image/png&quot; href=&quot;favicon.png&quot;/&gt;
46
47  &lt;title&gt;signin_example&lt;/title&gt;
48  &lt;link rel=&quot;manifest&quot; href=&quot;manifest.json&quot;&gt;
49&lt;/head&gt;
50&lt;body&gt;
51  &lt;!-- This script installs service_worker.js to provide PWA functionality to
52       application. For more information, see:
53       https://developers.google.com/web/fundamentals/primers/service-workers --&gt;
54  
55  
56  &lt;script&gt;
57    var serviceWorkerVersion = null;
58    var scriptLoaded = false;
59    function loadMainDartJs() {
60      if (scriptLoaded) {
61        return;
62      }
63      scriptLoaded = true;
64      var scriptTag = document.createElement('script');
65      scriptTag.src = 'main.dart.js';
66      scriptTag.type = 'application/javascript';
67      document.body.append(scriptTag);
68    }
69
70    if ('serviceWorker' in navigator) {
71      // Service workers are supported. Use them.
72      window.addEventListener('load', function () {
73        // Wait for registration to finish before dropping the &lt;script&gt; tag.
74        // Otherwise, the browser will load the script multiple times,
75        // potentially different versions.
76        var serviceWorkerUrl = 'flutter_service_worker.js?v=' + serviceWorkerVersion;
77        navigator.serviceWorker.register(serviceWorkerUrl)
78          .then((reg) =&gt; {
79            function waitForActivation(serviceWorker) {
80              serviceWorker.addEventListener('statechange', () =&gt; {
81                if (serviceWorker.state == 'activated') {
82                  console.log('Installed new service worker.');
83                  loadMainDartJs();
84                }
85              });
86            }
87            if (!reg.active &amp;&amp; (reg.installing || reg.waiting)) {
88              // No active web worker and we have installed or are installing
89              // one for the first time. Simply wait for it to activate.
90              waitForActivation(reg.installing || reg.waiting);
91            } else if (!reg.active.scriptURL.endsWith(serviceWorkerVersion)) {
92              // When the app updates the serviceWorkerVersion changes, so we
93              // need to ask the service worker to update.
94              console.log('New service worker available.');
95              reg.update();
96              waitForActivation(reg.installing);
97            } else {
98              // Existing service worker is still good.
99              console.log('Loading app from service worker.');
100              loadMainDartJs();
101            }
102          });
103
104        // If service worker doesn't succeed in a reasonable amount of time,
105        // fallback to plaint &lt;script&gt; tag.
106        setTimeout(() =&gt; {
107          if (!scriptLoaded) {
108            console.warn(
109              'Failed to load app from service worker. Falling back to plain &lt;script&gt; tag.',
110            );
111            loadMainDartJs();
112          }
113        }, 4000);
114      });
115    } else {
116      // Service workers not supported. Just drop the &lt;script&gt; tag.
117      loadMainDartJs();
118    }
119  &lt;/script&gt;
120  &lt;script type=&quot;module&quot;&gt;
121    // Import the functions you need from the SDKs you need
122    import { initializeApp } from &quot;https://www.gstatic.com/firebasejs/9.6.0/firebase-app.js&quot;;
123    import { getAnalytics } from &quot;https://www.gstatic.com/firebasejs/9.6.0/firebase-analytics.js&quot;;
124    // TODO: Add SDKs for Firebase products that you want to use
125    // https://firebase.google.com/docs/web/setup#available-libraries
126
127    // Your web app's Firebase configuration
128    // For Firebase JS SDK v7.20.0 and later, measurementId is optional
129    const firebaseConfig = {
130      apiKey: &quot;xxx&quot;,
131      authDomain: &quot;xxx&quot;,
132      projectId: &quot;xx&quot;,
133      storageBucket: &quot;exxx&quot;,
134      messagingSenderId: &quot;xxx&quot;,
135      appId: &quot;xxx&quot;,
136      measurementId: &quot;xxx&quot;
137    };
138
139    // Initialize Firebase
140    const app = initializeApp(firebaseConfig);
141    const analytics = getAnalytics(app);
142  &lt;/script&gt;
143&lt;/body&gt;
144&lt;/html&gt;
145void main() async {
146  WidgetsFlutterBinding.ensureInitialized();
147  await Firebase.initializeApp();
148  runApp(SignUpApp());
149}
150name: signin_example
151description: A new Flutter project.
152
153# The following line prevents the package from being accidentally published to
154# pub.dev using `flutter pub publish`. This is preferred for private packages.
155publish_to: 'none' # Remove this line if you wish to publish to pub.dev
156
157https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
158version: 1.0.0+1
159
160environment:
161  sdk: &quot;&gt;=2.15.0-268.18.beta &lt;3.0.0&quot;
162
163dependencies:
164  flutter:
165    sdk: flutter
166
167
168  # The following adds the Cupertino Icons font to your application.
169  # Use with the CupertinoIcons class for iOS style icons.
170  cupertino_icons: ^1.0.2
171  firebase_auth: ^3.3.0
172  firebase_core: ^1.10.2
173  google_sign_in: ^5.2.1
174  shared_preferences: ^2.0.9
175
176dev_dependencies:
177  flutter_test:
178    sdk: flutter
179
180  flutter_lints: ^1.0.0
181
182# The following section is specific to Flutter.
183flutter:
184
185  assets:
186    - assets/images/
187
188  uses-material-design: true
189void main() async {
190  WidgetsFlutterBinding.ensureInitialized();
191  await Firebase.initializeApp(
192    // Replace with actual values
193    options: FirebaseOptions(
194      apiKey: &quot;XXX&quot;,
195      appId: &quot;XXX&quot;,
196      messagingSenderId: &quot;XXX&quot;,
197      projectId: &quot;XXX&quot;,
198    ),
199  );
200  runApp(MyApp());
201}
202dart pub global activate flutterfire_cli
203
  1. Configure Flutterfire (run in your project's root and go through the wizard selecting the correct Firebase project and target platforms):
1&quot;FirebaseOptions cannot be null when creating the default app.&quot;
2    at Object.throw_ [as throw] (http://localhost:7357/dart_sdk.js:5063:11)
3    at Object.assertFailed (http://localhost:7357/dart_sdk.js:4988:15)
4at firebase_core_web.FirebaseCoreWeb.new.initializeApp (http://localhost:7357/packages/firebase_core_web/firebase_core_web.dart.lib.js:252:42)
5    at initializeApp.next (&lt;anonymous&gt;)
6    at http://localhost:7357/dart_sdk.js:40192:33
7    at _RootZone.runUnary (http://localhost:7357/dart_sdk.js:40062:59)
8    at _FutureListener.thenAwait.handleValue (http://localhost:7357/dart_sdk.js:34983:29)
9    at handleValueCallback (http://localhost:7357/dart_sdk.js:35551:49)
10    at Function._propagateToListeners (http://localhost:7357/dart_sdk.js:35589:17)
11    at _Future.new.[_completeWithValue] (http://localhost:7357/dart_sdk.js:35437:23)
12    at async._AsyncCallbackEntry.new.callback (http://localhost:7357/dart_sdk.js:35458:35)
13    at Object._microtaskLoop (http://localhost:7357/dart_sdk.js:40330:13)
14    at _startMicrotaskLoop (http://localhost:7357/dart_sdk.js:40336:13)
15    at http://localhost:7357/dart_sdk.js:35811:9
16&lt;!DOCTYPE html&gt;
17&lt;html&gt;
18&lt;head&gt;
19  &lt;!--
20    If you are serving your web app in a path other than the root, change the
21    href value below to reflect the base path you are serving from.
22
23    The path provided below has to start and end with a slash &quot;/&quot; in order for
24    it to work correctly.
25
26    For more details:
27    * https://developer.mozilla.org/en-US/docs/Web/HTML/Element/base
28
29    This is a placeholder for base href that will be replaced by the value of
30    the `--base-href` argument provided to `flutter build`.
31  --&gt;
32  &lt;base href=&quot;$FLUTTER_BASE_HREF&quot;&gt;
33
34  &lt;meta charset=&quot;UTF-8&quot;&gt;
35  &lt;meta content=&quot;IE=Edge&quot; http-equiv=&quot;X-UA-Compatible&quot;&gt;
36  &lt;meta name=&quot;description&quot; content=&quot;A new Flutter project.&quot;&gt;
37  &lt;meta name=&quot;google-signin-client_id&quot; content=&quot;619218114547-xxxx.apps.googleusercontent.com&quot;&gt;
38  &lt;!-- iOS meta tags &amp; icons --&gt;
39  &lt;meta name=&quot;apple-mobile-web-app-capable&quot; content=&quot;yes&quot;&gt;
40  &lt;meta name=&quot;apple-mobile-web-app-status-bar-style&quot; content=&quot;black&quot;&gt;
41  &lt;meta name=&quot;apple-mobile-web-app-title&quot; content=&quot;signin_example&quot;&gt;
42  &lt;link rel=&quot;apple-touch-icon&quot; href=&quot;icons/Icon-192.png&quot;&gt;
43  
44  &lt;!-- Favicon --&gt;
45  &lt;link rel=&quot;icon&quot; type=&quot;image/png&quot; href=&quot;favicon.png&quot;/&gt;
46
47  &lt;title&gt;signin_example&lt;/title&gt;
48  &lt;link rel=&quot;manifest&quot; href=&quot;manifest.json&quot;&gt;
49&lt;/head&gt;
50&lt;body&gt;
51  &lt;!-- This script installs service_worker.js to provide PWA functionality to
52       application. For more information, see:
53       https://developers.google.com/web/fundamentals/primers/service-workers --&gt;
54  
55  
56  &lt;script&gt;
57    var serviceWorkerVersion = null;
58    var scriptLoaded = false;
59    function loadMainDartJs() {
60      if (scriptLoaded) {
61        return;
62      }
63      scriptLoaded = true;
64      var scriptTag = document.createElement('script');
65      scriptTag.src = 'main.dart.js';
66      scriptTag.type = 'application/javascript';
67      document.body.append(scriptTag);
68    }
69
70    if ('serviceWorker' in navigator) {
71      // Service workers are supported. Use them.
72      window.addEventListener('load', function () {
73        // Wait for registration to finish before dropping the &lt;script&gt; tag.
74        // Otherwise, the browser will load the script multiple times,
75        // potentially different versions.
76        var serviceWorkerUrl = 'flutter_service_worker.js?v=' + serviceWorkerVersion;
77        navigator.serviceWorker.register(serviceWorkerUrl)
78          .then((reg) =&gt; {
79            function waitForActivation(serviceWorker) {
80              serviceWorker.addEventListener('statechange', () =&gt; {
81                if (serviceWorker.state == 'activated') {
82                  console.log('Installed new service worker.');
83                  loadMainDartJs();
84                }
85              });
86            }
87            if (!reg.active &amp;&amp; (reg.installing || reg.waiting)) {
88              // No active web worker and we have installed or are installing
89              // one for the first time. Simply wait for it to activate.
90              waitForActivation(reg.installing || reg.waiting);
91            } else if (!reg.active.scriptURL.endsWith(serviceWorkerVersion)) {
92              // When the app updates the serviceWorkerVersion changes, so we
93              // need to ask the service worker to update.
94              console.log('New service worker available.');
95              reg.update();
96              waitForActivation(reg.installing);
97            } else {
98              // Existing service worker is still good.
99              console.log('Loading app from service worker.');
100              loadMainDartJs();
101            }
102          });
103
104        // If service worker doesn't succeed in a reasonable amount of time,
105        // fallback to plaint &lt;script&gt; tag.
106        setTimeout(() =&gt; {
107          if (!scriptLoaded) {
108            console.warn(
109              'Failed to load app from service worker. Falling back to plain &lt;script&gt; tag.',
110            );
111            loadMainDartJs();
112          }
113        }, 4000);
114      });
115    } else {
116      // Service workers not supported. Just drop the &lt;script&gt; tag.
117      loadMainDartJs();
118    }
119  &lt;/script&gt;
120  &lt;script type=&quot;module&quot;&gt;
121    // Import the functions you need from the SDKs you need
122    import { initializeApp } from &quot;https://www.gstatic.com/firebasejs/9.6.0/firebase-app.js&quot;;
123    import { getAnalytics } from &quot;https://www.gstatic.com/firebasejs/9.6.0/firebase-analytics.js&quot;;
124    // TODO: Add SDKs for Firebase products that you want to use
125    // https://firebase.google.com/docs/web/setup#available-libraries
126
127    // Your web app's Firebase configuration
128    // For Firebase JS SDK v7.20.0 and later, measurementId is optional
129    const firebaseConfig = {
130      apiKey: &quot;xxx&quot;,
131      authDomain: &quot;xxx&quot;,
132      projectId: &quot;xx&quot;,
133      storageBucket: &quot;exxx&quot;,
134      messagingSenderId: &quot;xxx&quot;,
135      appId: &quot;xxx&quot;,
136      measurementId: &quot;xxx&quot;
137    };
138
139    // Initialize Firebase
140    const app = initializeApp(firebaseConfig);
141    const analytics = getAnalytics(app);
142  &lt;/script&gt;
143&lt;/body&gt;
144&lt;/html&gt;
145void main() async {
146  WidgetsFlutterBinding.ensureInitialized();
147  await Firebase.initializeApp();
148  runApp(SignUpApp());
149}
150name: signin_example
151description: A new Flutter project.
152
153# The following line prevents the package from being accidentally published to
154# pub.dev using `flutter pub publish`. This is preferred for private packages.
155publish_to: 'none' # Remove this line if you wish to publish to pub.dev
156
157https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
158version: 1.0.0+1
159
160environment:
161  sdk: &quot;&gt;=2.15.0-268.18.beta &lt;3.0.0&quot;
162
163dependencies:
164  flutter:
165    sdk: flutter
166
167
168  # The following adds the Cupertino Icons font to your application.
169  # Use with the CupertinoIcons class for iOS style icons.
170  cupertino_icons: ^1.0.2
171  firebase_auth: ^3.3.0
172  firebase_core: ^1.10.2
173  google_sign_in: ^5.2.1
174  shared_preferences: ^2.0.9
175
176dev_dependencies:
177  flutter_test:
178    sdk: flutter
179
180  flutter_lints: ^1.0.0
181
182# The following section is specific to Flutter.
183flutter:
184
185  assets:
186    - assets/images/
187
188  uses-material-design: true
189void main() async {
190  WidgetsFlutterBinding.ensureInitialized();
191  await Firebase.initializeApp(
192    // Replace with actual values
193    options: FirebaseOptions(
194      apiKey: &quot;XXX&quot;,
195      appId: &quot;XXX&quot;,
196      messagingSenderId: &quot;XXX&quot;,
197      projectId: &quot;XXX&quot;,
198    ),
199  );
200  runApp(MyApp());
201}
202dart pub global activate flutterfire_cli
203flutterfire configure
204
  1. Import the automatically generated firebase_options.dart file in your main.dart file and initialize Firebase as follows:
1&quot;FirebaseOptions cannot be null when creating the default app.&quot;
2    at Object.throw_ [as throw] (http://localhost:7357/dart_sdk.js:5063:11)
3    at Object.assertFailed (http://localhost:7357/dart_sdk.js:4988:15)
4at firebase_core_web.FirebaseCoreWeb.new.initializeApp (http://localhost:7357/packages/firebase_core_web/firebase_core_web.dart.lib.js:252:42)
5    at initializeApp.next (&lt;anonymous&gt;)
6    at http://localhost:7357/dart_sdk.js:40192:33
7    at _RootZone.runUnary (http://localhost:7357/dart_sdk.js:40062:59)
8    at _FutureListener.thenAwait.handleValue (http://localhost:7357/dart_sdk.js:34983:29)
9    at handleValueCallback (http://localhost:7357/dart_sdk.js:35551:49)
10    at Function._propagateToListeners (http://localhost:7357/dart_sdk.js:35589:17)
11    at _Future.new.[_completeWithValue] (http://localhost:7357/dart_sdk.js:35437:23)
12    at async._AsyncCallbackEntry.new.callback (http://localhost:7357/dart_sdk.js:35458:35)
13    at Object._microtaskLoop (http://localhost:7357/dart_sdk.js:40330:13)
14    at _startMicrotaskLoop (http://localhost:7357/dart_sdk.js:40336:13)
15    at http://localhost:7357/dart_sdk.js:35811:9
16&lt;!DOCTYPE html&gt;
17&lt;html&gt;
18&lt;head&gt;
19  &lt;!--
20    If you are serving your web app in a path other than the root, change the
21    href value below to reflect the base path you are serving from.
22
23    The path provided below has to start and end with a slash &quot;/&quot; in order for
24    it to work correctly.
25
26    For more details:
27    * https://developer.mozilla.org/en-US/docs/Web/HTML/Element/base
28
29    This is a placeholder for base href that will be replaced by the value of
30    the `--base-href` argument provided to `flutter build`.
31  --&gt;
32  &lt;base href=&quot;$FLUTTER_BASE_HREF&quot;&gt;
33
34  &lt;meta charset=&quot;UTF-8&quot;&gt;
35  &lt;meta content=&quot;IE=Edge&quot; http-equiv=&quot;X-UA-Compatible&quot;&gt;
36  &lt;meta name=&quot;description&quot; content=&quot;A new Flutter project.&quot;&gt;
37  &lt;meta name=&quot;google-signin-client_id&quot; content=&quot;619218114547-xxxx.apps.googleusercontent.com&quot;&gt;
38  &lt;!-- iOS meta tags &amp; icons --&gt;
39  &lt;meta name=&quot;apple-mobile-web-app-capable&quot; content=&quot;yes&quot;&gt;
40  &lt;meta name=&quot;apple-mobile-web-app-status-bar-style&quot; content=&quot;black&quot;&gt;
41  &lt;meta name=&quot;apple-mobile-web-app-title&quot; content=&quot;signin_example&quot;&gt;
42  &lt;link rel=&quot;apple-touch-icon&quot; href=&quot;icons/Icon-192.png&quot;&gt;
43  
44  &lt;!-- Favicon --&gt;
45  &lt;link rel=&quot;icon&quot; type=&quot;image/png&quot; href=&quot;favicon.png&quot;/&gt;
46
47  &lt;title&gt;signin_example&lt;/title&gt;
48  &lt;link rel=&quot;manifest&quot; href=&quot;manifest.json&quot;&gt;
49&lt;/head&gt;
50&lt;body&gt;
51  &lt;!-- This script installs service_worker.js to provide PWA functionality to
52       application. For more information, see:
53       https://developers.google.com/web/fundamentals/primers/service-workers --&gt;
54  
55  
56  &lt;script&gt;
57    var serviceWorkerVersion = null;
58    var scriptLoaded = false;
59    function loadMainDartJs() {
60      if (scriptLoaded) {
61        return;
62      }
63      scriptLoaded = true;
64      var scriptTag = document.createElement('script');
65      scriptTag.src = 'main.dart.js';
66      scriptTag.type = 'application/javascript';
67      document.body.append(scriptTag);
68    }
69
70    if ('serviceWorker' in navigator) {
71      // Service workers are supported. Use them.
72      window.addEventListener('load', function () {
73        // Wait for registration to finish before dropping the &lt;script&gt; tag.
74        // Otherwise, the browser will load the script multiple times,
75        // potentially different versions.
76        var serviceWorkerUrl = 'flutter_service_worker.js?v=' + serviceWorkerVersion;
77        navigator.serviceWorker.register(serviceWorkerUrl)
78          .then((reg) =&gt; {
79            function waitForActivation(serviceWorker) {
80              serviceWorker.addEventListener('statechange', () =&gt; {
81                if (serviceWorker.state == 'activated') {
82                  console.log('Installed new service worker.');
83                  loadMainDartJs();
84                }
85              });
86            }
87            if (!reg.active &amp;&amp; (reg.installing || reg.waiting)) {
88              // No active web worker and we have installed or are installing
89              // one for the first time. Simply wait for it to activate.
90              waitForActivation(reg.installing || reg.waiting);
91            } else if (!reg.active.scriptURL.endsWith(serviceWorkerVersion)) {
92              // When the app updates the serviceWorkerVersion changes, so we
93              // need to ask the service worker to update.
94              console.log('New service worker available.');
95              reg.update();
96              waitForActivation(reg.installing);
97            } else {
98              // Existing service worker is still good.
99              console.log('Loading app from service worker.');
100              loadMainDartJs();
101            }
102          });
103
104        // If service worker doesn't succeed in a reasonable amount of time,
105        // fallback to plaint &lt;script&gt; tag.
106        setTimeout(() =&gt; {
107          if (!scriptLoaded) {
108            console.warn(
109              'Failed to load app from service worker. Falling back to plain &lt;script&gt; tag.',
110            );
111            loadMainDartJs();
112          }
113        }, 4000);
114      });
115    } else {
116      // Service workers not supported. Just drop the &lt;script&gt; tag.
117      loadMainDartJs();
118    }
119  &lt;/script&gt;
120  &lt;script type=&quot;module&quot;&gt;
121    // Import the functions you need from the SDKs you need
122    import { initializeApp } from &quot;https://www.gstatic.com/firebasejs/9.6.0/firebase-app.js&quot;;
123    import { getAnalytics } from &quot;https://www.gstatic.com/firebasejs/9.6.0/firebase-analytics.js&quot;;
124    // TODO: Add SDKs for Firebase products that you want to use
125    // https://firebase.google.com/docs/web/setup#available-libraries
126
127    // Your web app's Firebase configuration
128    // For Firebase JS SDK v7.20.0 and later, measurementId is optional
129    const firebaseConfig = {
130      apiKey: &quot;xxx&quot;,
131      authDomain: &quot;xxx&quot;,
132      projectId: &quot;xx&quot;,
133      storageBucket: &quot;exxx&quot;,
134      messagingSenderId: &quot;xxx&quot;,
135      appId: &quot;xxx&quot;,
136      measurementId: &quot;xxx&quot;
137    };
138
139    // Initialize Firebase
140    const app = initializeApp(firebaseConfig);
141    const analytics = getAnalytics(app);
142  &lt;/script&gt;
143&lt;/body&gt;
144&lt;/html&gt;
145void main() async {
146  WidgetsFlutterBinding.ensureInitialized();
147  await Firebase.initializeApp();
148  runApp(SignUpApp());
149}
150name: signin_example
151description: A new Flutter project.
152
153# The following line prevents the package from being accidentally published to
154# pub.dev using `flutter pub publish`. This is preferred for private packages.
155publish_to: 'none' # Remove this line if you wish to publish to pub.dev
156
157https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
158version: 1.0.0+1
159
160environment:
161  sdk: &quot;&gt;=2.15.0-268.18.beta &lt;3.0.0&quot;
162
163dependencies:
164  flutter:
165    sdk: flutter
166
167
168  # The following adds the Cupertino Icons font to your application.
169  # Use with the CupertinoIcons class for iOS style icons.
170  cupertino_icons: ^1.0.2
171  firebase_auth: ^3.3.0
172  firebase_core: ^1.10.2
173  google_sign_in: ^5.2.1
174  shared_preferences: ^2.0.9
175
176dev_dependencies:
177  flutter_test:
178    sdk: flutter
179
180  flutter_lints: ^1.0.0
181
182# The following section is specific to Flutter.
183flutter:
184
185  assets:
186    - assets/images/
187
188  uses-material-design: true
189void main() async {
190  WidgetsFlutterBinding.ensureInitialized();
191  await Firebase.initializeApp(
192    // Replace with actual values
193    options: FirebaseOptions(
194      apiKey: &quot;XXX&quot;,
195      appId: &quot;XXX&quot;,
196      messagingSenderId: &quot;XXX&quot;,
197      projectId: &quot;XXX&quot;,
198    ),
199  );
200  runApp(MyApp());
201}
202dart pub global activate flutterfire_cli
203flutterfire configure
204void main() async {
205  WidgetsFlutterBinding.ensureInitialized();
206  await Firebase.initializeApp(
207    options: DefaultFirebaseOptions.currentPlatform,
208  );
209  runApp(MyApp());
210}
211

PREVIOUS ANSWER:

From the docs:

The only way to currently add the Firebase SDKs to your Flutter web project is by importing the scripts from the Firebase content delivery network (CDN).

Therefore, please try to use script tags to import the relevant firebase components with version 8.6.1 as shown below (more info here):

1&quot;FirebaseOptions cannot be null when creating the default app.&quot;
2    at Object.throw_ [as throw] (http://localhost:7357/dart_sdk.js:5063:11)
3    at Object.assertFailed (http://localhost:7357/dart_sdk.js:4988:15)
4at firebase_core_web.FirebaseCoreWeb.new.initializeApp (http://localhost:7357/packages/firebase_core_web/firebase_core_web.dart.lib.js:252:42)
5    at initializeApp.next (&lt;anonymous&gt;)
6    at http://localhost:7357/dart_sdk.js:40192:33
7    at _RootZone.runUnary (http://localhost:7357/dart_sdk.js:40062:59)
8    at _FutureListener.thenAwait.handleValue (http://localhost:7357/dart_sdk.js:34983:29)
9    at handleValueCallback (http://localhost:7357/dart_sdk.js:35551:49)
10    at Function._propagateToListeners (http://localhost:7357/dart_sdk.js:35589:17)
11    at _Future.new.[_completeWithValue] (http://localhost:7357/dart_sdk.js:35437:23)
12    at async._AsyncCallbackEntry.new.callback (http://localhost:7357/dart_sdk.js:35458:35)
13    at Object._microtaskLoop (http://localhost:7357/dart_sdk.js:40330:13)
14    at _startMicrotaskLoop (http://localhost:7357/dart_sdk.js:40336:13)
15    at http://localhost:7357/dart_sdk.js:35811:9
16&lt;!DOCTYPE html&gt;
17&lt;html&gt;
18&lt;head&gt;
19  &lt;!--
20    If you are serving your web app in a path other than the root, change the
21    href value below to reflect the base path you are serving from.
22
23    The path provided below has to start and end with a slash &quot;/&quot; in order for
24    it to work correctly.
25
26    For more details:
27    * https://developer.mozilla.org/en-US/docs/Web/HTML/Element/base
28
29    This is a placeholder for base href that will be replaced by the value of
30    the `--base-href` argument provided to `flutter build`.
31  --&gt;
32  &lt;base href=&quot;$FLUTTER_BASE_HREF&quot;&gt;
33
34  &lt;meta charset=&quot;UTF-8&quot;&gt;
35  &lt;meta content=&quot;IE=Edge&quot; http-equiv=&quot;X-UA-Compatible&quot;&gt;
36  &lt;meta name=&quot;description&quot; content=&quot;A new Flutter project.&quot;&gt;
37  &lt;meta name=&quot;google-signin-client_id&quot; content=&quot;619218114547-xxxx.apps.googleusercontent.com&quot;&gt;
38  &lt;!-- iOS meta tags &amp; icons --&gt;
39  &lt;meta name=&quot;apple-mobile-web-app-capable&quot; content=&quot;yes&quot;&gt;
40  &lt;meta name=&quot;apple-mobile-web-app-status-bar-style&quot; content=&quot;black&quot;&gt;
41  &lt;meta name=&quot;apple-mobile-web-app-title&quot; content=&quot;signin_example&quot;&gt;
42  &lt;link rel=&quot;apple-touch-icon&quot; href=&quot;icons/Icon-192.png&quot;&gt;
43  
44  &lt;!-- Favicon --&gt;
45  &lt;link rel=&quot;icon&quot; type=&quot;image/png&quot; href=&quot;favicon.png&quot;/&gt;
46
47  &lt;title&gt;signin_example&lt;/title&gt;
48  &lt;link rel=&quot;manifest&quot; href=&quot;manifest.json&quot;&gt;
49&lt;/head&gt;
50&lt;body&gt;
51  &lt;!-- This script installs service_worker.js to provide PWA functionality to
52       application. For more information, see:
53       https://developers.google.com/web/fundamentals/primers/service-workers --&gt;
54  
55  
56  &lt;script&gt;
57    var serviceWorkerVersion = null;
58    var scriptLoaded = false;
59    function loadMainDartJs() {
60      if (scriptLoaded) {
61        return;
62      }
63      scriptLoaded = true;
64      var scriptTag = document.createElement('script');
65      scriptTag.src = 'main.dart.js';
66      scriptTag.type = 'application/javascript';
67      document.body.append(scriptTag);
68    }
69
70    if ('serviceWorker' in navigator) {
71      // Service workers are supported. Use them.
72      window.addEventListener('load', function () {
73        // Wait for registration to finish before dropping the &lt;script&gt; tag.
74        // Otherwise, the browser will load the script multiple times,
75        // potentially different versions.
76        var serviceWorkerUrl = 'flutter_service_worker.js?v=' + serviceWorkerVersion;
77        navigator.serviceWorker.register(serviceWorkerUrl)
78          .then((reg) =&gt; {
79            function waitForActivation(serviceWorker) {
80              serviceWorker.addEventListener('statechange', () =&gt; {
81                if (serviceWorker.state == 'activated') {
82                  console.log('Installed new service worker.');
83                  loadMainDartJs();
84                }
85              });
86            }
87            if (!reg.active &amp;&amp; (reg.installing || reg.waiting)) {
88              // No active web worker and we have installed or are installing
89              // one for the first time. Simply wait for it to activate.
90              waitForActivation(reg.installing || reg.waiting);
91            } else if (!reg.active.scriptURL.endsWith(serviceWorkerVersion)) {
92              // When the app updates the serviceWorkerVersion changes, so we
93              // need to ask the service worker to update.
94              console.log('New service worker available.');
95              reg.update();
96              waitForActivation(reg.installing);
97            } else {
98              // Existing service worker is still good.
99              console.log('Loading app from service worker.');
100              loadMainDartJs();
101            }
102          });
103
104        // If service worker doesn't succeed in a reasonable amount of time,
105        // fallback to plaint &lt;script&gt; tag.
106        setTimeout(() =&gt; {
107          if (!scriptLoaded) {
108            console.warn(
109              'Failed to load app from service worker. Falling back to plain &lt;script&gt; tag.',
110            );
111            loadMainDartJs();
112          }
113        }, 4000);
114      });
115    } else {
116      // Service workers not supported. Just drop the &lt;script&gt; tag.
117      loadMainDartJs();
118    }
119  &lt;/script&gt;
120  &lt;script type=&quot;module&quot;&gt;
121    // Import the functions you need from the SDKs you need
122    import { initializeApp } from &quot;https://www.gstatic.com/firebasejs/9.6.0/firebase-app.js&quot;;
123    import { getAnalytics } from &quot;https://www.gstatic.com/firebasejs/9.6.0/firebase-analytics.js&quot;;
124    // TODO: Add SDKs for Firebase products that you want to use
125    // https://firebase.google.com/docs/web/setup#available-libraries
126
127    // Your web app's Firebase configuration
128    // For Firebase JS SDK v7.20.0 and later, measurementId is optional
129    const firebaseConfig = {
130      apiKey: &quot;xxx&quot;,
131      authDomain: &quot;xxx&quot;,
132      projectId: &quot;xx&quot;,
133      storageBucket: &quot;exxx&quot;,
134      messagingSenderId: &quot;xxx&quot;,
135      appId: &quot;xxx&quot;,
136      measurementId: &quot;xxx&quot;
137    };
138
139    // Initialize Firebase
140    const app = initializeApp(firebaseConfig);
141    const analytics = getAnalytics(app);
142  &lt;/script&gt;
143&lt;/body&gt;
144&lt;/html&gt;
145void main() async {
146  WidgetsFlutterBinding.ensureInitialized();
147  await Firebase.initializeApp();
148  runApp(SignUpApp());
149}
150name: signin_example
151description: A new Flutter project.
152
153# The following line prevents the package from being accidentally published to
154# pub.dev using `flutter pub publish`. This is preferred for private packages.
155publish_to: 'none' # Remove this line if you wish to publish to pub.dev
156
157https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
158version: 1.0.0+1
159
160environment:
161  sdk: &quot;&gt;=2.15.0-268.18.beta &lt;3.0.0&quot;
162
163dependencies:
164  flutter:
165    sdk: flutter
166
167
168  # The following adds the Cupertino Icons font to your application.
169  # Use with the CupertinoIcons class for iOS style icons.
170  cupertino_icons: ^1.0.2
171  firebase_auth: ^3.3.0
172  firebase_core: ^1.10.2
173  google_sign_in: ^5.2.1
174  shared_preferences: ^2.0.9
175
176dev_dependencies:
177  flutter_test:
178    sdk: flutter
179
180  flutter_lints: ^1.0.0
181
182# The following section is specific to Flutter.
183flutter:
184
185  assets:
186    - assets/images/
187
188  uses-material-design: true
189void main() async {
190  WidgetsFlutterBinding.ensureInitialized();
191  await Firebase.initializeApp(
192    // Replace with actual values
193    options: FirebaseOptions(
194      apiKey: &quot;XXX&quot;,
195      appId: &quot;XXX&quot;,
196      messagingSenderId: &quot;XXX&quot;,
197      projectId: &quot;XXX&quot;,
198    ),
199  );
200  runApp(MyApp());
201}
202dart pub global activate flutterfire_cli
203flutterfire configure
204void main() async {
205  WidgetsFlutterBinding.ensureInitialized();
206  await Firebase.initializeApp(
207    options: DefaultFirebaseOptions.currentPlatform,
208  );
209  runApp(MyApp());
210}
211  &lt;script src=&quot;https://www.gstatic.com/firebasejs/8.6.1/firebase-app.js&quot;&gt;&lt;/script&gt;
212  &lt;script src=&quot;https://www.gstatic.com/firebasejs/8.6.1/firebase-analytics.js&quot;&gt;&lt;/script&gt;
213  &lt;script&gt;
214    var firebaseConfig = {
215      apiKey: &quot;xxx&quot;,
216      authDomain: &quot;xxx&quot;,
217      projectId: &quot;xx&quot;,
218      storageBucket: &quot;exxx&quot;,
219      messagingSenderId: &quot;xxx&quot;,
220      appId: &quot;xxx&quot;,
221      measurementId: &quot;xxx&quot;
222    };
223
224    firebase.initializeApp(firebaseConfig);
225    firebase.analytics();
226  &lt;/script&gt;
227

Source https://stackoverflow.com/questions/70232931

Community Discussions contain sources that include Stack Exchange Network

Tutorials and Learning Resources in Tutorial

Share this Page

share link

Get latest updates on Tutorial