Flutter firebase auth for desktop - flutter

I'm trying to create an app that performs a Firebase authorization on a desktop.
I didn't find any full sample code for this so I started by create a basic demo project on VScode.
As soon as I add the package flutter pub add firebase_auth_desktop (without adding code to the app), I get errors when I try to run the app.
/C:/Users/yvan_/AppData/Local/Pub/Cache/hosted/pub.dev/firebase_core-1.24.0/lib/src/firebase_app.dart(18,25): error G75B77105: Member not found: 'FirebaseAppPlatform.verifyExtends'.
[C:\FDSTiming\Project\Flutter\app3\build\windows\flutter\flutter_assemble.vcxproj]
/C:/Users/yvan_/AppData/Local/Pub/Cache/hosted/pub.dev/firebase_auth_platform_interface-6.10.1/lib/src/action_code_info.dart(65,15): error GE5CFE876: The method 'FallThroughError' isn't defined for the class 'ActionCodeInfo'. [C:\FDSTiming\Project\Flutter\app3\build\windows\flutter\flutter_assemble.vcxproj]
C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Microsoft\VC\v170\Microsoft.CppCommon.targets(247,5): error MSB8066: Custom build for 'C:\FDSTiming\Project\Flutter\app3\build\windows\CMakeFiles\18de2b4c67371752531dc30d7008f913\flutter_windows.dll.rule;C:\FDSTiming\Project\Flutter\app3\build\windows\CMakeFiles\122a37675ed5a5d637290377de62a3e1\flutter_assemble.rule;C:\FDSTiming\Project\Flutter\app3\windows\flutter\CMakeLists.txt' exited with code 1. [C:\FDSTiming\Project\Flutter\app3\build\windows\flutter\flutter_assemble.vcxproj]
Exception: Build process failed.
The code is:
import 'package:flutter/material.dart';
//import 'package:firebase_auth_desktop/firebase_auth_desktop.dart';
void main() {
runApp(const MainApp());
}
class MainApp extends StatelessWidget {
const MainApp({super.key});
#override
Widget build(BuildContext context) {
return const MaterialApp(
home: Scaffold(
body: Center(
child: Text('Hello World!'),
),
),
);
}
}
And pubspec.yaml:
dependencies:
flutter:
sdk: flutter
cupertino_icons: ^1.0.2
firebase_auth_desktop: ^1.0.2
Any idea?
I managed to get rid of the first error by adding:
firebase_core_platform_interface: 4.5.1
firebase_messaging: ^13.0.4
But didn't find any clues for the others errors

The flutter firebase_core dependency currently not supported by windows platform.

Related

[ERROR: Unable to load asset: assets/audios/note1.wav in flutter

I have this question. My code actually working but when I click my button there is no new sound. I actually change the name of directory folder but it didn't work.
import 'package:flutter/material.dart';
import 'package:audioplayers/audioplayers.dart';
import 'dart:math';
void main() => runApp(XylophoneApp());
class XylophoneApp extends StatelessWidget {
void playSound () {
final player = AudioPlayer();
int soundNumber = Random().nextInt(5) + 1;
player.setSource(AssetSource('sounds/note$soundNumber.wav'));
}
#override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
body: SafeArea(
child: Center(
child:TextButton
(onPressed: () {
playSound();
},
child:const Text('Click Me')),
),
),
),
);
}
}
Here is the result:
E/flutter ( 8119): [ERROR:flutter/lib/ui/ui_dart_state.cc(198)]
Unhandled Exception: Unable to load asset: assets/audios/note1.wav
E/flutter ( 8119): #0 PlatformAssetBundle.load
(package:flutter/src/services/asset_bundle.dart:237:7)
E/flutter ( 8119): <asynchronous suspension>
yaml file :
assets:
- assets/sounds/
You have to add this file in assets section in pubspec.yaml file
assets:
- assets/audios/note1.wav
try to move your sub audio folder out of your former asset folder that comes by default . and place it direct to your project new folder like lib folder in the first level
sometimes flutter does not see the external files .
and for better work done clean your engine .
As I'm working in the Xylophone project
I did this to run my APP:
You can add new project and then rewrite your code line by line and debug it
probably it is because of some change that you have done.
Change the package I recommend you to add the new package in new projects
PS: If you are in windows before everything quit the Android Studio from the Task Manager and shut down your computer then start everything from the beginning
If you find new solution let me know
Thank you

My Flutter web app logout every time whenever I made change in code in vs code and hot reload

I am using Firebase Authentication on my Flutter Web app, but the session is not persisted after hot restart or refresh in chrome.
In Android it work properly but in web app after hot reload or chrome refresh user logged out.
After googling and finding for about more than 12hr still not I still not get solution.
also follow this answer of #frank-van-puffelen 's solution but still facing same problem.
this ticket is still not resolved.
If possible please run below code.
I look forward to your answer.
Here is my code in main.dart
Future<void> main() async {
WidgetsFlutterBinding.ensureInitialized();
await Firebase.initializeApp(
options: DefaultFirebaseOptions.currentPlatform,
);
runApp(const AuthGate());
}
class AuthGate extends StatelessWidget {
const AuthGate({Key? key}) : super(key: key);
#override
Widget build(BuildContext context) {
return MaterialApp(
home: StreamBuilder<User?>(
stream: FirebaseAuth.instance.authStateChanges(),
builder: (BuildContext context, AsyncSnapshot<User?> snapshot) {
if (!snapshot.hasData) {
return const FlutterFireUiLogin();
} else {
return const Text("You are Logged In");
}
},
),
);
}
}
And here is my flutterfire_ui_login.dart
import 'package:flutter/material.dart';
import 'package:flutterfire_ui/auth.dart';
class FlutterFireUiLogin extends StatelessWidget {
const FlutterFireUiLogin({Key? key}) : super(key: key);
#override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(),
body: Container(
padding: const EdgeInsets.all(20),
child: SignInScreen(
providerConfigs: const [
EmailProviderConfiguration(),
PhoneProviderConfiguration(),
],
),
),
);
}
}
Here is my pubspec.yaml
version: 1.0.0+1
environment:
sdk: ">=2.17.6 <3.0.0"
dependencies:
flutter:
sdk: flutter
authentication_repository:
path: packages/authentication_repository
form_inputs:
path: packages/form_inputs
cupertino_icons: ^1.0.2
firebase_auth: ^3.5.0
firebase_core: ^1.20.0
equatable: ^2.0.3
cloud_firestore: ^3.4.0
flutter_bloc: ^8.0.1
firebase_storage: ^10.3.3
rxdart: ^0.27.5
formz: any
meta: any
very_good_analysis: any
flow_builder: any
google_fonts: ^3.0.1
flutterfire_ui: ^0.4.3
font_awesome_flutter: ^10.1.0
google_sign_in: ^5.4.0
google_sign_in_web: ^0.10.2
http: ^0.13.4
path: ^1.8.1
csv: ^5.0.1
provider: ^6.0.3
flutter_lints: ^1.0.4
dev_dependencies:
flutter_test:
sdk: flutter
mocktail: ^0.3.0
flutter doctor
Doctor summary (to see all details, run flutter doctor -v):
[√] Flutter (Channel stable, 3.0.5, on Microsoft Windows [Version 10.0.22000.795], locale en-IN)
[√] Android toolchain - develop for Android devices (Android SDK version 31.0.0)
[√] Chrome - develop for the web
[!] Visual Studio - develop for Windows (Visual Studio Build Tools 2019 16.11.8)
X The current Visual Studio installation is incomplete. Please reinstall Visual Studio.
[√] Android Studio (version 2020.3)
[√] IntelliJ IDEA Community Edition (version 2021.2)
[√] VS Code (version 1.69.2)
[√] Connected device (3 available)
[√] HTTP Host Availability
! Doctor found issues in 1 category.
This fix has just been released in the latest version 3.6.0.

Error running sample Flutter Provider program

I am trying to run sample Riverpod program from Getting started Riverpod page
Pubspec is specified as given on the page.
Debug Console dumps the following message:
Launching lib/main.dart on Chrome in debug mode...
lib/main.dart:1
: Error: Method not found: 'Error.throwWithStackTrace'.
../…/framework/provider_base.dart:985
Error.throwWithStackTrace(error, chain);
^^^^^^^^^^^^^^^^^^^
: Error: A non-null value must be returned since the return type 'Never' doesn't
allow null.
../…/framework/provider_base.dart:979
Never _rethrowProviderError(Object error, StackTrace stackTrace) {
^
Failed to compile application.
Exited (sigterm)
Just to be sure, following is main.dart:
import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
// We create a "provider", which will store a value (here "Hello world").
// By using a provider, this allows us to mock/override the value exposed.
final helloWorldProvider = Provider((_) => 'Hello world');
void main() {
runApp(
// For widgets to be able to read providers, we need to wrap the entire
// application in a "ProviderScope" widget.
// This is where the state of our providers will be stored.
const ProviderScope(
child: MyApp(),
),
);
}
// Extend ConsumerWidget instead of StatelessWidget, which is exposed by Riverpod
class MyApp extends ConsumerWidget {
const MyApp({Key? key}) : super(key: key);
#override
Widget build(BuildContext context, WidgetRef ref) {
final String value = ref.watch(helloWorldProvider);
return MaterialApp(
home: Scaffold(
appBar: AppBar(title: const Text('Example')),
body: Center(
child: Text(value),
),
),
);
}
}
And pubspec is as follows:
name: simple_app
description: A new Flutter project.
publish_to: 'none' # Remove this line if you wish to publish to pub.dev
version: 1.0.0+1
environment:
sdk: ">=2.12.0 <3.0.0"
flutter: ">=2.0.0"
dependencies:
flutter:
sdk: flutter
flutter_riverpod: ^2.0.0-dev.4
cupertino_icons: ^1.0.2
dev_dependencies:
flutter_test:
sdk: flutter
flutter_lints: ^1.0.0
flutter:
uses-material-design: true
Environment:
Flutter (Channel stable, 2.5.3, on macOS 12.2.1 21D62 darwin-x64, locale en-US)

Flutter Error: Getter not found: 'wordPair' in english_words.dart package

i recently started learning flutter. I was working on the 'package:english_words/english_words.dart' package. I have successfully imported it by modifying the pubspec.yaml file by adding 'english_words: ^3.1.0 inside dependencies and on the main.dart file child:Text(wordPair.asPascalCase) is throwing an error. The output I got after running it is :
Compiler message:
lib/main.dart:17:23: Error: Getter not found: 'wordPair'.
Target kernel_snapshot failed: Exception: Errors during snapshot creation: null
build failed.
FAILURE: Build failed with an exception.
Where:
Script 'C:\flutter\packages\flutter_tools\gradle\flutter.gradle' line: 780
What went wrong:
Execution failed for task ':app:compileFlutterBuildDebug'.
Process 'command 'C:\flutter\bin\flutter.bat'' finished with non-zero exit value 1
and here is my code:
import 'package:flutter/material.dart';
import 'package:english_words/english_words.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
#override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Welcome to Flutter',
home: Scaffold(
appBar: AppBar(
title: const Text('Welcome to Flutter'),
),
body: const Center(
child: Text(wordPair.asPascalCase),
),
),
);
}
}
my english.dart file is
/// Support for working with English text.
library english_words;
export 'src/syllables.dart';
export 'src/word_pair.dart';
export 'src/words/adjectives.dart';
export 'src/words/all.dart';
export 'src/words/nouns.dart';
This file comes from the flutter package, you won't have to modify it.
library english_words;
export 'src/syllables.dart';
export 'src/word_pair.dart';
export 'src/words/adjectives.dart';
export 'src/words/all.dart';
export 'src/words/nouns.dart';
The problem is the understanding of the english_words package. Using wordPair makes no sense since you didn't declared it.
You can't access the asPascalCase getter with a static instance of WordPair. So you will have to create an instance of WordPair and then use the pascalCase getter.
import 'package:english_words/english_words.dart';
var wordpair = WordPair("first,", "second");
String pascalCase = wordpair.asPascalCase;
The working code for this question is also available here

how to run firstapp flutter 1.5

i tryed testdrive for flutter installed on windows as here https://flutter.dev/docs/get-started/test-drive
defaut application generated work, well, but when i try to follow the snd part at
https://flutter.dev/docs/get-started/codelab
i get errors:
error: The function 'MyApp' isn't defined. (undefined_function at [flutter_app007] lib\main.dart:3)
error: 'MaterialApp' isn't a function. (invocation_of_non_function at [flutter_app007] lib\main.dart:8)
error: 'Scaffold' isn't a function. (invocation_of_non_function at [flutter_app007] lib\main.dart:10)
error: 'AppBar' isn't a function. (invocation_of_non_function at [flutter_app007] lib\main.dart:11)
for this code in main.dart
import 'package:flutter/material.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
#override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Welcome to Flutter',
home: Scaffold(
appBar: AppBar(
title: const Text('Welcome to Flutter'),
),
body: const Center(
child: const Text('Hello World'),
),
),
);
}
}
i checked flutter doctor, but show nothing bad.. any idea?
go to the project directory and open windows cmd. and try flutter run
ok, i finally resolved the problem.
when i was typed 'flutter_console.bat', i was get after, 'mysql is unknow program '. i finally founded that an install of MySQL Fabric 1.5 & MySQL Utilities 1.5\ setted his path in PATH env variable. this path poisonned result path integration , returning 'mysql is unknow program' and stopping project generation.. . desinstalling the mysql software solved the problem by cleaning path from his entry and now, the project can be created and work as expected..
very strange, no..?