-
Notifications
You must be signed in to change notification settings - Fork 30.1k
Description
With the following code:
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter/cupertino.dart';
void main() {
debugDefaultTargetPlatformOverride = TargetPlatform.fuchsia;
runApp(MyApp());
}
class MyApp extends StatefulWidget {
@override
_MyAppState createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> {
bool dark = false;
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Material(
child: AnimatedTheme(
data: dark ? ThemeData.dark() : Theme.of(context),
child: Center(
child: Container(
color: dark ? Colors.black : Colors.white,
child: FlatButton(
onPressed: () {
setState(() { dark = !dark;});
},
child: Text('TEST'),
),
),
),
),
),
);
}
}I get the following exception during the transition. It's fine at the either end of the lerp, just broken in the middle, it seems because inherited is false for one ThemeData, and true for the other. This occurs (at least) on Android and on Web.
Exception
Details
══╡ EXCEPTION CAUGHT BY WIDGETS LIBRARY ╞═══════════════════════════════════════════════════════════ The following assertion was thrown building AnimatedTheme(duration: 200ms, dirty, state: _AnimatedThemeState#f29b7(ticker active, ThemeDataTween(ThemeData#00000(buttonTheme: ButtonThemeData#00000(buttonColor: Color(0xffe0e0e0), focusColor: Color(0x1f000000), hoverColor: Color(0x0a000000), colorScheme: ColorScheme#00000(primary: MaterialColor(primary value: Color(0xff2196f3)), primaryVariant: Color(0xff1976d2), secondary: Color(0xff2196f3), secondaryVariant: Color(0xff1976d2), background: Color(0xff90caf9), error: Color(0xffd32f2f), onSecondary: Color(0xffffffff), onBackground: Color(0xffffffff)), materialTapTargetSize: MaterialTapTargetSize.padded), toggleButtonsTheme: ToggleButtonsThemeData#00000, textTheme: TextTheme#00000(display4: TextStyle(debugLabel: (englishLike display4 2014).merge(blackMountainView display4), inherit: false, color: Color(0x8a000000), family: Roboto, size: 112.0, weight: 100, baseline: alphabetic, decoration: TextDecoration.none), display3: TextStyle(debugLabel: (englishLike display3 2014).merge(blackMountainView display3), inherit: false, color: Color(0x8a000000), family: Roboto, size: 56.0, weight: 400, baseline: alphabetic, decoration: TextDecoration.none), display2: TextStyle(debugLabel: (englishLike display2 2014).merge(blackMountainView display2), inherit: false, color: Color(0x8a000000), family: Roboto, size: 45.0, weight: 400, baseline: alphabetic, decoration: TextDecoration.none), display1: TextStyle(debugLabel: (englishLike display1 2014).merge(blackMountainView display1), inherit: false, color: Color(0x8a000000), family: Roboto, size: 34.0, weight: 400, baseline: alphabetic, decoration: TextDecoration.none), headline: TextStyle(debugLabel: (englishLike headline 2014).merge(blackMountainView headline), inherit: false, color: Color(0xdd000000), family: Roboto, size: 24.0, weight: 400, baseline: alphabetic, decoration: TextDecoration.none), title: TextStyle(debugLabel: (englishLike title 2014).merge(blackMountainView title), inherit: false, color: Color(0xdd000000), family: Roboto, size: 20.0, weight: 500, baseline: alphabetic, decoration: TextDecoration.none), subhead: TextStyle(debugLabel: (englishLike subhead 2014).merge(blackMountainView subhead), inherit: false, color: Color(0xdd000000), family: Roboto, size: 16.0, weight: 400, baseline: alphabetic, decoration: TextDecoration.none), body2: TextStyle(debugLabel: (englishLike body2 2014).merge(blackMountainView body2), inherit: false, color: Color(0xdd000000), family: Roboto, size: 14.0, weight: 500, baseline: alphabetic, decoration: TextDecoration.none), body1: TextStyle(debugLabel: (englishLike body1 2014).merge(blackMountainView body1), inherit: false, color: Color(0xdd000000), family: Roboto, size: 14.0, weight: 400, baseline: alphabetic, decoration: TextDecoration.none), caption: TextStyle(debugLabel: (englishLike caption 2014).merge(blackMountainView caption), inherit: false, color: Color(0x8a000000), family: Roboto, size: 12.0, weight: 400, baseline: alphabetic, decoration: TextDecoration.none), button: TextStyle(debugLabel: (englishLike button 2014).merge(blackMountainView button), inherit: false, color: Color(0xdd000000), family: Roboto, size: 14.0, weight: 500, baseline: alphabetic, decoration: TextDecoration.none), subtitle): TextStyle(debugLabel: (englishLike subtitle 2014).merge(blackMountainView subtitle), inherit: false, color: Color(0xff000000), family: Roboto, size: 14.0, weight: 500, letterSpacing: 0.1, baseline: alphabetic, decoration: TextDecoration.none), overline: TextStyle(debugLabel: (englishLike overline 2014).merge(blackMountainView overline), inherit: false, color: Color(0xff000000), family: Roboto, size: 10.0, weight: 400, letterSpacing: 1.5, baseline: alphabetic, decoration: TextDecoration.none)), primaryTextTheme: TextTheme#00000(display4: TextStyle(debugLabel: (englishLike display4 2014).merge(whiteMountainView display4), inherit: false, color: Color(0xb3ffffff), family: Roboto, size: 112.0, weight: 100, baseline: alphabetic, decoration: TextDecoration.none), display3: TextStyle(debugLabel: (englishLike display3 2014).merge(whiteMountainView display3), inherit: false, color: Color(0xb3ffffff), family: Roboto, size: 56.0, weight: 400, baseline: alphabetic, decoration: TextDecoration.none), display2: TextStyle(debugLabel: (englishLike display2 2014).merge(whiteMountainView display2), inherit: false, color: Color(0xb3ffffff), family: Roboto, size: 45.0, weight: 400, baseline: alphabetic, decoration: TextDecoration.none), display1: TextStyle(debugLabel: (englishLike display1 2014).merge(whiteMountainView display1), inherit: false, color: Color(0xb3ffffff), family: Roboto, size: 34.0, weight: 400, baseline: alphabetic, decoration: TextDecoration.none), headline: TextStyle(debugLabel: (englishLike headline 2014).merge(whiteMountainView headline), inherit: false, color: Color(0xffffffff), family: Roboto, size: 24.0, weight: 400, baseline: alphabetic, decoration: TextDecoration.none), title: TextStyle(debugLabel: (englishLike title 2014).merge(whiteMountainView title), inherit: false, color: Color(0xffffffff), family: Roboto, size: 20.0, weight: 500, baseline: alphabetic, decoration: TextDecoration.none), subhead: TextStyle(debugLabel: (englishLike subhead 2014).merge(whiteMountainView subhead), inherit: false, color: Color(0xffffffff), family: Roboto, size: 16.0, weight: 400, baseline: alphabetic, decoration: TextDecoration.none), body2: TextStyle(debugLabel: (englishLike body2 2014).merge(whiteMountainView body2), inherit: false, color: Color(0xffffffff), family: Roboto, size: 14.0, weight: 500, baseline: alphabetic, decoration: TextDecoration.none), body1: TextStyle(debugLabel: (englishLike body1 2014).merge(whiteMountainView body1), inherit: false, color: Color(0xffffffff), family: Roboto, size: 14.0, weight: 400, baseline: alphabetic, decoration: TextDecoration.none), caption: TextStyle(debugLabel: (englishLike caption 2014).merge(whiteMountainView caption), inherit: false, color: Color(0xb3ffffff), family: Roboto, size: 12.0, weight: 400, baseline: alphabetic, decoration: TextDecoration.none), button: TextStyle(debugLabel: (englishLike button 2014).merge(whiteMountainView button), inherit: false, color: Color(0xffffffff), family: Roboto, size: 14.0, weight: 500, baseline: alphabetic, decoration: TextDecoration.none), subtitle): TextStyle(debugLabel: (englishLike subtitle 2014).merge(whiteMountainView subtitle), inherit: false, color: Color(0xffffffff), family: Roboto, size: 14.0, weight: 500, letterSpacing: 0.1, baseline: alphabetic, decoration: TextDecoration.none), overline: TextStyle(debugLabel: (englishLike overline 2014).merge(whiteMountainView overline), inherit: false, color: Color(0xffffffff), family: Roboto, size: 10.0, weight: 400, letterSpacing: 1.5, baseline: alphabetic, decoration: TextDecoration.none)), accentTextTheme: TextTheme#00000(display4: TextStyle(debugLabel: (englishLike display4 2014).merge(whiteMountainView display4), inherit: false, color: Color(0xb3ffffff), family: Roboto, size: 112.0, weight: 100, baseline: alphabetic, decoration: TextDecoration.none), display3: TextStyle(debugLabel: (englishLike display3 2014).merge(whiteMountainView display3), inherit: false, color: Color(0xb3ffffff), family: Roboto, size: 56.0, weight: 400, baseline: alphabetic, decoration: TextDecoration.none), display2: TextStyle(debugLabel: (englishLike display2 2014).merge(whiteMountainView display2), inherit: false, color: Color(0xb3ffffff), family: Roboto, size: 45.0, weight: 400, baseline: alphabetic, decoration: TextDecoration.none), display1: TextStyle(debugLabel: (englishLike display1 2014).merge(whiteMountainView display1), inherit: false, color: Color(0xb3ffffff), family: Roboto, size: 34.0, weight: 400, baseline: alphabetic, decoration: TextDecoration.none), headline: TextStyle(debugLabel: (englishLike headline 2014).merge(whiteMountainView headline), inherit: false, color: Color(0xffffffff), family: Roboto, size: 24.0, weight: 400, baseline: alphabetic, decoration: TextDecoration.none), title: TextStyle(debugLabel: (englishLike title 2014).merge(whiteMountainView title), inherit: false, color: Color(0xffffffff), family: Roboto, size: 20.0, weight: 500, baseline: alphabetic, decoration: TextDecoration.none), subhead: TextStyle(debugLabel: (englishLike subhead 2014).merge(whiteMountainView subhead), inherit: false, color: Color(0xffffffff), family: Roboto, size: 16.0, weight: 400, baseline: alphabetic, decoration: TextDecoration.none), body2: TextStyle(debugLabel: (englishLike body2 2014).merge(whiteMountainView body2), inherit: false, color: Color(0xffffffff), family: Roboto, size: 14.0, weight: 500, baseline: alphabetic, decoration: TextDecoration.none), body1: TextStyle(debugLabel: (englishLike body1 2014).merge(whiteMountainView body1), inherit: false, color: Color(0xffffffff), family: Roboto, size: 14.0, weight: 400, baseline: alphabetic, decoration: TextDecoration.none), caption: TextStyle(debugLabel: (englishLike caption 2014).merge(whiteMountainView caption), inherit: false, color: Color(0xb3ffffff), family: Roboto, size: 12.0, weight: 400, baseline: alphabetic, decoration: TextDecoration.none), button: TextStyle(debugLabel: (englishLike button 2014).merge(whiteMountainView button), inherit: false, color: Color(0xffffffff), family: Roboto, size: 14.0, weight: 500, baseline: alphabetic, decoration: TextDecoration.none), subtitle): TextStyle(debugLabel: (englishLike subtitle 2014).merge(whiteMountainView subtitle), inherit: false, color: Color(0xffffffff), family: Roboto, size: 14.0, weight: 500, letterSpacing: 0.1, baseline: alphabetic, decoration: TextDecoration.none), overline: TextStyle(debugLabel: (englishLike overline 2014).merge(whiteMountainView overline), inherit: false, color: Color(0xffffffff), family: Roboto, size: 10.0, weight: 400, letterSpacing: 1.5, baseline: alphabetic, decoration: TextDecoration.none)), inputDecorationTheme: InputDecorationTheme#00000, iconTheme: IconThemeData#9f466(color: Color(0xdd000000)), primaryIconTheme: IconThemeData#49346(color: Color(0xffffffff)), accentIconTheme: IconThemeData#49346(color: Color(0xffffffff)), sliderTheme: SliderThemeData#00000, tabBarTheme: TabBarTheme#b33f1, tooltipTheme: TooltipThemeData#44c00, cardTheme: CardTheme#11859, chipTheme: ChipThemeData#00000, materialTapTargetSize: MaterialTapTargetSize.padded, applyElevationOverlayColor: false, pageTransitionsTheme: PageTransitionsTheme#30633) → ThemeData#00000(brightness: dark, primaryColor: Color(0xff212121), accentColor: Color(0xff64ffda), accentColorBrightness: light, canvasColor: Color(0xff303030), scaffoldBackgroundColor: Color(0xff303030), bottomAppBarColor: Color(0xff424242), cardColor: Color(0xff424242), dividerColor: Color(0x1fffffff), focusColor: Color(0x1fffffff), hoverColor: Color(0x0affffff), highlightColor: Color(0x40cccccc), splashColor: Color(0x40cccccc), unselectedWidgetColor: Color(0xb3ffffff), disabledColor: Color(0x62ffffff), buttonColor: Color(0xff1e88e5), secondaryHeaderColor: Color(0xff616161), textSelectionColor: Color(0xff64ffda), textSelectionHandleColor: Color(0xff1de9b6), backgroundColor: Color(0xff616161), dialogBackgroundColor: Color(0xff424242), indicatorColor: Color(0xff64ffda), hintColor: Color(0x80ffffff), toggleableActiveColor: Color(0xff64ffda), buttonTheme: ButtonThemeData#00000(buttonColor: Color(0xff1e88e5), focusColor: Color(0x1fffffff), hoverColor: Color(0x0affffff), colorScheme: ColorScheme#00000(primary: MaterialColor(primary value: Color(0xff2196f3)), primaryVariant: Color(0xff000000), secondary: Color(0xff64ffda), secondaryVariant: Color(0xff00bfa5), surface: Color(0xff424242), background: Color(0xff616161), error: Color(0xffd32f2f), onSurface: Color(0xffffffff), onBackground: Color(0xffffffff), onError: Color(0xff000000), brightness: Brightness.dark), materialTapTargetSize: MaterialTapTargetSize.padded), toggleButtonsTheme: ToggleButtonsThemeData#00000, textTheme: TextTheme#00000(display4: TextStyle(debugLabel: whiteMountainView display4, inherit: true, color: Color(0xb3ffffff), family: Roboto, decoration: TextDecoration.none), display3: TextStyle(debugLabel: whiteMountainView display3, inherit: true, color: Color(0xb3ffffff), family: Roboto, decoration: TextDecoration.none), display2: TextStyle(debugLabel: whiteMountainView display2, inherit: true, color: Color(0xb3ffffff), family: Roboto, decoration: TextDecoration.none), display1: TextStyle(debugLabel: whiteMountainView display1, inherit: true, color: Color(0xb3ffffff), family: Roboto, decoration: TextDecoration.none), headline: TextStyle(debugLabel: whiteMountainView headline, inherit: true, color: Color(0xffffffff), family: Roboto, decoration: TextDecoration.none), title: TextStyle(debugLabel: whiteMountainView title, inherit: true, color: Color(0xffffffff), family: Roboto, decoration: TextDecoration.none), subhead: TextStyle(debugLabel: whiteMountainView subhead, inherit: true, color: Color(0xffffffff), family: Roboto, decoration: TextDecoration.none), body2: TextStyle(debugLabel: whiteMountainView body2, inherit: true, color: Color(0xffffffff), family: Roboto, decoration: TextDecoration.none), body1: TextStyle(debugLabel: whiteMountainView body1, inherit: true, color: Color(0xffffffff), family: Roboto, decoration: TextDecoration.none), caption: TextStyle(debugLabel: whiteMountainView caption, inherit: true, color: Color(0xb3ffffff), family: Roboto, decoration: TextDecoration.none), button: TextStyle(debugLabel: whiteMountainView button, inherit: true, color: Color(0xffffffff), family: Roboto, decoration: TextDecoration.none), subtitle): TextStyle(debugLabel: whiteMountainView subtitle, inherit: true, color: Color(0xffffffff), family: Roboto, decoration: TextDecoration.none), overline: TextStyle(debugLabel: whiteMountainView overline, inherit: true, color: Color(0xffffffff), family: Roboto, decoration: TextDecoration.none)), primaryTextTheme: TextTheme#00000(display4: TextStyle(debugLabel: whiteMountainView display4, inherit: true, color: Color(0xb3ffffff), family: Roboto, decoration: TextDecoration.none), display3: TextStyle(debugLabel: whiteMountainView display3, inherit: true, color: Color(0xb3ffffff), family: Roboto, decoration: TextDecoration.none), display2: TextStyle(debugLabel: whiteMountainView display2, inherit: true, color: Color(0xb3ffffff), family: Roboto, decoration: TextDecoration.none), display1: TextStyle(debugLabel: whiteMountainView display1, inherit: true, color: Color(0xb3ffffff), family: Roboto, decoration: TextDecoration.none), headline: TextStyle(debugLabel: whiteMountainView headline, inherit: true, color: Color(0xffffffff), family: Roboto, decoration: TextDecoration.none), title: TextStyle(debugLabel: whiteMountainView title, inherit: true, color: Color(0xffffffff), family: Roboto, decoration: TextDecoration.none), subhead: TextStyle(debugLabel: whiteMountainView subhead, inherit: true, color: Color(0xffffffff), family: Roboto, decoration: TextDecoration.none), body2: TextStyle(debugLabel: whiteMountainView body2, inherit: true, color: Color(0xffffffff), family: Roboto, decoration: TextDecoration.none), body1: TextStyle(debugLabel: whiteMountainView body1, inherit: true, color: Color(0xffffffff), family: Roboto, decoration: TextDecoration.none), caption: TextStyle(debugLabel: whiteMountainView caption, inherit: true, color: Color(0xb3ffffff), family: Roboto, decoration: TextDecoration.none), button: TextStyle(debugLabel: whiteMountainView button, inherit: true, color: Color(0xffffffff), family: Roboto, decoration: TextDecoration.none), subtitle): TextStyle(debugLabel: whiteMountainView subtitle, inherit: true, color: Color(0xffffffff), family: Roboto, decoration: TextDecoration.none), overline: TextStyle(debugLabel: whiteMountainView overline, inherit: true, color: Color(0xffffffff), family: Roboto, decoration: TextDecoration.none)), accentTextTheme: TextTheme#00000, inputDecorationTheme: InputDecorationTheme#00000, iconTheme: IconThemeData#49346(color: Color(0xffffffff)), primaryIconTheme: IconThemeData#49346(color: Color(0xffffffff)), accentIconTheme: IconThemeData#c69fe(color: Color(0xff000000)), sliderTheme: SliderThemeData#00000, tabBarTheme: TabBarTheme#b33f1, tooltipTheme: TooltipThemeData#44c00, cardTheme: CardTheme#11859, chipTheme: ChipThemeData#00000(backgroundColor: Color(0x1fffffff), deleteIconColor: Color(0xdeffffff), disabledColor: Color(0x0cffffff), selectedColor: Color(0x3dffffff), secondarySelectedColor: Color(0x3d212121), labelStyle: TextStyle(debugLabel: (whiteMountainView body2).copyWith, inherit: true, color: Color(0xdeffffff), family: Roboto, decoration: TextDecoration.none), secondaryLabelStyle: TextStyle(debugLabel: (whiteMountainView body2).copyWith, inherit: true, color: Color(0xde212121), family: Roboto, decoration: TextDecoration.none), brightness: dark), materialTapTargetSize: MaterialTapTargetSize.padded, applyElevationOverlayColor: false, pageTransitionsTheme: PageTransitionsTheme#30633, colorScheme: ColorScheme#00000(primary: MaterialColor(primary value: Color(0xff2196f3)), primaryVariant: Color(0xff000000), secondary: Color(0xff64ffda), secondaryVariant: Color(0xff00bfa5), surface: Color(0xff424242), background: Color(0xff616161), error: Color(0xffd32f2f), onSurface: Color(0xffffffff), onBackground: Color(0xffffffff), onError: Color(0xff000000), brightness: Brightness.dark))))): Assertion failed: org-dartlang-app:///packages/flutter/src/painting/text_style.dart:929:12 t(a == null || b == null || a.inherit == b.inher is not trueEither the assertion indicates an error in the framework itself, or we should provide substantially
more information in this error message to help you determine and fix the underlying cause.
In either case, please report this assertion by filing a bug on GitHub:
https://github.com/flutter/flutter/issues/new?template=BUG.mdThe relevant error-causing widget was:
AnimatedTheme org-dartlang-app:///packages/mysample/main.dart:28:16When the exception was thrown, this was the stack:
package:dart-sdk/lib/internal/js_dev_runtime/private/ddc_runtime/errors.dart 194:49 throw
package:dart-sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/errors.dart 24:3 assertFailed
package:flutter/src/painting/text_style.dart 929:52 lerp
package:flutter/src/material/text_theme.dart 462:27 lerp
package:flutter/src/material/theme_data.dart 1226:28 lerp
package:flutter/src/material/theme.dart 202:41 lerp
package:flutter/src/animation/tween.dart 260:12 transform
package:flutter/src/animation/tween.dart 53:46 evaluate
package:flutter/src/material/theme.dart 266:19 build
package:flutter/src/widgets/framework.dart 4064:27 build
package:flutter/src/widgets/framework.dart 3958:15 performRebuild
package:flutter/src/widgets/framework.dart 3755:5 rebuild
package:flutter/src/widgets/framework.dart 2347:31 buildScope
package:flutter/src/widgets/binding.dart 777:49 drawFrame
package:flutter/src/rendering/binding.dart 283:5 [_handlePersistentFrameCallback]
package:flutter/src/scheduler/binding.dart 1043:15 [_invokeFrameCallback]
package:flutter/src/scheduler/binding.dart 982:9 handleDrawFrame
package:flutter/src/scheduler/binding.dart 898:5 [_handleDrawFrame]
package:build_web_compilers/lib/_engine/engine.dart 176:21