Skip to content

Commit

Permalink
Added a media query extension to calculate the dialog width to use
Browse files Browse the repository at this point in the history
  • Loading branch information
Wolfteam committed Jul 10, 2021
1 parent c3e198b commit c38a809
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
@@ -0,0 +1,9 @@
import 'package:flutter/cupertino.dart';

extension MediaQueryExtensions on MediaQueryData {
double getWidthForDialogs() {
final take = orientation == Orientation.portrait ? 2 : 3;
final width = size.width / take;
return width;
}
}
6 changes: 5 additions & 1 deletion lib/presentation/shared/info_dialog.dart
@@ -1,6 +1,7 @@
import 'package:flutter/material.dart';
import 'package:genshindb/generated/l10n.dart';
import 'package:genshindb/presentation/shared/bullet_list.dart';
import 'package:genshindb/presentation/shared/extensions/media_query_extensions.dart';

class InfoDialog extends StatelessWidget {
final List<String> explanations;
Expand All @@ -16,7 +17,10 @@ class InfoDialog extends StatelessWidget {
return AlertDialog(
title: Text(s.information),
content: SingleChildScrollView(
child: BulletList(items: explanations, fontSize: 14),
child: SizedBox(
width: MediaQuery.of(context).getWidthForDialogs(),
child: BulletList(items: explanations, fontSize: 14),
),
),
actions: [
ElevatedButton(
Expand Down

0 comments on commit c38a809

Please sign in to comment.