Search code examples
flutterflutter-layoutflutter-theme

The method 'dark' isn't defined for the type 'ThemeData'


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(),
    );
  }
}


Solution

  • 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'),
     
    );