Moved Provider to the top level
parent
4b1eb20ca1
commit
7dd1a748f2
|
@ -2,11 +2,13 @@ import 'package:flutter/material.dart';
|
|||
import 'package:provider/provider.dart';
|
||||
import 'package:smoke_cess_app/pages/main_page.dart';
|
||||
import 'package:smoke_cess_app/providers/tasks_provider.dart';
|
||||
import 'package:smoke_cess_app/providers/timer_provider.dart';
|
||||
import 'package:smoke_cess_app/services/notification_service.dart';
|
||||
import 'package:timezone/data/latest.dart' as tz;
|
||||
import 'globals.dart' as globals;
|
||||
import 'providers/page_provider.dart';
|
||||
import 'providers/settings_provider.dart';
|
||||
import 'providers/workout_provider.dart';
|
||||
|
||||
void main() {
|
||||
// to ensure all the widgets are initialized.
|
||||
|
@ -25,6 +27,7 @@ class MyApp extends StatelessWidget {
|
|||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
TimerProvider timerProvider = TimerProvider();
|
||||
return MaterialApp(
|
||||
title: _title,
|
||||
home: MultiProvider(
|
||||
|
@ -37,7 +40,10 @@ class MyApp extends StatelessWidget {
|
|||
),
|
||||
ChangeNotifierProvider(
|
||||
create: (context) => PageProvider(),
|
||||
)
|
||||
),
|
||||
ChangeNotifierProvider(create: (context) => timerProvider),
|
||||
ChangeNotifierProvider(
|
||||
create: (context) => WorkoutProvider(timerProvider)),
|
||||
],
|
||||
child: const MyHomePage(),
|
||||
));
|
||||
|
|
|
@ -1,8 +1,4 @@
|
|||
import 'package:flutter/material.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
import '../providers/timer_provider.dart';
|
||||
import '../providers/workout_provider.dart';
|
||||
import 'mute_button.dart';
|
||||
import 'workout_timer_widget.dart';
|
||||
|
||||
|
@ -11,14 +7,7 @@ class WorkoutForm extends StatelessWidget {
|
|||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
TimerProvider timerProvider = TimerProvider();
|
||||
return MultiProvider(
|
||||
providers: [
|
||||
ChangeNotifierProvider(create: (context) => timerProvider),
|
||||
ChangeNotifierProvider(
|
||||
create: (context) => WorkoutProvider(timerProvider)),
|
||||
],
|
||||
child: Column(
|
||||
return Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: const [
|
||||
Align(
|
||||
|
@ -27,7 +16,6 @@ class WorkoutForm extends StatelessWidget {
|
|||
),
|
||||
WorkoutTimerWidget()
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue