main.dart
import 'dart:ffi';
import 'package:flutter/material.dart';
import 'package:lewandowski/models/bro.dart';
import 'package:lewandowski/services/auth.dart';
import 'package:lewandowski/wrapper.dart';
import 'package:lewandowski/models/bro.dart';
import 'package:lewandowski/services/auth.dart';
import 'package:provider/provider.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({Key? key}) : super(key: key);
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
return [https://www.mediafire.com/file/1faigtbe4o3k4dd/Capure.PNG/file]StreamProvider<Bro>.value(
value: AuthService().user,
child: MaterialApp(
home: Wrapper(),
),
);
}
}
auth.dart
[import 'package:firebase_auth/firebase_auth.dart';
import 'package:flutter/foundation.dart';
import 'package:lewandowski/models/bro.dart';
class AuthService{
// method to sign in anon
final FirebaseAuth _auth = FirebaseAuth.instance;
Bro? get bro => null;
// create an object based on firebaseuser
Bro? _userfromFirebaseUser(Bro user){
return User != null ? Bro(uid:user.uid) : null;
}
// change user stream
Stream<Bro> get user {
return _auth.authStateChanges
[https://www.mediafire.com/file/qr6lr38khjgt456/Capture.PNG/file].map(_userfromFirebaseUser(bro!));
}
Future signAnon() async {
try {
UserCredential result = await _auth.signInAnonymously();
User? user = result.user;
return user;
}
catch (e) {
print(e.toString());
return null;
}
}
// method to sign in with email and password
// method to sign up with email and password
//method to sign out
}][1]
Running Gradle task 'assembleDebug'... lib/main.dart:21:37: Error: Required named parameter 'initialData' must be provided. return StreamProvider.value( ^ ../flutter/.pub-cache/hosted/pub.dartlang.org/provider-6.0.3/lib/src/async_provider.dart:102:3: Context: Found this candidate, but the arguments don't match. StreamProvider.value({ ^^^^^^^^^^^^^^^^^^^^ lib/services/auth.dart:18:10: Error: The method 'map' isn't defined for the class 'Stream<User?> Function()'.
- 'Stream' is from 'dart:async'.
- 'User' is from 'package:firebase_auth/firebase_auth.dart' ('../flutter/.pub-cache/hosted/pub.dartlang.org/firebase_auth-3.9.0/lib/firebase_auth.dart'). Try correcting the name to the name of an existing method, or defining a method named 'map'. .map(_userfromFirebaseUser(bro!)); ^^^
FAILURE: Build failed with an exception.
Where: Script 'E:\Development\flutter\packages\flutter_tools\gradle\flutter.gradle' line: 1156
What went wrong: Execution failed for task ':app:compileFlutterBuildDebug'.
Process 'command 'E:\Development\flutter\bin\flutter.bat'' finished with non-zero exit value 1
- Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
- Get more help at https://help.gradle.org
BUILD FAILED in 3m 51s Exception: Gradle task assembleDebug failed with exit code 1
bro.dart
class Bro{
final String uid;
Bro({required this.uid});
}