i got error dart analysis -
error: The method 'document' isn't defined for the type 'CollectionReference'. (undefined_method at [food_app] libscrprovidersauth.dart:51)
error: The function 'MyApp' isn't defined. (undefined_function at [food_app] testwidget_test.dart:15)`
main.dart
:
import 'package:flutter/material.dart';
import 'package:food_app/scr/providers/auth.dart';
import 'package:food_app/scr/screens/home.dart';
import 'package:food_app/scr/screens/login.dart';
import 'package:food_app/scr/widgets/loading.dart';
import 'package:provider/provider.dart';
void main() {
runApp(MultiProvider(
providers: [
ChangeNotifierProvider.value(value: AuthProvider.initialize())
],
child: MaterialApp(
ebugShowCheckedModeBanner: false,
title: 'Food app',
theme: ThemeData(
primarySwatch: Colors.red,
),
home: ScreensController())));
}
class ScreensController extends StatelessWidget {
@override
Widget build(BuildContext context) {
final auth = Provider.of<AuthProvider>(context);
switch (auth.status) {
case Status.Uninitialized:
return Loading();
case Status.Unauthenticated:
case Status.Authenticating:
return LoginScreen();
case Status.Authenticated:
return Home();
default:
return LoginScreen();
}
}
}
Widget_test.dart
:
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:food_app/main.dart';
void main() {
testWidgets('Counter increments smoke test', (WidgetTester tester) async {
// Build our app and trigger a frame.
await tester.pumpWidget(
MyApp()); // ERROR LINE error: The function 'MyApp' isn't defined. (undefined_function at [food_app] testwidget_test.dart:15)
// Verify that our counter starts at 0.
expect(find.text('0'), findsOneWidget);
expect(find.text('1'), findsNothing);
// Tap the '+' icon and trigger a frame.
await tester.tap(find.byIcon(Icons.add));
await tester.pump();
// Verify that our counter has incremented.
expect(find.text('0'), findsNothing);
expect(find.text('1'), findsOneWidget);
});
}
i got error in (document) , when i m changing (document) to (doc) it will not showing error after that it showing error in (setData) same thing setData i m chnaging it to (set) it is fine or not ?
auth.dart
:
Future<bool> signUp() async {
try {
_status = Status.Authenticating;
notifyListeners();
await _auth
.createUserWithEmailAndPassword(
email: email.text.trim(), password: password.text.trim())
.then((result) {
_firestore.collection('users').document(result.user.uid).setData({
// ERROR LINE undefined document and setData
'name': name.text,
'email': email.text,
'id': result.user.uid
});
});
question from:
https://stackoverflow.com/questions/65840126/error-showing-white-display-await-tester-pumpwidgetmyapp-cant-detect 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…