Made elements on component screen stay compact on wider screen, take 2 (#1267)

* Revert "Revert "Made elements on component screen stay compact on wider screen (#1258)" (#1266)"

This reverts commit 53c83adc71.

* ran flutter format for the changed files

* fixed test

Co-authored-by: Qun Cheng <quncheng@google.com>
pull/1273/head
Qun Cheng 2 years ago committed by GitHub
parent 53c83adc71
commit 52ef797b9a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -11,26 +11,32 @@ class ComponentScreen extends StatelessWidget {
return Expanded(
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 10),
child: ListView(
shrinkWrap: true,
children: [
_colDivider,
_colDivider,
const Buttons(),
_colDivider,
const FloatingActionButtons(),
_colDivider,
const Cards(),
_colDivider,
const Dialogs(),
_colDivider,
showNavBottomBar
? const NavigationBars(
selectedIndex: 0,
isExampleBar: true,
)
: Container(),
],
child: Align(
alignment: Alignment.topCenter,
child: SizedBox(
width: _maxWidthConstraint,
child: ListView(
shrinkWrap: true,
children: [
_colDivider,
_colDivider,
const Buttons(),
_colDivider,
const FloatingActionButtons(),
_colDivider,
const Cards(),
_colDivider,
const Dialogs(),
_colDivider,
showNavBottomBar
? const NavigationBars(
selectedIndex: 0,
isExampleBar: true,
)
: Container(),
],
),
),
),
),
);
@ -40,6 +46,7 @@ class ComponentScreen extends StatelessWidget {
const _rowDivider = SizedBox(width: 10);
const _colDivider = SizedBox(height: 10);
const double _cardWidth = 115;
const double _maxWidthConstraint = 400;
void Function()? handlePressed(
BuildContext context, bool isDisabled, String buttonName) {
@ -255,8 +262,7 @@ class Cards extends StatelessWidget {
alignment: Alignment.topRight,
child: Icon(Icons.more_vert),
),
_colDivider,
_colDivider,
SizedBox(height: 35),
Align(
alignment: Alignment.bottomLeft,
child: Text("Elevated"),
@ -279,8 +285,7 @@ class Cards extends StatelessWidget {
alignment: Alignment.topRight,
child: Icon(Icons.more_vert),
),
_colDivider,
_colDivider,
SizedBox(height: 35),
Align(
alignment: Alignment.bottomLeft,
child: Text("Filled"),
@ -308,8 +313,7 @@ class Cards extends StatelessWidget {
alignment: Alignment.topRight,
child: Icon(Icons.more_vert),
),
_colDivider,
_colDivider,
SizedBox(height: 35),
Align(
alignment: Alignment.bottomLeft,
child: Text("Outlined"),

@ -179,15 +179,17 @@ class _Material3DemoState extends State<Material3Demo> {
body: SafeArea(
bottom: false,
top: false,
child: Row(children: <Widget>[
Padding(
padding: const EdgeInsets.symmetric(horizontal: 5),
child: NavigationRailSection(
onSelectItem: handleScreenChanged,
selectedIndex: screenIndex)),
const VerticalDivider(thickness: 1, width: 1),
createScreenFor(screenIndex, true),
]),
child: Row(
children: <Widget>[
Padding(
padding: const EdgeInsets.symmetric(horizontal: 5),
child: NavigationRailSection(
onSelectItem: handleScreenChanged,
selectedIndex: screenIndex)),
const VerticalDivider(thickness: 1, width: 1),
createScreenFor(screenIndex, true),
],
),
),
);
}

@ -27,6 +27,11 @@ void main() {
expect(find.text("Icon"), findsNWidgets(5));
// FABs
Finder floatingActionButton = find.text("Create");
await tester.scrollUntilVisible(
floatingActionButton,
500.0,
);
expect(
find.widgetWithIcon(FloatingActionButton, Icons.add), findsNWidgets(4));
expect(find.widgetWithText(FloatingActionButton, "Create"), findsOneWidget);

Loading…
Cancel
Save