load_switch 1.0.1 copy "load_switch: ^1.0.1" to clipboard
load_switch: ^1.0.1 copied to clipboard

outdated

A highly customizable toggle switch with a loading state.

example/lib/main.dart

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

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

class MyApp extends StatefulWidget {
  const MyApp({Key? key}) : super(key: key);

  @override
  State<MyApp> createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  bool value = false;

  Future<bool> _getFuture() async {
    await Future.delayed(const Duration(seconds: 2));
    return !value;
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Load Switch Example',
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: LoadSwitch(
        value: value,
        future: _getFuture,
        onChange: (v) {
          value = v;
          print('Value changed to $v');
          setState(() {});
        },
        onTap: (v) {
          print('Tapping while value is $v');
        },
      ),
    );
  }
}
65
likes
0
points
2.8k
downloads

Publisher

verified publisheresentis.dev

Weekly Downloads

A highly customizable toggle switch with a loading state.

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

flutter

More

Packages that depend on load_switch