Skip to content

Commit

Permalink
managed all file and folder
Browse files Browse the repository at this point in the history
  • Loading branch information
ashwanisng committed Jun 4, 2021
1 parent ff044a8 commit 83be226
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 57 deletions.
56 changes: 0 additions & 56 deletions lib/main.dart
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
import 'package:vaccine_finder/screens/homepage.dart';
import 'package:vaccine_finder/screens/splash_screen.dart';
import 'package:vaccine_finder/theme/style.dart';
import 'package:vaccine_finder/theme/theme_provider.dart';

void main() {
runApp(MyApp());
Expand All @@ -17,55 +13,3 @@ class MyApp extends StatelessWidget {
);
}
}

class HomePage extends StatefulWidget {
@override
_HomePageState createState() => _HomePageState();
}

class _HomePageState extends State<HomePage> {
bool switchValue = false;
ThemeProvider themeProvider = ThemeProvider();

void getCurrentTheme() async {
themeProvider.darkTheme = await themeProvider.themePrefrences.getTheme();
}

@override
void initState() {
getCurrentTheme();
super.initState();
}

@override
Widget build(BuildContext context) {
return ChangeNotifierProvider(
create: (_) => themeProvider,
child: Consumer<ThemeProvider>(
builder: (context, value, child) {
return MaterialApp(
debugShowCheckedModeBanner: false,
theme: Style.themeData(themeProvider.darkTheme),
home: Scaffold(
appBar: AppBar(
backgroundColor: Color(0xff676FFE),
title: Text('Where is my Vaccine'),
actions: [
Switch(
value: switchValue,
onChanged: (val) {
themeProvider.darkTheme = !themeProvider.darkTheme;
setState(() {
switchValue = val;
});
})
],
),
body: DataFeild(),
),
);
},
),
);
}
}
File renamed without changes.
57 changes: 57 additions & 0 deletions lib/widget/homepage.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
import 'package:vaccine_finder/screens/data_feild.dart';
import 'package:vaccine_finder/theme/style.dart';
import 'package:vaccine_finder/theme/theme_provider.dart';

class HomePage extends StatefulWidget {
@override
_HomePageState createState() => _HomePageState();
}

class _HomePageState extends State<HomePage> {
bool switchValue = false;
ThemeProvider themeProvider = ThemeProvider();

void getCurrentTheme() async {
themeProvider.darkTheme = await themeProvider.themePrefrences.getTheme();
}

@override
void initState() {
getCurrentTheme();
super.initState();
}

@override
Widget build(BuildContext context) {
return ChangeNotifierProvider(
create: (_) => themeProvider,
child: Consumer<ThemeProvider>(
builder: (context, value, child) {
return MaterialApp(
debugShowCheckedModeBanner: false,
theme: Style.themeData(themeProvider.darkTheme),
home: Scaffold(
appBar: AppBar(
backgroundColor: Color(0xff676FFE),
title: Text('Where is my Vaccine'),
actions: [
Switch(
value: switchValue,
onChanged: (val) {
themeProvider.darkTheme = !themeProvider.darkTheme;
setState(() {
switchValue = val;
});
})
],
),
body: DataFeild(),
),
);
},
),
);
}
}
2 changes: 1 addition & 1 deletion test/widget_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import 'package:vaccine_finder/main.dart';
void main() {
testWidgets('Counter increments smoke test', (WidgetTester tester) async {
// Build our app and trigger a frame.
await tester.pumpWidget(HomePage());
await tester.pumpWidget(MyApp());

// Verify that our counter starts at 0.
expect(find.text('0'), findsOneWidget);
Expand Down

0 comments on commit 83be226

Please sign in to comment.