Commit 7bd0f51c by 杜長金

11

parent 4c5cd564
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
main() { main() {
runApp(const MyApp()); runApp(MyApp());
} }
class MyApp extends StatelessWidget { class MyApp extends StatelessWidget {
const MyApp({Key? key}) : super(key: key); @override
Widget build(BuildContext context) {
return MaterialApp(
debugShowCheckedModeBanner: false,
home: Container(
child: Text("aaa"),
),
);
}
}
class HomePage extends StatelessWidget {
List tabs = ["全部", "待付款", "點評/投票"];
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Container(); return new DefaultTabController(
length: tabs.length,
child: new Scaffold(
appBar: AppBar(
bottom: TabBar(
//生成Tab菜单
tabs: tabs.map((e) => Tab(text: e)).toList()),
),
body: new TabBarView(
children: tabs.map((e) {
//分别创建对应的Tab页面
return Container(
alignment: Alignment.center,
child: Text(e, textScaleFactor: 5),
);
}).toList(),
),
),
);
} }
} }
// 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:flutter_one/main.dart';
void main() {
testWidgets('Counter increments smoke test', (WidgetTester tester) async {
// Build our app and trigger a frame.
await tester.pumpWidget(const MyApp());
// 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);
});
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment