Skip to main content

flutter_design_tokens 1.0.1 copy "flutter_design_tokens: ^1.0.1" to clipboard
flutter_design_tokens: ^1.0.1 copied to clipboard

A Flutter package providing semantic, reusable, and themeable design tokens for colors, typography, spacing, radius, borders, elevations, and component sizes.

example/flutter_design_tokens_example.dart

import 'package:flutter/material.dart';
import 'package:flutter_design_tokens/flutter_design_tokens.dart';

import 'light_tokens_example.dart';

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

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

  @override
  Widget build(BuildContext context) {
    // Wrap MaterialApp with AppTheme
    return AppTheme(
        tokens: lightTokens,
        builder: (context) {
          return MaterialApp(
            title: 'Flutter Demo',
            theme: ThemeData.light(),
            home: const HomePage(),
          );
        });
  }
}

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

  @override
  Widget build(BuildContext context) {
    // Access tokens in your widgets
    final colors = context.colors;
    final textStyle = context.textStyle;
    final spacing = context.spacing;

    return Scaffold(
      backgroundColor: colors.bgPrimary,
      body: Padding(
        padding: EdgeInsets.all(spacing.pageHorizontal),
        child: Column(
          crossAxisAlignment: CrossAxisAlignment.start,
          children: [
            Text(
              '标题',
              style: textStyle.headlineMedium.copyWith(
                color: colors.textPrimary,
              ),
            ),
            SizedBox(height: spacing.lg),
            Container(
              padding: EdgeInsets.all(spacing.cardPadding),
              decoration: BoxDecoration(
                color: colors.surfacePrimary,
                borderRadius: BorderRadius.circular(context.radius.md),
                boxShadow: [
                  BoxShadow(
                    blurRadius: context.elevation.level2,
                    color: Colors.black12,
                  )
                ],
              ),
              child: Text(
                '内容',
                style: textStyle.bodyMedium,
              ),
            ),
          ],
        ),
      ),
    );
  }
}
0
likes
140
points
34
downloads

Documentation

API reference

Publisher

unverified uploader

Weekly Downloads

A Flutter package providing semantic, reusable, and themeable design tokens for colors, typography, spacing, radius, borders, elevations, and component sizes.

Repository (GitHub)

License

MIT (license)

Dependencies

flutter

More

Packages that depend on flutter_design_tokens