本文介绍了Flutter-FloatingActionButton中的SimpleDialog的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在点击 FloatingActionButton 之后创建一个 SimpleDialog ,但是当按下该按钮时却什么也没有

I'm trying to create a SimpleDialog after a tap on the FloatingActionButton, however when pressing that button nothing happens.

我在做什么错了?

import "package:flutter/material.dart";

void main() {
  runApp(new ControlleApp());
}

class ControlleApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return new MaterialApp(
      home: new HomePage(),
    );
  }
}

class HomePage extends StatelessWidget {
  @override
  Widget build(BuildContext context) => new Scaffold(
    appBar: new AppBar(
      backgroundColor: new Color(0xFF26C6DA),
    ),
    floatingActionButton: new FloatingActionButton(
      tooltip: 'Add',
      child: new Icon(Icons.add),
      backgroundColor: new Color(0xFFF44336),
      onPressed: (){
        new SimpleDialog(
          title: new Text('Test'),
          children: <Widget>[
            new RadioListTile(
              title: new Text('Testing'), value: null, groupValue: null, onChanged: (value) {},
            )
          ],
        );
      }
    ),
  );
}


推荐答案

您需要对此进行包装

showDialog(context: context, child:
    new AlertDialog(
      title: new Text("My Super title"),
      content: new Text("Hello World"),
    )
);

这篇关于Flutter-FloatingActionButton中的SimpleDialog的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-10 19:37