GithubHelp home page GithubHelp logo

Comments (1)

mandolf0 avatar mandolf0 commented on July 22, 2024 1

The problem seems to stem from having too many parent widgets above the toggle_switch.

Scaffold body: Container>Column>toggle_wtich does the trick.

import 'package:font_awesome_flutter/font_awesome_flutter.dart';
import 'package:toggle_switch/toggle_switch.dart';

class ToggleDemo extends StatefulWidget {
  @override
  _ToggleDemoState createState() => _ToggleDemoState();
}

class _ToggleDemoState extends State<ToggleDemo> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(title: Text("Toggle Demo")),
      body: Container(
        child: Column(
          children: [
            ToggleSwitch(
              changeOnTap: true,
              minWidth: 110.0,
              initialLabelIndex: 0,
              cornerRadius: 20.0,
              activeFgColor: Colors.white,
              // activeBgColors: Colors.white,
              inactiveBgColor: Colors.grey,
              inactiveFgColor: Colors.white,
              labels: ['Macho', 'Hembra'],
              icons: [FontAwesomeIcons.mars, FontAwesomeIcons.venus],
              activeBgColors: [Colors.blue, Colors.pink],
              onToggle: (index) async {
                print('switched to: $index');
              },
            ),
          ],
        ),
      ),
    );
  }
}

from toggle_switch.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.