因此,我将导入一个自定义组件TextButton,并将其打包到另一个OutlinedButton中。我导出类OutlinedButton,希望看到道具的传递和添加的新样式呈现。然而,只有道具被正确地呈现。我添加的额外样式根本没有出现。对于为什么会发生这种情况,有什么想法吗?
import React, { Component } from 'react';
import TextButton from './TextButton';
class OutlinedButton extends Component {
render() {
r
我在为OutlinedButton添加pad时遇到了问题,我一直在使用OutlineButton,我已经决定使用OutlinedButton,因为按钮已经折旧了。但是,在填充参数未定义的情况下,按钮的用法有所不同。我尝试过用OutlinedButton包装ButtonTheme,但是它没有任何效果,现在我正在使用填充,如下面的代码示例所示。
new Column(children: [
new Row(children: [
//5th row
new Expanded(
我正在尝试更多地使用Flutter。 我有一个按钮类,它根据参数构建FlatButton或OutlineButton import 'package:flutter/material.dart';
class Button extends StatelessWidget {
final String text;
final VoidCallback onPressed;
final Color backgroundColor;
final Color textColor;
final bool isOutline;
Button(
{@
FlatButton is deprecated and shouldn't be used. Used TextButton instead. 在我之前的FlatButton小部件上,我可以在按下时更改启动颜色。但现在我正在使用TextButton小部件,如何在MaterialApp ThemeData上或直接在TextButton小部件上高效地更改它的颜色。 目前这是我的TextButton TextButton(
style: TextButton.styleFrom(
primary: Colors.red,
textStyle: TextStyle(
有没有一种方法可以用dart类型来创建一个对象?我想要做的事情的例子,但它不起作用:
// select the button type based on certain value (valid in this case)
final button = valid ? ElevatedButton : OutlinedButton;
// create the correct button
button(....) // this does not work
有办法让这件事成功吗?
我不想有这样的代码,因为会有重复:
if (valid) {
return Outline