reusable_switch_btn 0.0.1 copy "reusable_switch_btn: ^0.0.1" to clipboard
reusable_switch_btn: ^0.0.1 copied to clipboard

A customizable Flutter package with animated switch buttons, including AppSwitch, AppSwitchCard, and NormalSwitch for flexible UI designs.

example/main.dart

import 'package:flutter/material.dart';
import 'package:reusable_switch_btn/reusable_switch_btn.dart';

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

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

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Reusable Switch Btn Example',
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: const HomeScreen(),
    );
  }
}

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

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text('Switch Button Examples'),
      ),
      body: Padding(
        padding: const EdgeInsets.all(16.0),
        child: Column(
          crossAxisAlignment: CrossAxisAlignment.start,
          children: <Widget>[
            const Text('AppSwitch Example', style: TextStyle(fontSize: 20, fontWeight: FontWeight.bold)),
            const SizedBox(height: 16),
            AppSwitch(
              activeTxt: 'Active',
              disableTxt: 'Inactive',
              initSwitched: true,
              onChanged: (bool value) {
                print('AppSwitch state: \$value');
              },
            ),
            const SizedBox(height: 24),
            const Text('AppSwitchCard Example', style: TextStyle(fontSize: 20, fontWeight: FontWeight.bold)),
            const SizedBox(height: 16),
            AppSwitchCard(
              title: 'Enable Feature X',
              activeTxt: 'Enabled',
              disableTxt: 'Disabled',
              initSwitched: false,
              onChanged: (bool value) {
                print('Feature X is: \$value');
              },
            ),
            const SizedBox(height: 24),
            const Text('NormalSwitch Example', style: TextStyle(fontSize: 20, fontWeight: FontWeight.bold)),
            const SizedBox(height: 16),
            NormalSwitch(
              isSwitched: true,
              onChanged: (bool value) {
                print('NormalSwitch state: \$value');
              },
            ),
          ],
        ),
      ),
    );
  }
}
0
likes
140
points
23
downloads

Publisher

unverified uploader

Weekly Downloads

A customizable Flutter package with animated switch buttons, including AppSwitch, AppSwitchCard, and NormalSwitch for flexible UI designs.

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (license)

Dependencies

app_style, flutter

More

Packages that depend on reusable_switch_btn