在同一列中插入第二个按钮

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

我想知道是否可以在右侧按钮下方集成第二个按钮。让右侧的两个按钮变小,使其与左侧按钮的宽度相同。这是我的代码(我是初学者)。我有很多问题,但这一个对于未来的良好运作至关重要

void main() => runApp(const InfoAliments());

class InfoAliments extends StatelessWidget {
  const InfoAliments({super.key});

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: '',
      debugShowCheckedModeBanner: false,
      theme: ThemeData(
        colorScheme: ColorScheme.fromSeed(seedColor: Colors.black),
      ),
      home: const MyHomePage(title: ''),
    );
  }
}

class MyHomePage extends StatefulWidget {
  final String title;

  const MyHomePage({
    super.key,
    required this.title,
  });

  @override
  State<MyHomePage> createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  // Bandeau haut

  @override
  Widget build(BuildContext context) {
    Size size = MediaQuery.of(context).size;
    return Scaffold(
        appBar: AppBar(
            toolbarHeight: 90,
            backgroundColor: erreurThermo
                ? Colors.red
                : criticalAliments
                    ? Colors.red
                    : warningAliments
                        ? Colors.orange
                        : Colors.black54,
            leading: IconButton(
              icon: const Icon(Icons.menu),
              iconSize: 40,
              color: Colors.white,
              onPressed: () {
                Navigator.push(context,
                    MaterialPageRoute(builder: (context) => const MyApp()));
              },
            ),
            actions: <Widget>[
              Row(
                mainAxisAlignment: MainAxisAlignment.start,
                children: [
                  const SizedBox(width: 50),
                  DigitalClock(
                    hourMinuteDigitTextStyle:
                        const TextStyle(fontSize: 35, color: Colors.white),
                    colon: const Icon(Icons.query_builder,
                        size: 25, color: Colors.white),
                  )
                ],
              ),
              IconButton(
                icon: const Icon(Icons.search),
                iconSize: 40,
                color: Colors.white,
                onPressed: () {},
              ),
              IconButton(
                icon: const Icon(Icons.settings),
                iconSize: 40,
                color: Colors.white,
                onPressed: () {
                  Navigator.push(
                      context,
                      MaterialPageRoute(
                          builder: (context) => const settings()));
                },
              )
            ]),

        // Body

        body: SizedBox(
          width: size.width,
          height: size.height,
          child: GridView(
              gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(
                  crossAxisCount: 2,
                  crossAxisSpacing: 10,
                  mainAxisSpacing: 10,
                  childAspectRatio: (1 / .9)),
              padding: const EdgeInsets.all(30.0),
              children: [
                // Bouton CREER
                ElevatedButton(
                  style: ElevatedButton.styleFrom(
                      foregroundColor: Colors.black54,
                      backgroundColor: Colors.black54,
                      shape: const RoundedRectangleBorder(
                          borderRadius:
                              BorderRadius.all(Radius.circular(12.0)))),
                  onPressed: () {},
                  child: Center(
                      child: Column(
                          mainAxisAlignment: MainAxisAlignment.center,
                          children: [
                        const Image(
                          image: AssetImage("icons/067-category.png"),
                          color: Colors.white,
                          width: 150,
                          height: 150,
                        ),
                        const SizedBox(
                          height: 15,
                        ),
                        const Text(
                          'CREER UN ALIMENT',
                          style: TextStyle(fontSize: 15, color: Colors.white),
                        ),
                        const SizedBox(
                          height: 0,
                        ),
                        //Boutton editer (modifier, supprimer, historique, etc...)
                        IconButton(
                          icon:
                              const Icon(Icons.drive_file_rename_outline_sharp),
                          iconSize: 40,
                          color: Colors.red,
                          onPressed: () {
                            Navigator.push(
                                context,
                                MaterialPageRoute(
                                    builder: (context) =>
                                        const InfoAliments()));
                          }, // Boutton edit
                        ),
                      ])),
                ),
                
                
                ElevatedButton(
                  style: ElevatedButton.styleFrom(
                      foregroundColor: Colors.black54,
                      backgroundColor: Colors.black54,
                      shape: const RoundedRectangleBorder(
                          borderRadius:
                              BorderRadius.all(Radius.circular(12.0)))),
                  onPressed: () {},
                  child: const Center(
                      child: Column(
                          mainAxisAlignment: MainAxisAlignment.center,
                          children: [
                        Text(
                          'ALIMENT AU FRAIS',
                          style: TextStyle(fontSize: 40, color: Colors.white),
                        ),

                        // Boutton edit
                      ])),
                ),
              ]),
        ));
  }
}

我尝试过,但它在不同的行中放置了一个按钮

flutter
1个回答
0
投票

这是我的页面

在此输入图片描述

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