tbib_button_with_loader 1.0.6 copy "tbib_button_with_loader: ^1.0.6" to clipboard
tbib_button_with_loader: ^1.0.6 copied to clipboard

discontinued

Flutter widgets and themes implementing the current macOS design language.

example/lib/main.dart

import 'dart:async';

import 'package:fluent_ui/fluent_ui.dart';
import 'package:flutter/material.dart';
import 'package:tbib_button_with_loader/tbib_button_with_loader.dart';
import 'package:macos_ui/macos_ui.dart' as macos;

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

class MainApp extends StatefulWidget {
  const MainApp({super.key});

  @override
  State<MainApp> createState() => _MainAppState();
}

class _MainAppState extends State<MainApp> {
  Function? startLoading;
  Function? stopLoading;
  Function(bool isSuccess)? isSuccess;

  @override
  void initState() {
    super.initState();
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        body: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: [
            Center(
              child: FluentTheme(
                data: FluentThemeData(),
                child: ButtonWithLoader(
                  onPressed: (startLoading, stopLoading,
                      Function(bool isSuccess) isSuccess, state) {
                    this.startLoading = startLoading;
                    this.stopLoading = stopLoading;
                    this.isSuccess = isSuccess;
                    this.startLoading?.call();
                    Future.delayed(const Duration(seconds: 2), () {
                      this.stopLoading?.call();
                    });
                  },
                  buttonData: const ButtonLoaderData(
                      useFluentUi: true, borderRadius: 10),
                  title: 'Click Me fluent os button',
                ),
              ),
            ),
            const SizedBox(height: 10),
            Center(
              child: macos.MacosTheme(
                data: macos.MacosThemeData(),
                child: ButtonWithLoader(
                  onPressed: (startLoading, stopLoading,
                      Function(bool isSuccess) isSuccess, state) {
                    this.startLoading = startLoading;
                    this.stopLoading = stopLoading;
                    this.isSuccess = isSuccess;
                    this.startLoading?.call();
                    Future.delayed(const Duration(seconds: 2), () {
                      this.stopLoading?.call();
                    });
                  },
                  buttonData:
                      const ButtonLoaderData(useMacUi: true, borderRadius: 10),
                  title: 'Click Me mac os button',
                ),
              ),
            ),
            const SizedBox(height: 10),
            Center(
              child: ButtonWithLoader(
                onPressed: (startLoading, stopLoading,
                    Function(bool isSuccess) isSuccess, state) {
                  this.startLoading = startLoading;
                  this.stopLoading = stopLoading;
                  this.isSuccess = isSuccess;
                  this.startLoading?.call();

                  Future.delayed(const Duration(seconds: 2), () {
                    this.isSuccess?.call(true);
                  });
                },
                title: 'success',
                buttonData: const ButtonLoaderData(borderRadius: 30),
              ),
            ),
            const SizedBox(height: 10),
            Center(
              child: ButtonWithLoader(
                onPressed: (startLoading, stopLoading,
                    Function(bool isSuccess) isSuccess, state) {
                  this.startLoading = startLoading;
                  this.stopLoading = stopLoading;
                  this.isSuccess = isSuccess;
                  this.startLoading?.call();
                  Future.delayed(const Duration(seconds: 2), () {
                    this.isSuccess?.call(false);
                  });
                },
                title: 'error',
                buttonData: const ButtonLoaderData(
                    buttonLoader: ButtonLoader(
                        customWidgetInError: Icon(Icons.running_with_errors))),
              ),
            ),
            const SizedBox(height: 10),
          ],
        ),
      ),
    );
  }
}
0
likes
150
points
59
downloads

Publisher

unverified uploader

Weekly Downloads

Flutter widgets and themes implementing the current macOS design language.

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (license)

Dependencies

fluent_ui, flutter, macos_ui, plugin_platform_interface

More

Packages that depend on tbib_button_with_loader