首页
学习
活动
专区
工具
TVP
发布
精选内容/技术社群/优惠产品,尽在小程序
立即前往

如何更改flutter showAboutDialog中的文本按钮颜色?

在Flutter中,showAboutDialog 是一个用于显示关于对话框的函数。要更改其中的文本按钮颜色,可以通过自定义 AlertDialog 来实现。以下是一个示例代码,展示了如何更改“确定”按钮的颜色:

代码语言:txt
复制
import 'package:flutter/material.dart';

void main() {
  runApp(MyApp());
}

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(title: Text('Flutter About Dialog Example')),
        body: Center(
          child: ElevatedButton(
            onPressed: () {
              showDialog(
                context: context,
                builder: (BuildContext context) {
                  return AlertDialog(
                    title: Text('关于'),
                    content: Text('这是一个关于对话框的示例。'),
                    actions: <Widget>[
                      TextButton(
                        child: Text('确定'),
                        style: TextButton.styleFrom(
                          primary: Colors.red, // 设置按钮文本颜色
                        ),
                        onPressed: () {
                          Navigator.of(context).pop();
                        },
                      ),
                    ],
                  );
                },
              );
            },
            child: Text('显示关于对话框'),
          ),
        ),
      ),
    );
  }
}

在这个示例中,我们创建了一个 AlertDialog,并在 actions 属性中添加了一个 TextButton。通过 TextButton.styleFrom 方法,我们可以设置按钮的文本颜色。在这个例子中,我们将文本颜色设置为红色。

参考链接:

通过这种方式,你可以自定义 showAboutDialog 中的文本按钮颜色,以满足你的设计需求。

页面内容是否对你有帮助?
有帮助
没帮助

相关·内容

没有搜到相关的合辑

领券