Home > Net >  The method 'dark' isn't defined for the type 'ThemeData'
The method 'dark' isn't defined for the type 'ThemeData'

Time:05-27

I'm getting this errror while following a lecture. ThemeData.dark() is not working properly.

import 'package:zoom_clone/screens/login_screen.dart';

void main() {
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({Key? key}) : super(key: key);


  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Zoom Clone',
      theme: ThemeData().dark(),
      home: const LoginScreen(),
    );
  }
}

CodePudding user response:

Use it like this

MaterialApp(
  title: 'Flutter Demo',
  theme: ThemeData.dark(), // default dark theme replaces default light theme
  home: MyHomePage(title: 'Flutter Demo Home Page'),
 
);
  • Related