errors in my main.dart on line 21 the return statement and error in my auth,dart on line 18 the map


This Content is from Stack Overflow. Question asked by Robert Balinda


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.
  Widget build(BuildContext context) {
    return StreamProvider<Bro>.value(
        value: AuthService().user,
      child: MaterialApp(
 home: Wrapper(),



[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
  Future signAnon() async {
    try {
      UserCredential result = await _auth.signInAnonymously();
      User? user = result.user;
      return user;
    catch (e) {

      return null;

  // method to sign in with email and password

  // method to sign up with email and password

  //method to sign out


Running Gradle task ‘assembleDebug’…
lib/main.dart:21:37: Error: Required named parameter ‘initialData’ must be provided.
return StreamProvider.value(
../flutter/.pub-cache/hosted/ Context: Found this candidate, but the arguments don’t match.
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/’).
    Try correcting the name to the name of an existing method, or defining a method named ‘map’.

FAILURE: Build failed with an exception.

  • Where:
    Script ‘E:Developmentflutterpackagesflutter_toolsgradleflutter.gradle’ line: 1156

  • What went wrong:
    Execution failed for task ‘:app:compileFlutterBuildDebug’.

Process ‘command ‘E:Developmentflutterbinflutter.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.

BUILD FAILED in 3m 51s
Exception: Gradle task assembleDebug failed with exit code 1


This question is not yet answered, be the first one who answer using the comment. Later the confirmed answer will be published as the solution.

This Question and Answer are collected from stackoverflow and tested by JTuto community, is licensed under the terms of CC BY-SA 2.5. - CC BY-SA 3.0. - CC BY-SA 4.0.

people found this article helpful. What about you?