作为一个完全的初学者,我正在尝试各种 flutter 功能,但由于 widget_test.dart 文件中的错误,我陷入了运行 main.dart 的困境。
如果错误是由于其他原因造成的,请指出。
main.dart
import 'package:flutter/material.dart';
void main(){
var app = MaterialApp(
title: 'FlutterApp',
debugShowCheckedModeBanner: true,
theme: ThemeData(
primaryColor: Colors.black12,
accentColor: Colors.orange,
),
home: Scaffold(
appBar: AppBar(
title: Text('Stateless'),
backgroundColor: Colors.black,
),
),
);
runApp(app);
}
widget_test.dart
// This is a basic Flutter widget test.
//
// To perform an interaction with a widget in your test, use the WidgetTester
// utility that Flutter provides. For example, you can send tap and scroll
// gestures. You can also use WidgetTester to find child widgets in the widget
// tree, read text, and verify that the values of widget properties are correct.
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:stateless/main.dart';
void main() {
testWidgets('Counter increments smoke test', (WidgetTester tester) async {
// Build our app and trigger a frame.
await tester.pumpWidget(MyApp()); //error over here
// 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);
});
}
这是我的第一个问题,如果我无法以正确的方式提出问题,我深表歉意