小编Ami*_*gid的帖子

Flutter 函数参数按引用传递

我对 Dart 和 Flutter 有疑问。所以我试图重构一些代码,但我陷入了引用问题。

class _LoginPageState extends State<LoginPage> {
  String _email;
  String _password;

  @override
  Widget build(BuildContext context) {
    return Scaffold(
        appBar: new AppBar(
          title: new Text("Login Page"),
        ),
        body: new Container(
          padding: new EdgeInsets.all(16),
          child: new Form(
              child: new Column(
                  crossAxisAlignment: CrossAxisAlignment.stretch,
                  children: buildInputs()
              )),
        ));
  }

  Widget buildInput(String label, String val) {
    return new TextFormField(
      decoration: new InputDecoration(
        labelText: label,
      ),
      validator: (value) => value.isEmpty ? "$label can't be empty" : null,
      onSaved: (value) => val = value, …
Run Code Online (Sandbox Code Playgroud)

dart flutter

9
推荐指数
1
解决办法
2万
查看次数

如何在 Flutter 中设置默认选中的单选按钮?

默认情况下,Flutter 将所有单选按钮显示为空(未选中)。

如何设置默认选中的单选按钮?

我发布这个问题是为了记录我的解决方案,这可能会对某些人有所帮助,并且还开始讨论这个问题,因为我在这里没有找到任何相关信息。

在单选按钮代码下方:

class _ProductTypeScreen extends State<ProductType> {

  String _radioValue; //Initial definition of radio button value
  String choice;

  void radioButtonChanges(String value) {
    setState(() {
      _radioValue = value;
      switch (value) {
        case 'one':
          choice = value;
          break;
        case 'two':
          choice = value;
          break;
        case 'three':
          choice = value;
          break;
        default:
          choice = null;
      }
      debugPrint(choice); //Debug the choice in console
    });
  }

  // Now in the BuildContext... body widget:

  @override
  Widget build(BuildContext context) {
  //First of the three radio …
Run Code Online (Sandbox Code Playgroud)

radio-button flutter flutter-layout

8
推荐指数
2
解决办法
3万
查看次数

AppBar 标题带有图像抖动

我有附加的 AppBar,我想在标题旁边添加图像,而不是操作图标,仅添加图像,我该如何处理这个问题?

appBar: AppBar(
            title: Text('Title'),
            actions: <Widget>[
              new IconButton(
                icon: new Icon(Icons.refresh),
                onPressed: () {
                  setState(
                    () {
                      widget.athkarCategory.reset();
                    },
                  );
                },
              ),
            ],
          ),
Run Code Online (Sandbox Code Playgroud)

在此输入图像描述

appbar dart flutter

2
推荐指数
1
解决办法
6480
查看次数

标签 统计

flutter ×3

dart ×2

appbar ×1

flutter-layout ×1

radio-button ×1