Archives par mot-clé : scrollable

Flutter – Scrollable dialog with Getx

To have a scrollable dialog with Getx, you have multiple possibilities.

1. With Get.dialog

Get.dialog(
  Container(
    width: double.maxFinite,
    child: Column(
        mainAxisAlignment: MainAxisAlignment.center,
        mainAxisSize: MainAxisSize.min,
        children: [
          Text("Description 1",
              style:
                  TextStyle(fontWeight: FontWeight.bold)),
          SizedBox(height: 8),
          Flexible(
            child: SingleChildScrollView(
              child: Text('Very, very large title',
                  textScaleFactor: 15),
            ),
          ),
          ElevatedButton(
            onPressed: () {
              Navigator.of(context).pop();
            },
            child: Text("OK"),
          )
        ]),
  ),
);

2. With Get.defaultDialog

Get.defaultDialog(
  content: Flexible(
    child: SingleChildScrollView(
      child: Text('Very, very large title',
                  textScaleFactor: 15),
    ),
  ),
);

3. By combining Get.dialog and AlertDialog

Get.dialog(AlertDialog(
  content: Container(
    width: double.maxFinite,
    child: Column(
        mainAxisAlignment: MainAxisAlignment.center,
        mainAxisSize: MainAxisSize.min,
        children: [
          Text("Description 1",
              style:
                  TextStyle(fontWeight: FontWeight.bold)),
          SizedBox(height: 8),
          Flexible(
            child: SingleChildScrollView(
              child: Text('Very, very large title',
                  textScaleFactor: 15),
            ),
          ),
          ElevatedButton(
            onPressed: () {
              Navigator.of(context).pop();
            },
            child: Text("OK"),
          )
        ]),
  ),
));