bweird_widgets 0.1.3 copy "bweird_widgets: ^0.1.3" to clipboard
bweird_widgets: ^0.1.3 copied to clipboard

A collection of BWeird widgets and components with GetX implemented

example/lib/main.dart

import 'package:example/components/button_widget.dart';
import 'package:example/components/card_widget.dart';
import 'package:example/components/container_tabs_by_tap_widget.dart';
import 'package:example/components/container_tabs_widget.dart';
import 'package:example/components/dialog_widget.dart';
import 'package:example/components/dynamic_layout_widget.dart';
import 'package:example/components/layout_widget.dart';
import 'package:example/components/menu_tabs_widget.dart';
import 'package:example/components/modal_widget.dart';
import 'package:example/components/scaffold_sidemenu_widget.dart';
import 'package:example/components/text_widget.dart';
import 'package:flutter/material.dart';
import 'package:bweird_widgets/bweird_widgets.dart';
import 'package:get/route_manager.dart';

MyTheme currentTheme = MyTheme();

class MyTheme with ChangeNotifier {
  static bool _isDark = false;
  static Color _color = Colors.deepPurple;

  ThemeMode currentTheme() {
    return _isDark ? ThemeMode.dark : ThemeMode.light;
  }

  Color currentColor() {
    return _color;
  }

  void onSwitch() {
    _isDark = !_isDark;
    notifyListeners();
  }

  void onChangeColor(Color newColor) {
    _color = newColor;
    notifyListeners();
  }
}

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

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

  @override
  State<StatefulWidget> createState() {
    return _MyApp();
  }
}

class _MyApp extends State<MyApp> {
  @override
  void initState() {
    super.initState();
    currentTheme.addListener(() {
      setState(() {});
    });
  }

  @override
  Widget build(BuildContext context) {
    return GetMaterialApp(
      title: 'BWeird Flutter Components',
      debugShowCheckedModeBanner: false,
      theme: ThemeData(
        colorScheme:
            ColorScheme.fromSeed(seedColor: currentTheme.currentColor()),
        useMaterial3: true,
      ),
      darkTheme: ThemeData(
        colorScheme: ColorScheme.fromSeed(
          seedColor: currentTheme.currentColor(),
          brightness: Brightness.dark,
        ),
        useMaterial3: true,
      ),
      themeMode: currentTheme.currentTheme(),
      home: const MyHomePage(title: 'BWeird Flutter Components'),
    );
  }
}

class MyHomePage extends StatefulWidget {
  const MyHomePage({super.key, required this.title});

  final String title;

  @override
  State<MyHomePage> createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  int selectedTab = 0;
  @override
  void initState() {
    super.initState();
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
        appBar: AppBar(
          backgroundColor: Theme.of(context).colorScheme.inversePrimary,
          title: Text(widget.title),
        ),
        body: bodyWidget());
  }

  Widget bodyWidget() {
    return Column(
        mainAxisAlignment: MainAxisAlignment.start,
        crossAxisAlignment: CrossAxisAlignment.center,
        children: [
          const SizedBox(height: 10),
          Row(mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [
            themeMode(),
            colorMode(),
          ]),
          const SizedBox(height: 10),
          const Divider(),
          const SizedBox(height: 10),
          const Expanded(
              child: BWContainerTabs(
                  tabList: [
                    Tab(text: "Text"),
                    Tab(text: "Button"),
                    Tab(text: "Card"),
                    Tab(text: "Scaffold Side Menu"),
                    Tab(text: "Dialog"),
                    Tab(text: "Modal"),
                    Tab(text: "Layout"),
                    Tab(text: "Dynamic Layout"),
                    Tab(text: "Container Menu Tabs"),
                    Tab(text: "Menu Appbar"),
                    Tab(text: "Container Tabs"),
                    Tab(text: "Container Tabs By Tap"),
                  ],
                  isScrollable: true,
                  bodyList: [
                    TextExampleWidget(),
                    ButtonExampleWidget(),
                    CardExampleWidget(),
                    ScaffoldSideMenuExampleWidget(),
                    DialogWidget(),
                    ModalWidget(),
                    LayoutWidget(),
                    DynamicLayoutWidget(),
                    MenuTabsExampleWidget(),
                    MenuTabsExampleWidget(),
                    ContainerTabExampleWidget(),
                    ContainerTabByTapExampleWidget(),
                  ])),
        ]);
  }

  void onToggleTheme() {
    currentTheme.onSwitch();
  }

  Widget themeMode() {
    return Row(
      children: [
        const SizedBox(width: 10),
        Switch(
          value: Theme.of(context).brightness == Brightness.dark,
          onChanged: (isOn) => onToggleTheme(),
        ),
        const SizedBox(width: 10),
        BWText.subtitle(
            Theme.of(context).brightness == Brightness.dark ? "DARK" : "LIGHT",
            isBold: true)
      ],
    );
  }

  Widget colorMode() {
    return PopupMenuButton<Widget>(
      color: Colors.black,
      child: Row(
        children: [
          Icon(Icons.square, color: currentTheme.currentColor()),
          const Icon(Icons.arrow_drop_down_rounded),
        ],
      ),
      itemBuilder: (BuildContext context) => [
        PopupMenuItem<Widget>(
            onTap: () => currentTheme.onChangeColor(Colors.deepOrange),
            child: const Icon(Icons.square, color: Colors.deepOrange)),
        PopupMenuItem<Widget>(
            onTap: () => currentTheme.onChangeColor(Colors.deepPurple),
            child: const Icon(Icons.square, color: Colors.deepPurple)),
        PopupMenuItem<Widget>(
            onTap: () => currentTheme.onChangeColor(Colors.pinkAccent),
            child: const Icon(Icons.square, color: Colors.pinkAccent))
      ],
      //import export
    );
  }
}
copied to clipboard
1
likes
140
points
343
downloads

Publisher

unverified uploader

Weekly Downloads

2024.09.23 - 2025.04.07

A collection of BWeird widgets and components with GetX implemented

Homepage

Documentation

API reference

License

MIT (license)

Dependencies

flutter, get, iconify_flutter

More

Packages that depend on bweird_widgets