Skip to main content

jade_ui 0.3.0 copy "jade_ui: ^0.3.0" to clipboard
jade_ui: ^0.3.0 copied to clipboard

A token-driven Flutter component library with first-class light and dark themes, independent of Material and Cupertino.

example/lib/main.dart

import 'package:jade_ui/jade_ui.dart';

void main() => runApp(const ExampleApp());

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

  @override
  State<ExampleApp> createState() => _ExampleAppState();
}

class _ExampleAppState extends State<ExampleApp> {
  ThemeMode _mode = ThemeMode.system;

  @override
  Widget build(BuildContext context) {
    return JadeApp(
      title: 'Jade UI example',
      debugShowCheckedModeBanner: false,
      theme: ThemeData.light(),
      darkTheme: ThemeData.dark(),
      themeMode: _mode,
      home: ProfilePage(mode: _mode, onModeChanged: (mode) => setState(() => _mode = mode)),
    );
  }
}

class ProfilePage extends StatefulWidget {
  const ProfilePage({super.key, required this.mode, required this.onModeChanged});

  final ThemeMode mode;
  final ValueChanged<ThemeMode> onModeChanged;

  @override
  State<ProfilePage> createState() => _ProfilePageState();
}

class _ProfilePageState extends State<ProfilePage> {
  final _formKey = GlobalKey<FormState>();
  String _plan = 'Team';
  bool _digest = true;
  bool _mentions = true;

  void _save() {
    if (!(_formKey.currentState?.validate() ?? false)) return;
    ToastManager.show(context, title: const Text('Profile saved'), color: ColorRoleToken.success);
  }

  Future<void> _signOut() async {
    final confirmed = await showDialog<bool>(
      context: context,
      builder: (dialog) => Dialog(
        title: const Text('Sign out?'),
        body: const Text('You can sign back in at any time.'),
        footer: DialogActions(
          children: [
            Button.ghost(
              onPressed: () => Navigator.pop(dialog, false),
              child: const Text('Cancel'),
            ),
            Button.danger(
              onPressed: () => Navigator.pop(dialog, true),
              child: const Text('Sign out'),
            ),
          ],
        ),
      ),
    );
    if (confirmed == true && mounted) {
      ToastManager.show(context, title: const Text('Signed out'));
    }
  }

  @override
  Widget build(BuildContext context) {
    final colors = context.colors;
    return Scaffold(
      appBar: const AppBar(title: Text('Profile')),
      maxBodyWidth: 640,
      scrollBody: ScrollBody(
        padding: const EdgeInsets.fromLTRB(16, 8, 16, 32),
        children: [
          FormScope(
            formKey: _formKey,
            child: Column(
              crossAxisAlignment: CrossAxisAlignment.stretch,
              spacing: 16,
              children: [
                Card(
                  padding: const EdgeInsets.all(16),
                  child: User(
                    avatarName: 'Ada Lovelace',
                    name: const Text('Ada Lovelace'),
                    description: Text('ada@example.com', style: TextStyle(color: colors.muted)),
                    trailing: Chip(color: ColorRoleToken.accent, label: Text(_plan)),
                  ),
                ),
                Input(
                  initialValue: 'Ada Lovelace',
                  label: const Text('Display name'),
                  validator: (value) => (value ?? '').trim().isEmpty ? 'Enter a name' : null,
                ),
                Select<String>(
                  label: const Text('Plan'),
                  value: _plan,
                  items: const [
                    SelectItem(value: 'Free', label: 'Free'),
                    SelectItem(value: 'Team', label: 'Team'),
                    SelectItem(value: 'Business', label: 'Business'),
                  ],
                  onChanged: (value) => setState(() => _plan = value ?? _plan),
                ),
                Text('Appearance', style: context.text.sm.copyWith(color: colors.muted)),
                ToggleButtonGroup(
                  fullWidth: true,
                  selectedValue: widget.mode,
                  onChanged: (value) {
                    if (value is ThemeMode) widget.onModeChanged(value);
                  },
                  children: const [
                    ToggleButton(value: ThemeMode.light, child: Text('Light')),
                    ToggleButton(value: ThemeMode.dark, child: Text('Dark')),
                    ToggleButton(value: ThemeMode.system, child: Text('System')),
                  ],
                ),
                Switch(
                  label: const Text('Weekly digest'),
                  description: const Text('A summary of activity every Monday.'),
                  isSelected: _digest,
                  onChanged: (value) => setState(() => _digest = value),
                ),
                Switch(
                  label: const Text('Mentions'),
                  description: const Text('Email me when someone mentions me.'),
                  isSelected: _mentions,
                  onChanged: (value) => setState(() => _mentions = value),
                ),
                Button.primary(onPressed: _save, child: const Text('Save')),
                Button.dangerSoft(onPressed: _signOut, child: const Text('Sign out')),
              ],
            ),
          ),
        ],
      ),
    );
  }
}
1
likes
160
points
465
downloads

Documentation

API reference

Publisher

verified publisherarkinsta.org

Weekly Downloads

A token-driven Flutter component library with first-class light and dark themes, independent of Material and Cupertino.

Homepage

Topics

#ui #widget #design-system #theming #components

License

BSD-3-Clause (license)

Dependencies

cached_network_image, cupertino_ui, dart_mcp, flutter, flutter_markdown_plus, flutter_svg, intl, material_ui, path

More

Packages that depend on jade_ui