infobits_core 0.0.5 copy "infobits_core: ^0.0.5" to clipboard
infobits_core: ^0.0.5 copied to clipboard

Infobits core components

example/lib/main.dart

import 'dart:async';

import 'package:flutter/material.dart';
import 'package:go_router/go_router.dart';
import 'package:infobits_core/infobits_core.dart';

void main() {
  Timer.periodic(const Duration(seconds: 1), (timer) {
    InfobitsState.instance.initialized = true;
    timer.cancel();
  });
  runApp(MyApp());
}

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

  final router = GoRouter(routes: [
    GoRoute(
      path: '/',
      builder: (context, state) => const HomePage(),
    ),
  ]);

  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return InfobitsApp(
      title: "Infobits Core Example",
      logo: Container(
        width: 50,
        height: 50,
        color: Colors.red,
      ),
      router: router,
    );
  }
}

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

  @override
  State<HomePage> createState() => _HomePageState();
}

class _HomePageState extends State<HomePage> {
  late final DropdownInputController themeController;

  @override
  void initState() {
    themeController = DropdownInputController(
        defaultValue: 'system', initValue: context.chosenThemeName);

    themeController.addListener(_onThemeChanged);
    super.initState();
  }

  @override
  void dispose() {
    themeController.removeListener(_onThemeChanged);
    super.dispose();
  }

  void _onThemeChanged() {
    debugPrint("New theme value: ${themeController.value}");
    context.setThemeName(themeController.value);
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: SingleChildScrollView(
        child: Center(
          child: Container(
            padding: const EdgeInsets.all(20),
            constraints: const BoxConstraints(maxWidth: 800),
            child: Column(
              children: [
                Padding(
                  padding: const EdgeInsets.symmetric(vertical: 10),
                  child: Row(
                    children: [
                      const Expanded(child: T18("Theme")),
                      SizedBox(
                        width: 200,
                        child: DropdownInput(
                          controller: themeController,
                          items: const [
                            DropdownInputItem(
                                value: "system", child: T16("System")),
                            DropdownInputItem(
                                value: "light", child: T16("Light")),
                            DropdownInputItem(
                                value: "dark", child: T16("Dark")),
                          ],
                          defaultValue: "system",
                        ),
                      )
                    ],
                  ),
                ),
                const Padding(
                  padding: EdgeInsets.symmetric(vertical: 10),
                  child: Column(
                    children: [
                      H72("H72 largest text"),
                      H56("H56 large text"),
                      H40("H40 text"),
                      H32("H32 text"),
                      T24("T24 text"),
                      T20("T20 text"),
                      T18("T18 text"),
                      T16("T16 text"),
                      T14("T14 text"),
                      T12("T12 text"),
                      T10("T10 text"),
                    ],
                  ),
                ),
                Padding(
                  padding: const EdgeInsets.symmetric(vertical: 10),
                  child: Row(
                    mainAxisAlignment: MainAxisAlignment.spaceBetween,
                    children: [
                      Link(
                        onPressed: () {},
                        text: "Link",
                      ),
                      Link(
                        onPressed: () {},
                        text: "Link",
                        appearance: LinkAppearance.accent,
                      ),
                      Link(
                        onPressed: () {},
                        text: "Link",
                        appearance: LinkAppearance.neutral,
                      ),
                      Link(
                        onPressed: () {},
                        text: "Link",
                        color: Colors.red,
                      ),
                      Link(
                        onPressed: () {},
                        text: "Link",
                        color: Colors.red,
                        appearance: LinkAppearance.accent,
                      ),
                      Link(
                        onPressed: () {},
                        text: "Link",
                        color: Colors.red,
                        appearance: LinkAppearance.neutral,
                      ),
                      Link(
                        onPressed: () {},
                        text: "Link",
                        disabled: true,
                      ),
                      Link(
                        onPressed: () {},
                        text: "Link",
                        disabled: true,
                        appearance: LinkAppearance.accent,
                      ),
                      Link(
                        onPressed: () {},
                        text: "Link",
                        disabled: true,
                        appearance: LinkAppearance.neutral,
                      ),
                    ],
                  ),
                ),
                Padding(
                  padding: const EdgeInsets.symmetric(vertical: 10),
                  child: Row(
                    mainAxisAlignment: MainAxisAlignment.spaceBetween,
                    children: [
                      Link(
                        onPressed: () {},
                        text: "Link",
                        size: const LinkSize.large(),
                      ),
                      Link(
                        onPressed: () {},
                        text: "Link",
                        appearance: LinkAppearance.accent,
                        size: const LinkSize.large(),
                      ),
                      Link(
                        onPressed: () {},
                        text: "Link",
                        appearance: LinkAppearance.neutral,
                        size: const LinkSize.large(),
                      ),
                      Link(
                        onPressed: () {},
                        text: "Link",
                        color: Colors.red,
                        size: const LinkSize.large(),
                      ),
                      Link(
                        onPressed: () {},
                        text: "Link",
                        color: Colors.red,
                        appearance: LinkAppearance.accent,
                        size: const LinkSize.large(),
                      ),
                      Link(
                        onPressed: () {},
                        text: "Link",
                        color: Colors.red,
                        appearance: LinkAppearance.neutral,
                        size: const LinkSize.large(),
                      ),
                      Link(
                        onPressed: () {},
                        text: "Link",
                        disabled: true,
                        size: const LinkSize.large(),
                      ),
                      Link(
                        onPressed: () {},
                        text: "Link",
                        disabled: true,
                        appearance: LinkAppearance.accent,
                        size: const LinkSize.large(),
                      ),
                      Link(
                        onPressed: () {},
                        text: "Link",
                        disabled: true,
                        appearance: LinkAppearance.neutral,
                        size: const LinkSize.large(),
                      ),
                    ],
                  ),
                ),
                const Padding(
                  padding: EdgeInsets.symmetric(vertical: 10),
                  child: Row(
                    mainAxisAlignment: MainAxisAlignment.spaceBetween,
                    children: [
                      Button(
                        text: "Button",
                      ),
                      Button(
                        icon: Icons.add,
                        text: "Button",
                      ),
                      Button(
                        icon: Icons.add,
                        text: "Button",
                        isIconSurfix: true,
                      ),
                    ],
                  ),
                ),
                Padding(
                  padding: const EdgeInsets.symmetric(vertical: 10),
                  child: Row(
                    mainAxisAlignment: MainAxisAlignment.spaceBetween,
                    children: [
                      Button(
                        onPressed: () {},
                        text: "Button",
                        size: const ButtonSize.small(),
                      ),
                      Button(
                        onPressed: () {},
                        text: "Button",
                        appearance: ButtonAppearance.accent,
                        size: const ButtonSize.small(),
                      ),
                      Button(
                        onPressed: () {},
                        text: "Button",
                        appearance: ButtonAppearance.muted,
                        size: const ButtonSize.small(),
                      ),
                      Button(
                        onPressed: () {},
                        text: "Button",
                        appearance: ButtonAppearance.ghost,
                        size: const ButtonSize.small(),
                      ),
                      Button(
                        onPressed: () {},
                        text: "Button",
                        appearance: ButtonAppearance.neutral,
                        size: const ButtonSize.small(),
                      ),
                      Button(
                        onPressed: () {},
                        text: "Button",
                        appearance: ButtonAppearance.danger,
                        size: const ButtonSize.small(),
                      ),
                      Button(
                        onPressed: () {},
                        text: "Button",
                        appearance: ButtonAppearance.warning,
                        size: const ButtonSize.small(),
                      ),
                      Button(
                        onPressed: () {},
                        text: "Button",
                        appearance: ButtonAppearance.success,
                        size: const ButtonSize.small(),
                      ),
                    ],
                  ),
                ),
                Padding(
                  padding: const EdgeInsets.symmetric(vertical: 10),
                  child: Row(
                    mainAxisAlignment: MainAxisAlignment.spaceBetween,
                    children: [
                      Button(
                        onPressed: () {},
                        text: "Button",
                      ),
                      Button(
                        onPressed: () {},
                        text: "Button",
                        appearance: ButtonAppearance.accent,
                      ),
                      Button(
                        onPressed: () {},
                        text: "Button",
                        appearance: ButtonAppearance.muted,
                      ),
                      Button(
                        onPressed: () {},
                        text: "Button",
                        appearance: ButtonAppearance.ghost,
                      ),
                      Button(
                        onPressed: () {},
                        text: "Button",
                        appearance: ButtonAppearance.neutral,
                      ),
                      Button(
                        onPressed: () {},
                        text: "Button",
                        appearance: ButtonAppearance.danger,
                      ),
                      Button(
                        onPressed: () {},
                        text: "Button",
                        appearance: ButtonAppearance.warning,
                      ),
                      Button(
                        onPressed: () {},
                        text: "Button",
                        appearance: ButtonAppearance.success,
                      ),
                    ],
                  ),
                ),
                Padding(
                  padding: const EdgeInsets.symmetric(vertical: 10),
                  child: Row(
                    mainAxisAlignment: MainAxisAlignment.spaceBetween,
                    children: [
                      Button(
                        onPressed: () {},
                        text: "Button",
                        size: const ButtonSize.large(),
                      ),
                      Button(
                        onPressed: () {},
                        text: "Button",
                        appearance: ButtonAppearance.accent,
                        size: const ButtonSize.large(),
                      ),
                      Button(
                        onPressed: () {},
                        text: "Button",
                        appearance: ButtonAppearance.muted,
                        size: const ButtonSize.large(),
                      ),
                      Button(
                        onPressed: () {},
                        text: "Button",
                        appearance: ButtonAppearance.ghost,
                        size: const ButtonSize.large(),
                      ),
                      Button(
                        onPressed: () {},
                        text: "Button",
                        appearance: ButtonAppearance.neutral,
                        size: const ButtonSize.large(),
                      ),
                      Button(
                        onPressed: () {},
                        text: "Button",
                        appearance: ButtonAppearance.danger,
                        size: const ButtonSize.large(),
                      ),
                      Button(
                        onPressed: () {},
                        text: "Button",
                        appearance: ButtonAppearance.warning,
                        size: const ButtonSize.large(),
                      ),
                      Button(
                        onPressed: () {},
                        text: "Button",
                        appearance: ButtonAppearance.success,
                        size: const ButtonSize.large(),
                      ),
                    ],
                  ),
                ),
                Padding(
                  padding: const EdgeInsets.symmetric(vertical: 10),
                  child: Column(
                    children: [
                      TextInput(
                        controller: TextEditingController(),
                        title: "Text Input",
                      ),
                      EmailInput(
                        controller: TextEditingController(),
                      ),
                      PhoneInput(
                        controller: TextEditingController(),
                      ),
                      PasswordInput(
                        controller: TextEditingController(),
                      ),
                      CheckboxInput(
                        title: "Checkbox",
                        items: const [
                          CheckBoxItem(
                            value: true,
                            widget: T14("Checkbox 1"),
                          ),
                          CheckBoxItem(
                            value: false,
                            widget: T14("Checkbox 1"),
                          ),
                        ],
                        controller: CheckBoxInputController(),
                      ),
                      DateTimeInput(
                        controller: DateTimeInputController(),
                      ),
                    ],
                  ),
                )
              ],
            ),
          ),
        ),
      ),
    );
  }
}