How To Increased Switch Size Using Flutter Android App

admin_img Posted By Bajarangi soft , Posted On 02-11-2020

The switch itself does not maintain any state. Instead, when the state of the switch changes, the widget calls the onChanged callback. Most widgets that use a switch will listen for the onChanged callback and rebuild the switch with a new value to update the visual appearance of the switch.

How To Increased Switch Size Using Flutter Android App

Increased Switch Size
Complete Code For Increased Switch Size In Flutter
main.dart

import 'package:flutter/material.dart';

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

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      debugShowCheckedModeBanner: false,
      title: 'Flutter Demo',
      home: MyHomePage(),
    );
  }
}

class MyHomePage extends StatefulWidget {
  @override
  _MyHomePageState createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  bool _isSwitched = true;
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        backgroundColor: Colors.blue[800],
        title: Text("Increased Switch Size"),
      ),
      body: Column(
        mainAxisAlignment: MainAxisAlignment.start,
        children: [
          SizedBox(height: 20),
         Container(
            alignment: Alignment.topCenter,
            child: Text('Switch Size Increase',style: TextStyle(fontSize: 14),),
          ),
          SizedBox(height: 10),
          Center(
            child: Transform.scale(
              scale: 2.5,
              child: Switch(
                activeColor: Colors.blue[900],
                onChanged: (val) => setState(() => _isSwitched = val),
                value: _isSwitched,
              ),
            ),
          ),
          SizedBox(height: 10),
          Center(
            child: Transform.scale(
              scale: 1.5,
              child: Switch(
                activeColor: Colors.blue[900],
                onChanged: (val) => setState(() => _isSwitched = val),
                value: _isSwitched,
              ),
            ),
          ),
        ],
      ),
    );
  }
}

Related Post