Flutter如何在Java中将容器更改为面板

问题描述 投票:0回答:1

我想知道如何以交互方式更改我的容器。我有4个按钮,我希望每个按钮都更改为一个不同的容器,并保留标题

这是我的实际代码。

import 'package:flutter/material.dart';

class PantallaUsuarioA extends StatefulWidget {
  PantallaUsuarioA({Key key}) : super(key: key);

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

class _PantallaUsuarioAState extends State<PantallaUsuarioA> {
  @override
  Widget build(BuildContext context) {
    double tamanioPantalla = MediaQuery.of(context).size.width;
    double largoPantalla = MediaQuery.of(context).size.height;
    return Scaffold(
      body: Container(
        color: Colors.black,
        child: Column(
          crossAxisAlignment: CrossAxisAlignment.start,
          mainAxisAlignment: MainAxisAlignment.start,
          children: <Widget>[
            SizedBox(
              height: largoPantalla * 0.10,
            ),
            Container(
              width: tamanioPantalla,
              height: 518,
              color: Colors.grey[400],
              child: Column(
                children: <Widget>[
                  Container(
                    child: Column(
                      crossAxisAlignment: CrossAxisAlignment.start,
                      mainAxisAlignment: MainAxisAlignment.start,
                      children: <Widget>[
                        Container(
                          width: tamanioPantalla,
                          height: 30,
                          child: Row(
                            crossAxisAlignment: CrossAxisAlignment.start,
                            mainAxisAlignment: MainAxisAlignment.start,
                            children: <Widget>[
                              Expanded(
                                  flex: 1,
                                  child: RaisedButton(
                                    shape: Border.all(width: 1),
                                    child: Text('Registrar',
                                        style: TextStyle(fontSize: 12)),
                                    onPressed: () {},
                                  )),
                              Expanded(
                                  flex: 1,
                                  child: RaisedButton(
                                    shape: Border.all(width: 1),
                                    child: Text('Eliminar',
                                        style: TextStyle(fontSize: 12)),
                                    onPressed: () {},
                                  )),
                              Expanded(
                                  flex: 1,
                                  child: RaisedButton(
                                    shape: Border.all(width: 1),
                                    child: Text('Actualizar',
                                        style: TextStyle(fontSize: 12)),
                                    onPressed: () {},
                                  )),
                              Expanded(
                                  flex: 1,
                                  child: RaisedButton(
                                    shape: Border.all(width: 1),
                                    child: Text('Buscar',
                                        style: TextStyle(fontSize: 12)),
                                    onPressed: () {},
                                  )),
                            ],
                          ),
                        ),
                      ],
                    ),
                  ),
                  Container(
                    //I want to change this container with the
                    color: Colors.red,
                    child: Text(
                        "i Want to change this container with my other buttons, how can I do that?"),
                  )
                ],
              ),
            ),
          ],
        ),
      ),
    );
  }
}

实际程序的照片。actual program如您所见,我有4个按钮,我希望每个按钮都作为自己的容器,并在用户单击in>时进行更改

我想知道如何以交互方式更改我的容器。我有4个按钮,我希望每个按钮都更改为一个不同的容器,并保留标题为我的实际代码。导入'...

flutter flutter-layout
1个回答
0
投票

您可以使用可见性/ opacity或后台显示来在onPressed上的小部件之间切换。例子

© www.soinside.com 2019 - 2024. All rights reserved.