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
by freeCodeCamp javascript
344419 BSD-3-Clause
freeCodeCamp.org's open-source codebase and curriculum. Learn to code for free.
by trekhleb javascript
138596 MIT
📝 Algorithms and data structures implemented in JavaScript with explanations and links to further readings
by CyC2018 java
137910
:books: 技术面试必备基础知识、Leetcode、计算机操作系统、计算机网络、系统设计
by TheAlgorithms python
117097 MIT
All Algorithms implemented in Python
by kdn251 java
53816 MIT
Everything you need to know to get the job.
by TheAlgorithms java
45287 MIT
All Algorithms implemented in Java
by microsoft javascript
44908 MIT
24 Lessons, 12 Weeks, Get Started as a Web Developer
by azl397985856 javascript
43986 NOASSERTION
LeetCode Solutions: A Record of My Problem Solving Journey.( leetcode题解,记录自己的leetcode解题之路。)
by astaxie go
38531 BSD-3-Clause
A golang ebook intro how to build a web with golang
Trending New libraries in Tutorial
by microsoft javascript
44908 MIT
24 Lessons, 12 Weeks, Get Started as a Web Developer
by geekxh java
29811
🌍 针对小白的算法训练 | 包括四部分:①.算法基础 ②.力扣图解 ③.大厂面经 ④.CS_汇总 | 附:1、千本开源电子书 2、百张技术思维导图(项目花了上百小时,希望可以点 star 支持,🌹感谢~)
by greyireland go
12016
算法模板,最科学的刷题方式,最快速的刷题路径,你值得拥有~
by chefyuan java
8824 MIT
专门为刚开始刷题的同学准备的算法基地,没有最细只有更细,立志用动画将晦涩难懂的算法说的通俗易懂!
by coding-horror csharp
8118 Unlicense
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/
by AkashSingh3031 jupyter notebook
7378 MIT
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.
by Dhghomon shell
6065 MIT
Rust explained using easy English
by yuanguangxin java
5890
LeetCode刷题记录与面试整理
by mdn html
4840 NOASSERTION
The content behind MDN Web Docs
Top Authors in Tutorial
1
126 Libraries
4879
2
90 Libraries
1933
3
53 Libraries
23678
4
48 Libraries
67554
5
35 Libraries
2030
6
35 Libraries
463
7
33 Libraries
12103
8
33 Libraries
25961
9
30 Libraries
594
10
29 Libraries
4333
1
126 Libraries
4879
2
90 Libraries
1933
3
53 Libraries
23678
4
48 Libraries
67554
5
35 Libraries
2030
6
35 Libraries
463
7
33 Libraries
12103
8
33 Libraries
25961
9
30 Libraries
594
10
29 Libraries
4333
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
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.
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.
The Primary School Leaving Examination (PSLE) is a significant milestone in the academic journey of Singaporean students. Among its various components, the PSLE English Oral examination stands out as a crucial assessment of students' proficiency in spoken English. This article aims to provide a comprehensive guide to mastering the PSLE English Oral examination, offering insights into its format, importance, preparation strategies, and tips for success.
Importance of PSLE English Oral Examination
The PSLE English Oral examination holds considerable weight in evaluating a student's language proficiency. It assesses not only their ability to articulate thoughts and express ideas coherently but also their fluency, pronunciation, and intonation. A strong performance in the oral component can significantly impact the overall English grade, underscoring its importance in the PSLE assessment framework.
Understanding the Format of PSLE English Oral Examination
Types of Questions
The PSLE English Oral examination typically includes various question types designed to test different aspects of oral communication skills. These may include reading passages, picture descriptions, situational dialogues, and personal opinion questions. Students are expected to respond effectively to each question type, demonstrating comprehension, critical thinking, and linguistic accuracy.
Evaluation Criteria
To excel in the PSLE English Oral examination, students must meet specific evaluation criteria set by assessors. These criteria often include pronunciation, intonation, articulation, fluency, clarity, coherence, and relevance of responses. Assessors also look for evidence of engagement, creativity, and depth of understanding in students' oral communication.
Tips for Preparation
1. Enhancing Communication Skills
Effective communication is the cornerstone of success in the PSLE English Oral examination. Students should focus on improving their speaking and listening skills through regular practice and exposure to diverse language contexts. Engaging in conversations, reading aloud, and listening to audio recordings can help develop fluency and confidence in spoken English.
2. Practicing Pronunciation and Intonation
Accurate pronunciation and intonation are essential for conveying meaning effectively. Students should practice enunciating words clearly and expressing emotions through variations in pitch and tone. Tongue twisters, phonetic exercises, and mimicking native speakers can aid in improving pronunciation and intonation skills.
3. Building Confidence
Confidence plays a crucial role in oral communication. Encourage students to participate in speaking activities, such as debates, presentations, and role-plays, to boost their self-assurance and poise. Positive reinforcement, supportive feedback, and acknowledging their progress can help build students' confidence in expressing themselves orally.
Strategies for Excelling in PSLE English Oral
1. Effective Time Management
Time management is paramount during the PSLE English Oral examination. Students must allocate sufficient time for each question and ensure they cover all aspects of the prompt within the allotted time. Practicing timed speaking exercises and developing a strategy for organizing thoughts coherently can aid in effective time management.
2. Structuring Responses
Structured responses demonstrate clarity of thought and organization. Encourage students to outline their answers before speaking, incorporating an introduction, body, and conclusion for coherence and cohesion. Emphasize the importance of addressing the question directly, providing relevant examples or evidence to support their points.
3. Handling Nervousness
Nervousness is natural before any examination. Teach students relaxation techniques, such as deep breathing and positive visualization, to manage anxiety and perform optimally during the oral assessment. Encourage them to focus on their preparation, trust in their abilities, and maintain a positive mindset throughout the examination.
Resources for Practice
To prepare for the PSLE English Oral examination, students can utilize various resources to enhance their skills and confidence:
- Practice Papers: Accessing sample questions and practice papers can familiarize students with the format and types of questions asked in the examination. Practicing responses to different prompts can help them refine their oral communication skills and develop effective strategies for tackling each question type.
- Online Tutorials: Online tutorials and instructional videos provide valuable insights, tips, and techniques for mastering oral communication skills. Platforms such as educational websites, YouTube channels, and language learning apps offer a wealth of resources that complement classroom instruction and self-study efforts.
- Language Enrichment Programs: Enrolling in language enrichment programs or extracurricular activities can provide additional support and opportunities for practicing spoken English. Language centers, community organizations, and school-based initiatives offer workshops, seminars, and clubs focused on improving oral communication skills in English.
Conclusion
Mastering the PSLE English Oral examination requires diligent preparation, effective communication skills, and confidence. By understanding the format, focusing on key evaluation criteria, and implementing proven strategies, students can excel in this essential component of the PSLE. With dedication, practice, and access to resources, success in the English Oral examination is achievable for every student.
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: "Inheritance from an interface with '@JvmDefault' members is only allowed with -Xjvm-default option"
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:25Trying 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("path")
5const basePath = process.cwd();
6const fs = require("fs");
7
8fs.readdirSync(`${basePath}/build/images`).foreach(file).forEach(file => {
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 => res.json())
25 .then(json => {
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 & ${fileName}.json updated!`);
35 })
36 .catch(err => console.error('error:' + err));
37})
38
39
ANSWER
Answered 2021-Dec-31 at 10:07It 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.
QUESTION
Invalid CSS value error while Customizing Bootstrap 5 colors with sass 3
Asked 2022-Mar-22 at 12:49I 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 "../../node_modules/bootstrap/scss/variables";
2
3$theme-colors: (
4"primary": //some color here,
5);
6
7@import "../../node_modules/bootstrap/scss/bootstrap";
8
and this is the error I get in terminal
1@import "../../node_modules/bootstrap/scss/variables";
2
3$theme-colors: (
4"primary": //some color here,
5);
6
7@import "../../node_modules/bootstrap/scss/bootstrap";
8PS F:\Coding\projects\sepehr\client\src\styles> sass style.scss custom.css
9Error: ("primary": #0d6efd, "secondary": #6c757d, "success": #198754, "info": #0dcaf0,
10"warning": #ffc107, "danger": #dc3545, "light": #f8f9fa, "dark": #212529) isn't a valid
11CSS value.
12 ╷
1394 │ $theme-colors-rgb: map-loop($theme-colors, to-rgb, "$value") !default;
14 │ ^^^^^^^^^^^^^
15 ╵
16
ANSWER
Answered 2021-Aug-24 at 14:36You need to import functions and mixins too...
1@import "../../node_modules/bootstrap/scss/variables";
2
3$theme-colors: (
4"primary": //some color here,
5);
6
7@import "../../node_modules/bootstrap/scss/bootstrap";
8PS F:\Coding\projects\sepehr\client\src\styles> sass style.scss custom.css
9Error: ("primary": #0d6efd, "secondary": #6c757d, "success": #198754, "info": #0dcaf0,
10"warning": #ffc107, "danger": #dc3545, "light": #f8f9fa, "dark": #212529) isn't a valid
11CSS value.
12 ╷
1394 │ $theme-colors-rgb: map-loop($theme-colors, to-rgb, "$value") !default;
14 │ ^^^^^^^^^^^^^
15 ╵
16@import "../../node_modules/bootstrap/scss/functions";
17@import "../../node_modules/bootstrap/scss/variables";
18@import "../../node_modules/bootstrap/scss/mixins";
19
QUESTION
How do I resolve error message: "Inheritance from an interface with '@JvmDefault' members is only allowed with -Xjvm-default option"
Asked 2022-Mar-19 at 21:08I'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 <T : ViewModel> create(modelClass: Class<T>): T {
3 if (modelClass.isAssignableFrom(exampleViewModel::class.java)) {
4 @Suppress("UNCHECKED_CAST")
5 return ExampleViewModel(exampleDao) as T
6 }
7 throw IllegalArgumentException("Unknown ViewModel class")
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:53It 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 <T : ViewModel> create(modelClass: Class<T>): T {
3 if (modelClass.isAssignableFrom(exampleViewModel::class.java)) {
4 @Suppress("UNCHECKED_CAST")
5 return ExampleViewModel(exampleDao) as T
6 }
7 throw IllegalArgumentException("Unknown ViewModel class")
8 }
9}
10tasks.withType(KotlinCompile).configureEach {
11 kotlinOptions {
12 freeCompilerArgs += [
13 "-Xjvm-default=all",
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
QUESTION
Why does this Cairo program put powers of 2 in the memory?
Asked 2022-Mar-17 at 18:03I'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
ANSWER
Answered 2022-Mar-17 at 15:43Here are some leading questions that can help you reach the answer. Answers to the questions after a break:
- Where does the
jmp rel -1
instruction jump to? - What does the target instruction do? What happens after it?
- How did this instruction end up in the program section of the memory?
jmp rel -1
is encoded in the memory at addresses 5-6. When it is executed, we havepc = 5
, thus after the jump we will execute the instruction atpc = 4
, which is0x48307fff7fff8000
.- 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 executejmp 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). - 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 as0x48307fff7fff8000
. Similarly, the2
at address 2 is the immediate argument of the instruction[fp + 1] = 2
, and the-1
at address 6 is the immediate ofjmp 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.
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:57I 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-
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:41I think you need to install cmdLine
please run flutter doctor and share cmd results to help better
QUESTION
TypeError: load() missing 1 required positional argument: 'Loader' in Google Colab
Asked 2022-Mar-04 at 11:01I 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<ipython-input-19-86e89bd44552> in <module>()
6----> 1 import plotly.express as px
7
89 frames
9/usr/local/lib/python3.7/dist-packages/plotly/express/__init__.py in <module>()
10 13 )
11 14
12---> 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 <module>()
17 9
18 10 try:
19---> 11 import xarray
20 12
21 13 xarray_imported = True
22
23/usr/local/lib/python3.7/dist-packages/xarray/__init__.py in <module>()
24 1 import pkg_resources
25 2
26----> 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 <module>()
31 11 import numpy as np
32 12
33---> 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 <module>()
38 4 formats. They should not be used directly, but rather through Dataset objects.
39 5
40----> 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 <module>()
45 14 _normalize_path,
46 15 )
47---> 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 <module>()
52 11
53 12 try:
54---> 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 <module>()
59 1 # flake8: noqa
60 2 try:
61----> 3 from distributed import *
62 4 except ImportError:
63 5 msg = (
64
65/usr/local/lib/python3.7/dist-packages/distributed/__init__.py in <module>()
66 1 from __future__ import print_function, division, absolute_import
67 2
68----> 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 <module>()
73 18
74 19 with open(fn) as f:
75---> 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:11Found 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<ipython-input-19-86e89bd44552> in <module>()
6----> 1 import plotly.express as px
7
89 frames
9/usr/local/lib/python3.7/dist-packages/plotly/express/__init__.py in <module>()
10 13 )
11 14
12---> 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 <module>()
17 9
18 10 try:
19---> 11 import xarray
20 12
21 13 xarray_imported = True
22
23/usr/local/lib/python3.7/dist-packages/xarray/__init__.py in <module>()
24 1 import pkg_resources
25 2
26----> 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 <module>()
31 11 import numpy as np
32 12
33---> 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 <module>()
38 4 formats. They should not be used directly, but rather through Dataset objects.
39 5
40----> 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 <module>()
45 14 _normalize_path,
46 15 )
47---> 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 <module>()
52 11
53 12 try:
54---> 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 <module>()
59 1 # flake8: noqa
60 2 try:
61----> 3 from distributed import *
62 4 except ImportError:
63 5 msg = (
64
65/usr/local/lib/python3.7/dist-packages/distributed/__init__.py in <module>()
66 1 from __future__ import print_function, division, absolute_import
67 2
68----> 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 <module>()
73 18
74 19 with open(fn) as f:
75---> 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.
QUESTION
How can I configure Hardhat to work with RSK regtest blockchain?
Asked 2022-Jan-20 at 08:01I 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: "127.0.0.1",
3 port: 4444,
4 network_id: "*"
5},
6
What hardhat.config.js
configuration do I need to run my tests on RSK regtest?
ANSWER
Answered 2022-Jan-20 at 08:01To deploy and test your smart contracts on RSK regtest yourhardhat.config.js
should look as follows:
1development: {
2 host: "127.0.0.1",
3 port: 4444,
4 network_id: "*"
5},
6/**
7 * @type import('hardhat/config').HardhatUserConfig
8 */
9require("@nomiclabs/hardhat-waffle");
10
11module.exports = {
12 solidity: "0.7.3",
13 defaultNetwork: "rskregtest",
14 networks: {
15 rskregtest: {
16 url: "http://localhost:4444/",
17 },
18 },
19};
20
Then you'll be able to run your tests by typing in the terminal
1development: {
2 host: "127.0.0.1",
3 port: 4444,
4 network_id: "*"
5},
6/**
7 * @type import('hardhat/config').HardhatUserConfig
8 */
9require("@nomiclabs/hardhat-waffle");
10
11module.exports = {
12 solidity: "0.7.3",
13 defaultNetwork: "rskregtest",
14 networks: {
15 rskregtest: {
16 url: "http://localhost:4444/",
17 },
18 },
19};
20% npx hardhat test
21
QUESTION
Flutter (2.5) - A splash screen was provided to Flutter, but this is deprecated
Asked 2022-Jan-19 at 05:24I 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: "#FFFFFF"
3 color_dark: "#000000"
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:24AndroidManifest.xml
file.
Previously, Android Flutter apps would either set
io.flutter.embedding.android.SplashScreenDrawable
in their application manifest, or implementprovideSplashScreen
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.
QUESTION
What to use instead of TaskException for ReviewManager Api?
Asked 2022-Jan-11 at 08:45Trying 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 ->
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 ->
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:45I 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 ->
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 -> {
15 exception.errorCode
16 }
17 is RuntimeExecutionException -> {
18 exception.errorCode
19 }
20 else -> {
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
QUESTION
FirebaseOptions cannot be null when creating the default app
Asked 2021-Dec-25 at 09:13I 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"FirebaseOptions cannot be null when creating the default app."
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 (<anonymous>)
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"FirebaseOptions cannot be null when creating the default app."
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 (<anonymous>)
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<!DOCTYPE html>
17<html>
18<head>
19 <!--
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 "/" 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 -->
32 <base href="$FLUTTER_BASE_HREF">
33
34 <meta charset="UTF-8">
35 <meta content="IE=Edge" http-equiv="X-UA-Compatible">
36 <meta name="description" content="A new Flutter project.">
37 <meta name="google-signin-client_id" content="619218114547-xxxx.apps.googleusercontent.com">
38 <!-- iOS meta tags & icons -->
39 <meta name="apple-mobile-web-app-capable" content="yes">
40 <meta name="apple-mobile-web-app-status-bar-style" content="black">
41 <meta name="apple-mobile-web-app-title" content="signin_example">
42 <link rel="apple-touch-icon" href="icons/Icon-192.png">
43
44 <!-- Favicon -->
45 <link rel="icon" type="image/png" href="favicon.png"/>
46
47 <title>signin_example</title>
48 <link rel="manifest" href="manifest.json">
49</head>
50<body>
51 <!-- 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 -->
54
55
56 <script>
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 <script> 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) => {
79 function waitForActivation(serviceWorker) {
80 serviceWorker.addEventListener('statechange', () => {
81 if (serviceWorker.state == 'activated') {
82 console.log('Installed new service worker.');
83 loadMainDartJs();
84 }
85 });
86 }
87 if (!reg.active && (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 <script> tag.
106 setTimeout(() => {
107 if (!scriptLoaded) {
108 console.warn(
109 'Failed to load app from service worker. Falling back to plain <script> tag.',
110 );
111 loadMainDartJs();
112 }
113 }, 4000);
114 });
115 } else {
116 // Service workers not supported. Just drop the <script> tag.
117 loadMainDartJs();
118 }
119 </script>
120 <script type="module">
121 // Import the functions you need from the SDKs you need
122 import { initializeApp } from "https://www.gstatic.com/firebasejs/9.6.0/firebase-app.js";
123 import { getAnalytics } from "https://www.gstatic.com/firebasejs/9.6.0/firebase-analytics.js";
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: "xxx",
131 authDomain: "xxx",
132 projectId: "xx",
133 storageBucket: "exxx",
134 messagingSenderId: "xxx",
135 appId: "xxx",
136 measurementId: "xxx"
137 };
138
139 // Initialize Firebase
140 const app = initializeApp(firebaseConfig);
141 const analytics = getAnalytics(app);
142 </script>
143</body>
144</html>
145
Part of code from main.dart file where firebase initialisation is happening
1"FirebaseOptions cannot be null when creating the default app."
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 (<anonymous>)
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<!DOCTYPE html>
17<html>
18<head>
19 <!--
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 "/" 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 -->
32 <base href="$FLUTTER_BASE_HREF">
33
34 <meta charset="UTF-8">
35 <meta content="IE=Edge" http-equiv="X-UA-Compatible">
36 <meta name="description" content="A new Flutter project.">
37 <meta name="google-signin-client_id" content="619218114547-xxxx.apps.googleusercontent.com">
38 <!-- iOS meta tags & icons -->
39 <meta name="apple-mobile-web-app-capable" content="yes">
40 <meta name="apple-mobile-web-app-status-bar-style" content="black">
41 <meta name="apple-mobile-web-app-title" content="signin_example">
42 <link rel="apple-touch-icon" href="icons/Icon-192.png">
43
44 <!-- Favicon -->
45 <link rel="icon" type="image/png" href="favicon.png"/>
46
47 <title>signin_example</title>
48 <link rel="manifest" href="manifest.json">
49</head>
50<body>
51 <!-- 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 -->
54
55
56 <script>
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 <script> 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) => {
79 function waitForActivation(serviceWorker) {
80 serviceWorker.addEventListener('statechange', () => {
81 if (serviceWorker.state == 'activated') {
82 console.log('Installed new service worker.');
83 loadMainDartJs();
84 }
85 });
86 }
87 if (!reg.active && (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 <script> tag.
106 setTimeout(() => {
107 if (!scriptLoaded) {
108 console.warn(
109 'Failed to load app from service worker. Falling back to plain <script> tag.',
110 );
111 loadMainDartJs();
112 }
113 }, 4000);
114 });
115 } else {
116 // Service workers not supported. Just drop the <script> tag.
117 loadMainDartJs();
118 }
119 </script>
120 <script type="module">
121 // Import the functions you need from the SDKs you need
122 import { initializeApp } from "https://www.gstatic.com/firebasejs/9.6.0/firebase-app.js";
123 import { getAnalytics } from "https://www.gstatic.com/firebasejs/9.6.0/firebase-analytics.js";
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: "xxx",
131 authDomain: "xxx",
132 projectId: "xx",
133 storageBucket: "exxx",
134 messagingSenderId: "xxx",
135 appId: "xxx",
136 measurementId: "xxx"
137 };
138
139 // Initialize Firebase
140 const app = initializeApp(firebaseConfig);
141 const analytics = getAnalytics(app);
142 </script>
143</body>
144</html>
145void main() async {
146 WidgetsFlutterBinding.ensureInitialized();
147 await Firebase.initializeApp();
148 runApp(SignUpApp());
149}
150
Pubsec.yaml file of the project
1"FirebaseOptions cannot be null when creating the default app."
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 (<anonymous>)
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<!DOCTYPE html>
17<html>
18<head>
19 <!--
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 "/" 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 -->
32 <base href="$FLUTTER_BASE_HREF">
33
34 <meta charset="UTF-8">
35 <meta content="IE=Edge" http-equiv="X-UA-Compatible">
36 <meta name="description" content="A new Flutter project.">
37 <meta name="google-signin-client_id" content="619218114547-xxxx.apps.googleusercontent.com">
38 <!-- iOS meta tags & icons -->
39 <meta name="apple-mobile-web-app-capable" content="yes">
40 <meta name="apple-mobile-web-app-status-bar-style" content="black">
41 <meta name="apple-mobile-web-app-title" content="signin_example">
42 <link rel="apple-touch-icon" href="icons/Icon-192.png">
43
44 <!-- Favicon -->
45 <link rel="icon" type="image/png" href="favicon.png"/>
46
47 <title>signin_example</title>
48 <link rel="manifest" href="manifest.json">
49</head>
50<body>
51 <!-- 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 -->
54
55
56 <script>
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 <script> 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) => {
79 function waitForActivation(serviceWorker) {
80 serviceWorker.addEventListener('statechange', () => {
81 if (serviceWorker.state == 'activated') {
82 console.log('Installed new service worker.');
83 loadMainDartJs();
84 }
85 });
86 }
87 if (!reg.active && (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 <script> tag.
106 setTimeout(() => {
107 if (!scriptLoaded) {
108 console.warn(
109 'Failed to load app from service worker. Falling back to plain <script> tag.',
110 );
111 loadMainDartJs();
112 }
113 }, 4000);
114 });
115 } else {
116 // Service workers not supported. Just drop the <script> tag.
117 loadMainDartJs();
118 }
119 </script>
120 <script type="module">
121 // Import the functions you need from the SDKs you need
122 import { initializeApp } from "https://www.gstatic.com/firebasejs/9.6.0/firebase-app.js";
123 import { getAnalytics } from "https://www.gstatic.com/firebasejs/9.6.0/firebase-analytics.js";
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: "xxx",
131 authDomain: "xxx",
132 projectId: "xx",
133 storageBucket: "exxx",
134 messagingSenderId: "xxx",
135 appId: "xxx",
136 measurementId: "xxx"
137 };
138
139 // Initialize Firebase
140 const app = initializeApp(firebaseConfig);
141 const analytics = getAnalytics(app);
142 </script>
143</body>
144</html>
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: ">=2.15.0-268.18.beta <3.0.0"
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:13UPDATE:
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"FirebaseOptions cannot be null when creating the default app."
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 (<anonymous>)
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<!DOCTYPE html>
17<html>
18<head>
19 <!--
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 "/" 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 -->
32 <base href="$FLUTTER_BASE_HREF">
33
34 <meta charset="UTF-8">
35 <meta content="IE=Edge" http-equiv="X-UA-Compatible">
36 <meta name="description" content="A new Flutter project.">
37 <meta name="google-signin-client_id" content="619218114547-xxxx.apps.googleusercontent.com">
38 <!-- iOS meta tags & icons -->
39 <meta name="apple-mobile-web-app-capable" content="yes">
40 <meta name="apple-mobile-web-app-status-bar-style" content="black">
41 <meta name="apple-mobile-web-app-title" content="signin_example">
42 <link rel="apple-touch-icon" href="icons/Icon-192.png">
43
44 <!-- Favicon -->
45 <link rel="icon" type="image/png" href="favicon.png"/>
46
47 <title>signin_example</title>
48 <link rel="manifest" href="manifest.json">
49</head>
50<body>
51 <!-- 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 -->
54
55
56 <script>
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 <script> 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) => {
79 function waitForActivation(serviceWorker) {
80 serviceWorker.addEventListener('statechange', () => {
81 if (serviceWorker.state == 'activated') {
82 console.log('Installed new service worker.');
83 loadMainDartJs();
84 }
85 });
86 }
87 if (!reg.active && (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 <script> tag.
106 setTimeout(() => {
107 if (!scriptLoaded) {
108 console.warn(
109 'Failed to load app from service worker. Falling back to plain <script> tag.',
110 );
111 loadMainDartJs();
112 }
113 }, 4000);
114 });
115 } else {
116 // Service workers not supported. Just drop the <script> tag.
117 loadMainDartJs();
118 }
119 </script>
120 <script type="module">
121 // Import the functions you need from the SDKs you need
122 import { initializeApp } from "https://www.gstatic.com/firebasejs/9.6.0/firebase-app.js";
123 import { getAnalytics } from "https://www.gstatic.com/firebasejs/9.6.0/firebase-analytics.js";
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: "xxx",
131 authDomain: "xxx",
132 projectId: "xx",
133 storageBucket: "exxx",
134 messagingSenderId: "xxx",
135 appId: "xxx",
136 measurementId: "xxx"
137 };
138
139 // Initialize Firebase
140 const app = initializeApp(firebaseConfig);
141 const analytics = getAnalytics(app);
142 </script>
143</body>
144</html>
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: ">=2.15.0-268.18.beta <3.0.0"
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: "XXX",
195 appId: "XXX",
196 messagingSenderId: "XXX",
197 projectId: "XXX",
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:
- Install Flutterfire CLI:
1"FirebaseOptions cannot be null when creating the default app."
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 (<anonymous>)
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<!DOCTYPE html>
17<html>
18<head>
19 <!--
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 "/" 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 -->
32 <base href="$FLUTTER_BASE_HREF">
33
34 <meta charset="UTF-8">
35 <meta content="IE=Edge" http-equiv="X-UA-Compatible">
36 <meta name="description" content="A new Flutter project.">
37 <meta name="google-signin-client_id" content="619218114547-xxxx.apps.googleusercontent.com">
38 <!-- iOS meta tags & icons -->
39 <meta name="apple-mobile-web-app-capable" content="yes">
40 <meta name="apple-mobile-web-app-status-bar-style" content="black">
41 <meta name="apple-mobile-web-app-title" content="signin_example">
42 <link rel="apple-touch-icon" href="icons/Icon-192.png">
43
44 <!-- Favicon -->
45 <link rel="icon" type="image/png" href="favicon.png"/>
46
47 <title>signin_example</title>
48 <link rel="manifest" href="manifest.json">
49</head>
50<body>
51 <!-- 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 -->
54
55
56 <script>
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 <script> 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) => {
79 function waitForActivation(serviceWorker) {
80 serviceWorker.addEventListener('statechange', () => {
81 if (serviceWorker.state == 'activated') {
82 console.log('Installed new service worker.');
83 loadMainDartJs();
84 }
85 });
86 }
87 if (!reg.active && (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 <script> tag.
106 setTimeout(() => {
107 if (!scriptLoaded) {
108 console.warn(
109 'Failed to load app from service worker. Falling back to plain <script> tag.',
110 );
111 loadMainDartJs();
112 }
113 }, 4000);
114 });
115 } else {
116 // Service workers not supported. Just drop the <script> tag.
117 loadMainDartJs();
118 }
119 </script>
120 <script type="module">
121 // Import the functions you need from the SDKs you need
122 import { initializeApp } from "https://www.gstatic.com/firebasejs/9.6.0/firebase-app.js";
123 import { getAnalytics } from "https://www.gstatic.com/firebasejs/9.6.0/firebase-analytics.js";
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: "xxx",
131 authDomain: "xxx",
132 projectId: "xx",
133 storageBucket: "exxx",
134 messagingSenderId: "xxx",
135 appId: "xxx",
136 measurementId: "xxx"
137 };
138
139 // Initialize Firebase
140 const app = initializeApp(firebaseConfig);
141 const analytics = getAnalytics(app);
142 </script>
143</body>
144</html>
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: ">=2.15.0-268.18.beta <3.0.0"
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: "XXX",
195 appId: "XXX",
196 messagingSenderId: "XXX",
197 projectId: "XXX",
198 ),
199 );
200 runApp(MyApp());
201}
202dart pub global activate flutterfire_cli
203
- Configure Flutterfire (run in your project's root and go through the wizard selecting the correct Firebase project and target platforms):
1"FirebaseOptions cannot be null when creating the default app."
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 (<anonymous>)
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<!DOCTYPE html>
17<html>
18<head>
19 <!--
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 "/" 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 -->
32 <base href="$FLUTTER_BASE_HREF">
33
34 <meta charset="UTF-8">
35 <meta content="IE=Edge" http-equiv="X-UA-Compatible">
36 <meta name="description" content="A new Flutter project.">
37 <meta name="google-signin-client_id" content="619218114547-xxxx.apps.googleusercontent.com">
38 <!-- iOS meta tags & icons -->
39 <meta name="apple-mobile-web-app-capable" content="yes">
40 <meta name="apple-mobile-web-app-status-bar-style" content="black">
41 <meta name="apple-mobile-web-app-title" content="signin_example">
42 <link rel="apple-touch-icon" href="icons/Icon-192.png">
43
44 <!-- Favicon -->
45 <link rel="icon" type="image/png" href="favicon.png"/>
46
47 <title>signin_example</title>
48 <link rel="manifest" href="manifest.json">
49</head>
50<body>
51 <!-- 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 -->
54
55
56 <script>
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 <script> 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) => {
79 function waitForActivation(serviceWorker) {
80 serviceWorker.addEventListener('statechange', () => {
81 if (serviceWorker.state == 'activated') {
82 console.log('Installed new service worker.');
83 loadMainDartJs();
84 }
85 });
86 }
87 if (!reg.active && (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 <script> tag.
106 setTimeout(() => {
107 if (!scriptLoaded) {
108 console.warn(
109 'Failed to load app from service worker. Falling back to plain <script> tag.',
110 );
111 loadMainDartJs();
112 }
113 }, 4000);
114 });
115 } else {
116 // Service workers not supported. Just drop the <script> tag.
117 loadMainDartJs();
118 }
119 </script>
120 <script type="module">
121 // Import the functions you need from the SDKs you need
122 import { initializeApp } from "https://www.gstatic.com/firebasejs/9.6.0/firebase-app.js";
123 import { getAnalytics } from "https://www.gstatic.com/firebasejs/9.6.0/firebase-analytics.js";
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: "xxx",
131 authDomain: "xxx",
132 projectId: "xx",
133 storageBucket: "exxx",
134 messagingSenderId: "xxx",
135 appId: "xxx",
136 measurementId: "xxx"
137 };
138
139 // Initialize Firebase
140 const app = initializeApp(firebaseConfig);
141 const analytics = getAnalytics(app);
142 </script>
143</body>
144</html>
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: ">=2.15.0-268.18.beta <3.0.0"
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: "XXX",
195 appId: "XXX",
196 messagingSenderId: "XXX",
197 projectId: "XXX",
198 ),
199 );
200 runApp(MyApp());
201}
202dart pub global activate flutterfire_cli
203flutterfire configure
204
- Import the automatically generated
firebase_options.dart
file in yourmain.dart
file and initializeFirebase
as follows:
1"FirebaseOptions cannot be null when creating the default app."
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 (<anonymous>)
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<!DOCTYPE html>
17<html>
18<head>
19 <!--
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 "/" 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 -->
32 <base href="$FLUTTER_BASE_HREF">
33
34 <meta charset="UTF-8">
35 <meta content="IE=Edge" http-equiv="X-UA-Compatible">
36 <meta name="description" content="A new Flutter project.">
37 <meta name="google-signin-client_id" content="619218114547-xxxx.apps.googleusercontent.com">
38 <!-- iOS meta tags & icons -->
39 <meta name="apple-mobile-web-app-capable" content="yes">
40 <meta name="apple-mobile-web-app-status-bar-style" content="black">
41 <meta name="apple-mobile-web-app-title" content="signin_example">
42 <link rel="apple-touch-icon" href="icons/Icon-192.png">
43
44 <!-- Favicon -->
45 <link rel="icon" type="image/png" href="favicon.png"/>
46
47 <title>signin_example</title>
48 <link rel="manifest" href="manifest.json">
49</head>
50<body>
51 <!-- 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 -->
54
55
56 <script>
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 <script> 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) => {
79 function waitForActivation(serviceWorker) {
80 serviceWorker.addEventListener('statechange', () => {
81 if (serviceWorker.state == 'activated') {
82 console.log('Installed new service worker.');
83 loadMainDartJs();
84 }
85 });
86 }
87 if (!reg.active && (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 <script> tag.
106 setTimeout(() => {
107 if (!scriptLoaded) {
108 console.warn(
109 'Failed to load app from service worker. Falling back to plain <script> tag.',
110 );
111 loadMainDartJs();
112 }
113 }, 4000);
114 });
115 } else {
116 // Service workers not supported. Just drop the <script> tag.
117 loadMainDartJs();
118 }
119 </script>
120 <script type="module">
121 // Import the functions you need from the SDKs you need
122 import { initializeApp } from "https://www.gstatic.com/firebasejs/9.6.0/firebase-app.js";
123 import { getAnalytics } from "https://www.gstatic.com/firebasejs/9.6.0/firebase-analytics.js";
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: "xxx",
131 authDomain: "xxx",
132 projectId: "xx",
133 storageBucket: "exxx",
134 messagingSenderId: "xxx",
135 appId: "xxx",
136 measurementId: "xxx"
137 };
138
139 // Initialize Firebase
140 const app = initializeApp(firebaseConfig);
141 const analytics = getAnalytics(app);
142 </script>
143</body>
144</html>
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: ">=2.15.0-268.18.beta <3.0.0"
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: "XXX",
195 appId: "XXX",
196 messagingSenderId: "XXX",
197 projectId: "XXX",
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"FirebaseOptions cannot be null when creating the default app."
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 (<anonymous>)
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<!DOCTYPE html>
17<html>
18<head>
19 <!--
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 "/" 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 -->
32 <base href="$FLUTTER_BASE_HREF">
33
34 <meta charset="UTF-8">
35 <meta content="IE=Edge" http-equiv="X-UA-Compatible">
36 <meta name="description" content="A new Flutter project.">
37 <meta name="google-signin-client_id" content="619218114547-xxxx.apps.googleusercontent.com">
38 <!-- iOS meta tags & icons -->
39 <meta name="apple-mobile-web-app-capable" content="yes">
40 <meta name="apple-mobile-web-app-status-bar-style" content="black">
41 <meta name="apple-mobile-web-app-title" content="signin_example">
42 <link rel="apple-touch-icon" href="icons/Icon-192.png">
43
44 <!-- Favicon -->
45 <link rel="icon" type="image/png" href="favicon.png"/>
46
47 <title>signin_example</title>
48 <link rel="manifest" href="manifest.json">
49</head>
50<body>
51 <!-- 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 -->
54
55
56 <script>
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 <script> 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) => {
79 function waitForActivation(serviceWorker) {
80 serviceWorker.addEventListener('statechange', () => {
81 if (serviceWorker.state == 'activated') {
82 console.log('Installed new service worker.');
83 loadMainDartJs();
84 }
85 });
86 }
87 if (!reg.active && (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 <script> tag.
106 setTimeout(() => {
107 if (!scriptLoaded) {
108 console.warn(
109 'Failed to load app from service worker. Falling back to plain <script> tag.',
110 );
111 loadMainDartJs();
112 }
113 }, 4000);
114 });
115 } else {
116 // Service workers not supported. Just drop the <script> tag.
117 loadMainDartJs();
118 }
119 </script>
120 <script type="module">
121 // Import the functions you need from the SDKs you need
122 import { initializeApp } from "https://www.gstatic.com/firebasejs/9.6.0/firebase-app.js";
123 import { getAnalytics } from "https://www.gstatic.com/firebasejs/9.6.0/firebase-analytics.js";
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: "xxx",
131 authDomain: "xxx",
132 projectId: "xx",
133 storageBucket: "exxx",
134 messagingSenderId: "xxx",
135 appId: "xxx",
136 measurementId: "xxx"
137 };
138
139 // Initialize Firebase
140 const app = initializeApp(firebaseConfig);
141 const analytics = getAnalytics(app);
142 </script>
143</body>
144</html>
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: ">=2.15.0-268.18.beta <3.0.0"
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: "XXX",
195 appId: "XXX",
196 messagingSenderId: "XXX",
197 projectId: "XXX",
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 <script src="https://www.gstatic.com/firebasejs/8.6.1/firebase-app.js"></script>
212 <script src="https://www.gstatic.com/firebasejs/8.6.1/firebase-analytics.js"></script>
213 <script>
214 var firebaseConfig = {
215 apiKey: "xxx",
216 authDomain: "xxx",
217 projectId: "xx",
218 storageBucket: "exxx",
219 messagingSenderId: "xxx",
220 appId: "xxx",
221 measurementId: "xxx"
222 };
223
224 firebase.initializeApp(firebaseConfig);
225 firebase.analytics();
226 </script>
227
Community Discussions contain sources that include Stack Exchange Network