Created
March 8, 2022 13:41
-
-
Save huynguyennovem/e4e8ac98ca0616777737e4ab53c7dbf4 to your computer and use it in GitHub Desktop.
AnimatedTheme throws exceptions when switching
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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'), | |
), | |
), | |
), | |
), | |
), | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Chrome 98.0.4758.109 (Official Build) (arm64)
Exception log:
Screen.Recording.2022-03-08.at.8.38.48.PM.mp4