mirror of
https://github.com/gabehf/Fladder.git
synced 2026-03-13 09:20:31 -07:00
Init repo
This commit is contained in:
commit
764b6034e3
566 changed files with 212335 additions and 0 deletions
31
lib/util/option_dialogue.dart
Normal file
31
lib/util/option_dialogue.dart
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
import 'package:flutter/material.dart';
|
||||
|
||||
Future<void> openOptionDialogue<T>(
|
||||
BuildContext context, {
|
||||
required String label,
|
||||
required List<T> items,
|
||||
bool isNullable = false,
|
||||
required Widget Function(T? type) itemBuilder,
|
||||
}) {
|
||||
return showDialog(
|
||||
context: context,
|
||||
builder: (context) {
|
||||
return AlertDialog.adaptive(
|
||||
title: Text(label),
|
||||
content: SizedBox(
|
||||
width: MediaQuery.of(context).size.width * 0.65,
|
||||
child: ListView(
|
||||
physics: const AlwaysScrollableScrollPhysics(),
|
||||
shrinkWrap: true,
|
||||
children: [
|
||||
if (isNullable) itemBuilder(null),
|
||||
...items.map(
|
||||
(e) => itemBuilder(e),
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue