Skip to content

ThemeData.copyWith method defines a wrong type for toggleButtonsTheme argument #40992

@rxlabz

Description

@rxlabz

You currently can't use the themeData.copyWith() method with the toggleButtonsTheme argument.
In the copyWith method, the toggleButtonsTheme argument is defined as a ToggleButtonsTheme, but the ThemeData.raw({}) constructor needs a ToggleButtonsThemeData.

Steps to Reproduce

final theme = ThemeData.light();
final newTheme = theme.copyWith(
  toggleButtonsTheme: ToggleButtonsTheme( data: ToggleButtonsThemeData()),
);
/// throws a runtime exception
/// [ERROR:flutter/lib/ui/ui_dart_state.cc(148)] Unhandled Exception: type 
/// 'ToggleButtonsTheme' is not a subtype of type 'ToggleButtonsThemeData'
final theme = ThemeData.light();
final newTheme = theme.copyWith( toggleButtonsTheme: ToggleButtonsThemeData() );
/// Dart analyzer error
/// error • The argument type 'ToggleButtonsThemeData' can't be assigned to the
/// parameter type 'ToggleButtonsTheme' • lib/generated_editor.dart:60:7 •
/// argument_type_not_assignable
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel master, v1.10.6-pre.19, on Mac OS X 10.14.6 18G95, locale
    fr-FR)
[✓] Android toolchain - develop for Android devices (Android SDK version 28.0.3)
[✓] Xcode - develop for iOS and macOS (Xcode 10.3)
[✓] Chrome - develop for the web
[✓] Android Studio (version 3.5)
[✓] Connected device (4 available)

Metadata

Metadata

Assignees

Labels

f: material designflutter/packages/flutter/material repository.frameworkflutter/packages/flutter repository. See also f: labels.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions