-
-
Save legalcodes/009a77697460e7ec6a3c142f0dfb1b5e to your computer and use it in GitHub Desktop.
Create a Column
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'dart:async'; | |
import 'package:flutter/material.dart'; | |
import 'package:flutter_test/flutter_test.dart'; | |
class MyWidget extends StatelessWidget { | |
@override | |
Widget build(BuildContext context) { | |
return Row( | |
children: [ | |
BlueBox(), | |
BlueBox(), | |
BlueBox(), | |
], | |
); | |
} | |
} | |
class BlueBox extends StatelessWidget { | |
@override | |
Widget build(BuildContext context) { | |
return Container( | |
width: 50, | |
height: 50, | |
decoration: BoxDecoration( | |
color: Colors.blue, | |
border: Border.all(), | |
), | |
); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 { | |
final completer = Completer<void>(); | |
runApp(MyApp()); | |
WidgetsFlutterBinding.ensureInitialized() | |
.addPostFrameCallback((timestamp) async { | |
completer.complete(); | |
}); | |
await completer.future; | |
runApp(MyApp()); | |
final controller = LiveWidgetController(WidgetsBinding.instance); | |
final columns = controller.widgetList(find.byType(Column)); | |
if (columns.length == 0) { | |
_result(false, ['The Row contains three BlueBox widgets and lays them out horizontally.']); | |
return; | |
} | |
if (columns.length > 1) { | |
_result(false, ['Found ${columns.length} Rows, rather than just one.']); | |
return; | |
} | |
final column = columns.first as Column; | |
if (column.children.length != 3 || column.children.any((w) => w is! BlueBox)) { | |
_result(false, ['Row/Column should contain three children, all BlueBox widgets.']); | |
return; | |
} | |
_result(true, ['The Column contains three BlueBox widgets and lays them out vertically.']); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment