Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Material 3 Support #89

Open
TC3000 opened this issue Aug 14, 2023 · 2 comments
Open

Material 3 Support #89

TC3000 opened this issue Aug 14, 2023 · 2 comments

Comments

@TC3000
Copy link

TC3000 commented Aug 14, 2023

Hello.

Could we please have Material 3 support? If I use the useMaterial3 flag on ThemeData, visual elements such as buttons aren't rendered properly.

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      theme: ThemeData.light(
          useMaterial3: true,
      ),
      home: const HomePage(),
    );
  }
@appliedrd
Copy link
Contributor

In partucular, the NEXT on the NEXT button , when enabled, cannt be seen

@msazzuhair
Copy link

msazzuhair commented Dec 16, 2023

I fixed the button problem when material 3 is enabled by wrapping the RPUITask widget with the Theme widget and overriding the elevated button foreground color:

Widget build(BuildContext context) {
  // Wrap the RPUITask widget with Theme widget
  return Theme(
    data: Theme.of(context).copyWith(
      elevatedButtonTheme: ElevatedButtonThemeData(
        style: ElevatedButton.styleFrom(
          foregroundColor: Theme.of(context).colorScheme.onPrimary, // Change the foreground color (text, etc) of the elevated button
        )
      )
    ),
    child: RPUITask(
      task: surveyTask,
      onSubmit: resultCallback,
      onCancel: (RPTaskResult? result) {
        if (result == null) {
          debugPrint("No result");
        } else {
          cancelCallBack(result);
        }
      },
    ),
  );
}

You might also need to override other styles such as OutlinedButton and Text themes on some components.

How to override a theme

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants