Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

522
Visualizações
How to place two switchListTIles next to each other, like in a Row in flutter?

I wanted to do 2 things in flutter:

  1. change the space between the title and switch of a switchlisttile().
  2. place two switchlistTiles next to each other in a row. For some reason this gives an error in flutter.

Thx.

over 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

on giving height i am not having any error just a demo try it might help import 'package:flutter/material.dart';

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

class MyApp extends StatelessWidget {
  const MyApp({Key? key}) : super(key: key);
  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: const MyHomePage(title: 'Flutter Demo Home Page'),
    );
  }
}

class MyHomePage extends StatefulWidget {
  const MyHomePage({Key? key, required this.title}) : super(key: key);

  final String title;

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

class _MyHomePageState extends State<MyHomePage> {
  int _counter = 0;
  double ?height ;
  double ?width ;
  void _incrementCounter() {
    setState(() {

      _counter++;
    });
  }

  @override
  Widget build(BuildContext context) {
    height = MediaQuery.of(context).size.height;
    width = MediaQuery.of(context).size.width;
    bool ans = false;
    bool anss = false;
    return Scaffold(
      appBar: AppBar(

        title: Text(widget.title),
      ),
      body: Center(

        child: Column(

          mainAxisAlignment: MainAxisAlignment.center,
          children: <Widget>[
            Row(
              children: [
                Container(
                  height: height!/10,
                  width: width!/2,
                  child:  SwitchListTile(
                    title: const Text('Lights'),
                    value: ans,
                    onChanged: (bool value) {
                      setState(() {
                        ans = value;
                      });
                    },
                    secondary: const Icon(Icons.lightbulb_outline),
                  ),
                ),
                Container(
                  height: height!/10,
                  width: width!/2,
                  child: SwitchListTile(
                    title: const Text('hhh'),
                    value: anss,
                    onChanged: (bool value) {
                      setState(() {
                        anss = value;
                      });
                    },
                    secondary: const Icon(Icons.lightbulb_outline),
                  ),
                )
              ],
            ),

          ],
        ),
      ),
       // This trailing comma makes auto-formatting nicer for build methods.
    );
  }
}
over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda