Closed yozachar closed 3 years ago
@joe733 This does not have to do anything with the library. You're missing declaration for savedThemeMode
in your MyApp
class.
This should fix it:
class MyApp extends StatelessWidget {
final AdaptiveThemeMode savedThemeMode;
MyApp({Key key,@required this.savedThemeMode});
...
}
Thanks a lot... still learning :)
Had to change widget_test.dart
to
import 'package:adaptive_theme/adaptive_theme.dart';
...
void main() {
AdaptiveThemeMode savedThemeMode;
testWidgets('Counter increments smoke test', (WidgetTester tester) async {
// Build our app and trigger a frame.
await tester.pumpWidget(MyApp(
savedThemeMode: savedThemeMode,
));
...
@joe733 You're welcome. Happy to help. 😊
Hi, I have the same issue but I don't understand neither your answer or his change :
import 'package:flutter/material.dart'; import 'package:adaptive_theme/adaptive_theme.dart'; import 'pages/home_page.dart';
void main() async { WidgetsFlutterBinding.ensureInitialized(); final savedThemeMode = await AdaptiveTheme.getThemeMode(); runApp(MyApp(savedThemeMode : savedThemeMode)); }
class MyApp extends StatelessWidget { @override Widget build(BuildContext context) { return AdaptiveTheme( light: ThemeData( brightness: Brightness.light, primarySwatch: Colors.lightBlue, accentColor: Colors.purple, ), dark: ThemeData( brightness: Brightness.dark, primarySwatch: Colors.lightBlue, accentColor: Colors.purple, ), initial: savedThemeMode ?? AdaptiveThemeMode.light, builder: (theme, darkTheme) => MaterialApp( debugShowCheckedModeBanner: false, title: 'Namka Nav', theme: theme, darkTheme: darkTheme, home: HomePage(), )); } }
issue : The named parameter 'savedThemeMode' isn't defined. Try correcting the name to an existing named parameter's name, or defining a named parameter with the name 'savedThemeMode'.
What am I missing ?
Thanks
@agarnet74 Compare your code with the example app and you will see what you're missing!
Your MyApp
should have this:
class MyApp extends StatelessWidget {
final AdaptiveThemeMode? savedThemeMode;
const MyApp({Key? key, this.savedThemeMode}) : super(key: key);
}
Thanks, it works fine !
Following Get ThemeMode at App Start, my code looks like this:
But I get an error saying:
Please pardon my ignorance in Dart and/or Flutter and show me how to resolve this.