stylex 1.1.0 copy "stylex: ^1.1.0" to clipboard
stylex: ^1.1.0 copied to clipboard

discontinued

A utility first package that helps developers to style widgets like CSS variables.

example/lib/main.dart

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

void main() => runApp(MyApp());

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'StyleX',
      home: StyleStore(
        style: StyleX({'theme': 'light', 'app-primary-color': '#F25ADA'}),
        child: MyHomePage(),
      ),
    );
  }
}

class MyHomePage extends StatefulWidget {
  const MyHomePage({Key key}) : super(key: key);

  @override
  _MyHomePageState createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  @override
  Widget build(BuildContext context) {
    final style = context.style;
    final color = style.get<Color>('app-primary-color');

    return Scaffold(
      body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          crossAxisAlignment: CrossAxisAlignment.center,
          children: [
            Container(width: 64, height: 64, color: color),
            RaisedButton(onPressed: () {
              setState(() {
                context.style = StyleX({'app-primary-color': Colors.red});
              });
            })
          ],
        ),
      ),
    );
  }
}
1
likes
40
pub points
0%
popularity

Publisher

unverified uploader

A utility first package that helps developers to style widgets like CSS variables.

Repository (GitHub)
View/report issues

License

MIT (LICENSE)

Dependencies

flutter

More

Packages that depend on stylex