ubuntu / yaru.dart

Ubuntu Yaru Flutter widgets and themes for building desktop and web applications
https://ubuntu.github.io/yaru.dart/
Mozilla Public License 2.0
214 stars 35 forks source link

Question about how to change YaruRadio color? #477

Closed HePingLaoSan closed 1 year ago

HePingLaoSan commented 1 year ago

Can somebody tell me how to change YaruRadio color? when launch in my computer, my color which is blue is different from demo which is orange.

Feichtmeier commented 1 year ago

hi @HePingLaoSan which distribution are you using? and if you use normal ubuntu, did you maybe change your theme to blue? yaru.dart detects the system theme on vanilla ubuntu and adapts

jpnurmi commented 1 year ago

One way to change the color on any platform is to force a specific variant of the Yaru theme:

import 'package:flutter/material.dart';
import 'package:yaru/yaru.dart';
import 'package:yaru_widgets/yaru_widgets.dart';

void main() {
  runApp(
    YaruTheme(
      data: const YaruThemeData(
        variant: YaruVariant.purple, // <==
      ),
      builder: (context, yaru, child) {
        return MaterialApp(
          theme: yaru.theme,
          darkTheme: yaru.darkTheme,
          home: Scaffold(
            body: Center(
              child: YaruRadio(
                value: true,
                groupValue: true,
                onChanged: (value) {},
              ),
            ),
          ),
        );
      },
    ),
  );
}

image

Jupi007 commented 1 year ago

I also plan to add some override properties soon, so we can locally change the colour of a specific control.