main.dart 937 B

123456789101112131415161718192021222324252627282930313233
  1. import 'package:flutter/material.dart';
  2. import 'package:flutter_provider_demo/routes.dart';
  3. import 'package:provider/provider.dart';
  4. void main() {
  5. runApp(const MyApp());
  6. }
  7. class MyApp extends StatelessWidget {
  8. const MyApp({super.key});
  9. // This widget is the root of your application.
  10. @override
  11. Widget build(BuildContext context) {
  12. return MultiProvider(
  13. providers: [
  14. // Provider<Counter>.value(value: Counter()),
  15. ChangeNotifierProvider<Counter>(create: (_) => Counter()),
  16. ChangeNotifierProvider<ThemeModel>(create: (_) => ThemeModel()),
  17. ],
  18. child: MaterialApp(
  19. title: 'Provider Demo',
  20. debugShowCheckedModeBanner: false,
  21. theme: ThemeData(
  22. primarySwatch: Colors.blue,
  23. visualDensity: VisualDensity.adaptivePlatformDensity,
  24. ),
  25. initialRoute: Routes.index,
  26. onGenerateRoute: Routes.generateRoute,
  27. ),
  28. );
  29. }
  30. }