Skip to content

Commit

Permalink
Use ContentSizeInfo.maybeOf in FlyoutListTile (Fixes #650)
Browse files Browse the repository at this point in the history
  • Loading branch information
bdlukaa committed Dec 23, 2022
1 parent 96b4889 commit fc77248
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
## [next]

- `FlyoutListTile` can be used outside of a flyout ([#650](https://github.com/bdlukaa/fluent_ui/issues/650))
- Add uk localization ([#647](https://github.com/bdlukaa/fluent_ui/pull/647))

## 4.1.2
Expand Down
8 changes: 5 additions & 3 deletions lib/src/controls/surfaces/flyout/content.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ part of 'flyout.dart';
///
/// * [Flyout], which is a light dismiss container that can show arbitrary UI
/// as its content
/// * [FlyoutListTile],
/// * [FlyoutListTile], a list tile adapted to flyouts
class FlyoutContent extends StatelessWidget {
/// Creates a flyout content
const FlyoutContent({
Expand Down Expand Up @@ -128,7 +128,7 @@ class FlyoutListTile extends StatelessWidget {
@override
Widget build(BuildContext context) {
assert(debugCheckHasFluentTheme(context));
final size = ContentSizeInfo.of(context).size;
final size = ContentSizeInfo.maybeOf(context)?.size;

return HoverButton(
key: key,
Expand Down Expand Up @@ -170,7 +170,9 @@ class FlyoutListTile extends StatelessWidget {
),
),
Flexible(
fit: size.isEmpty ? FlexFit.loose : FlexFit.tight,
fit: size == null || size.isEmpty
? FlexFit.loose
: FlexFit.tight,
child: Padding(
padding: const EdgeInsetsDirectional.only(end: 10.0),
child: DefaultTextStyle(
Expand Down
14 changes: 14 additions & 0 deletions test/flyout_test.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import 'package:fluent_ui/fluent_ui.dart';
import 'package:flutter_test/flutter_test.dart';

import 'app_test.dart';

void main() {
testWidgets('FlyoutListTile can be used outside of a Flyout', (tester) async {
await tester.pumpWidget(
wrapApp(
child: const FlyoutListTile(text: Text('Copy')),
),
);
});
}

0 comments on commit fc77248

Please # to comment.