main.dart 1.0 KB

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