相关疑难解决方法(0)

如何在 Flutter 中为警报对话框位置设置动画?

通过这个简单的代码,我可以像下面的截图一样在屏幕底部显示对话框:

在此处输入图片说明

但我有三个简单的问题:

  1. 在对话框底部设置边距,例如20.0显示对话框
  2. 使用controller.reverse()上解雇对话框
  3. 单击对话框外时关闭对话框

完整源代码:

import 'package:flutter/material.dart';

void main() => runApp(MyApp());

class MyApp extends StatelessWidget {
  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: MyHomePage(title: 'Flutter Demo Home Page'),
    );
  }
}

class MyHomePage extends StatefulWidget {
  MyHomePage({Key key, this.title}) : super(key: key);

  final String title;

  @override
  _MyHomePageState createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  void …
Run Code Online (Sandbox Code Playgroud)

flutter flutter-layout flutter-animation

9
推荐指数
3
解决办法
9012
查看次数

如何限制 AlertDialog 的高度

我显示里面有列表的对话框。

    showDialog(
        context: context,
        builder: (context) {
          return AlertDialog(
            title: Text(select_conference),
            content: ListView.separated(
              itemCount: selected.length,
              separatorBuilder: (context, index) => CommonDivider(),
              itemBuilder: (context, index) => ListTile(...),
            ),
          );
        });
Run Code Online (Sandbox Code Playgroud)

但是无论有多少元素 - 对话框都会填充所有可用高度。有没有办法在不计算列表元素高度的情况下解决这个问题?

flutter

7
推荐指数
2
解决办法
7243
查看次数