Skip to main content

antd_theme 0.1.0-beta.1 copy "antd_theme: ^0.1.0-beta.1" to clipboard
antd_theme: ^0.1.0-beta.1 copied to clipboard

Ant Design v6 theme system for Flutter. Theme data, shadow tokens, responsive breakpoints, and screen adaptation.

antd_theme #

Ant Design v6 theme system for Flutter — theme data, theme injection, responsive breakpoints, and screen adaptation, built on top of antd_tokens and antd_color.

Beta — This package is under active development. APIs may change before the stable release.

Features #

  • AntThemeData — Complete theme data generated from a seed token via the antd Seed → Map → Alias derivation chain. Provides light(), dark(), and fromSeed() factories, plus convenient accessors for every alias token (colors, fonts, radius, sizes, control heights, spacing, line widths, motion, shadows, z-index, screen breakpoints).
  • AntTheme / AntThemeBuilder — InheritedWidget that injects AntThemeData into the widget tree. Retrieve the current theme with AntTheme.of(context) or use AntThemeBuilder for a build-time shortcut.
  • AntBreakpoint / AntBreakpoints — antd responsive breakpoint enum (xs ~ xxxl) with fromWidth / of and comparison operators, plus isUp / isDown / isBetween utilities.
  • AntScreenUtilInit — Screen adaptation wrapper around flutter_screenutil with built-in desktop auto-adaptation (scale factor = 1 on desktop). Only .w / .sp / .r extensions are supported.

Getting started #

dependencies:
  antd_theme: ^0.1.0-beta.1
import 'package:antd_theme/antd_theme.dart';

Usage #

Theme data #

// Default light theme — identical to antd defaults
final light = AntThemeData.light();

// Dark theme
final dark = AntThemeData.dark();

// Custom seed
final custom = AntThemeData.fromSeed(
  const AntSeedToken(colorPrimary: '#722ed1', borderRadius: 8),
);

// Access tokens directly
Container(
  color: light.colorBgContainer,
  padding: EdgeInsets.all(light.padding),
  child: Text(
    'Hello',
    style: TextStyle(
      fontSize: light.fontSizeLG,
      color: light.colorText,
    ),
  ),
);

Theme injection #

AntTheme(
  data: AntThemeData.light(),
  child: MaterialApp(
    home: AntThemeBuilder(builder: (context, theme) {
      return Scaffold(
        backgroundColor: theme.colorBgLayout,
        body: Center(
          child: Text(
            'Themed!',
            style: TextStyle(color: theme.colorPrimary),
          ),
        ),
      );
    }),
  ),
);

Responsive breakpoints #

// Current breakpoint from context
final bp = AntBreakpoint.of(context);
if (bp >= AntBreakpoint.md) {
  // ≥768 layout
}

// Utility checks
if (AntBreakpoints.isDown(context, AntBreakpoint.sm)) {
  // <576 mobile layout
}
if (AntBreakpoints.isBetween(context, AntBreakpoint.md, AntBreakpoint.lg)) {
  // 768 ≤ width < 992
}

Screen adaptation #

AntScreenUtilInit(
  builder: (context, child) => AntTheme(
    data: AntThemeData.light(),
    child: MaterialApp(...),
  ),
);

// Use .w / .sp / .r extensions (never .h)
SizedBox(width: 100.w);
Text('Hello', style: TextStyle(fontSize: 14.sp));
BorderRadius.circular(6.r);

On desktop (window width ≥ 768 by default), the scale factor is automatically set to 1 so components keep their logical pixel sizes. Set desktopBreakpoint: null to disable this behavior.

License #

MIT

1
likes
0
points
103
downloads

Publisher

unverified uploader

Weekly Downloads

Ant Design v6 theme system for Flutter. Theme data, shadow tokens, responsive breakpoints, and screen adaptation.

Homepage
Repository (GitHub)
View/report issues

Topics

#ui #design-system #ant-design #theme

License

unknown (license)

Dependencies

antd_color, antd_tokens, flutter, flutter_screenutil

More

Packages that depend on antd_theme