Skip to content

Instantly share code, notes, and snippets.

@miquelbeltran
Created October 20, 2019 16:12
Show Gist options
  • Select an option

  • Save miquelbeltran/eda65c6e97e529584a11898c868c3751 to your computer and use it in GitHub Desktop.

Select an option

Save miquelbeltran/eda65c6e97e529584a11898c868c3751 to your computer and use it in GitHub Desktop.
Let's do a Hello World
import 'package:flutter_web/material.dart';
import 'package:flutter_web_test/flutter_web_test.dart';
import 'package:flutter_web_ui/ui.dart' as ui;
class MyWidget extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Container();
}
}
import 'package:flutter_web/material.dart';
import 'package:flutter_web_test/flutter_web_test.dart';
import 'package:flutter_web_ui/ui.dart' as ui;
class MyWidget extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Text('Hello World');
}
}
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Directionality(
textDirection: TextDirection.ltr,
child: Container(
color: Color(0xffeeeeee),
child: Center(
child: Container(
child: MyWidget(),
color: Color(0xffcccccc),
),
),
),
);
}
}
Future<void> main() async {
await ui.webOnlyInitializePlatform();
runApp(MyApp());
final controller = LiveWidgetController(WidgetsBinding.instance);
final texts = controller.widgetList(find.byType(Text));
if (texts.length == 0) {
_result(false, ['Couldn\'t find a Text!']);
return;
}
if (texts.length > 1) {
_result(false, ['Found ${texts.length} Text, rather than just one.']);
return;
}
final text = texts.first as Text;
if (text.data != 'Hello World') {
_result(false, ['The Text does not say Hello World.']);
return;
}
_result(true, ['A Text that says "Hello World". Well done!']);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment