Loading lib/common/service/ioc_container.dart +5 −1 Original line number Original line Diff line number Diff line Loading @@ -17,6 +17,10 @@ class IoCContainer { ), ), ); ); get.registerSingleton(MediaService()); get.registerSingleton(MediaService()); get.registerSingleton(AuthService()); get.registerSingleton( AuthService( get<UserService>(), ), ); } } } } lib/common/widget/app_wrapper.dart +10 −4 Original line number Original line Diff line number Diff line import 'package:firebase_auth/firebase_auth.dart'; import 'package:flutter/material.dart'; import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; import 'package:stamped/bottom_nav_bar/widget/bottom_nav_bar.dart'; import 'package:stamped/bottom_nav_bar/widget/bottom_nav_bar.dart'; import 'package:stamped/common/service/ioc_container.dart'; import 'package:stamped/common/service/ioc_container.dart'; import 'package:stamped/common/widget/future_builder_handler.dart'; import 'package:stamped/pages/auth/login_page.dart'; import 'package:stamped/pages/auth/login_page.dart'; import 'package:stamped/pages/collections/notifiers/user_notifier.dart'; import 'package:stamped/service/auth_service.dart'; import 'package:stamped/service/auth_service.dart'; class AppWrapper extends StatelessWidget { class AppWrapper extends StatelessWidget { Loading @@ -16,7 +18,7 @@ class AppWrapper extends StatelessWidget { @override @override Widget build(BuildContext context) { Widget build(BuildContext context) { final authService = get<AuthService>(); final authService = get<AuthService>(); final userNotifier = context.watch<UserNotifier>(); return MaterialApp( return MaterialApp( title: 'Stamped!', title: 'Stamped!', theme: ThemeData( theme: ThemeData( Loading @@ -33,8 +35,12 @@ class AppWrapper extends StatelessWidget { if (!snapshot.hasData) { if (!snapshot.hasData) { return LoginPage(); return LoginPage(); } } return FutureBuilderHandler( future: authService.getUser(), builder: (context, data) { userNotifier.user = data; return BottomNavBar(); return BottomNavBar(); }); }, }, ), ), ); ); Loading lib/data/entities/user.dart +2 −0 Original line number Original line Diff line number Diff line Loading @@ -5,6 +5,7 @@ part 'user.g.dart'; @JsonSerializable() @JsonSerializable() class User { class User { final String id; final String id; final String googleAuthId; final String userName; final String userName; final String profilePicture; final String profilePicture; final String lastLocation; final String lastLocation; Loading @@ -12,6 +13,7 @@ class User { const User({ const User({ required this.id, required this.id, required this.googleAuthId, required this.userName, required this.userName, required this.profilePicture, required this.profilePicture, required this.lastLocation, required this.lastLocation, Loading lib/data/entities/user.g.dart +2 −0 Original line number Original line Diff line number Diff line Loading @@ -8,6 +8,7 @@ part of 'user.dart'; User _$UserFromJson(Map<String, dynamic> json) => User( User _$UserFromJson(Map<String, dynamic> json) => User( id: json['id'] as String, id: json['id'] as String, googleAuthId: json['googleAuthId'] as String, userName: json['userName'] as String, userName: json['userName'] as String, profilePicture: json['profilePicture'] as String, profilePicture: json['profilePicture'] as String, lastLocation: json['lastLocation'] as String, lastLocation: json['lastLocation'] as String, Loading @@ -16,6 +17,7 @@ User _$UserFromJson(Map<String, dynamic> json) => User( Map<String, dynamic> _$UserToJson(User instance) => <String, dynamic>{ Map<String, dynamic> _$UserToJson(User instance) => <String, dynamic>{ 'id': instance.id, 'id': instance.id, 'googleAuthId': instance.googleAuthId, 'userName': instance.userName, 'userName': instance.userName, 'profilePicture': instance.profilePicture, 'profilePicture': instance.profilePicture, 'lastLocation': instance.lastLocation, 'lastLocation': instance.lastLocation, Loading lib/main.dart +8 −1 Original line number Original line Diff line number Diff line import 'package:firebase_core/firebase_core.dart'; import 'package:firebase_core/firebase_core.dart'; import 'package:flutter/material.dart'; import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; import 'package:stamped/common/service/ioc_container.dart'; import 'package:stamped/common/service/ioc_container.dart'; import 'package:stamped/common/widget/app_wrapper.dart'; import 'package:stamped/common/widget/app_wrapper.dart'; import 'package:stamped/pages/collections/notifiers/user_notifier.dart'; import 'firebase_options.dart'; import 'firebase_options.dart'; Future<void> main() async { Future<void> main() async { Loading @@ -12,5 +14,10 @@ Future<void> main() async { ); ); IoCContainer.initialize(); IoCContainer.initialize(); runApp(AppWrapper()); runApp( ChangeNotifierProvider( create: (BuildContext context) => UserNotifier(), child: AppWrapper(), ), ); } } Loading
lib/common/service/ioc_container.dart +5 −1 Original line number Original line Diff line number Diff line Loading @@ -17,6 +17,10 @@ class IoCContainer { ), ), ); ); get.registerSingleton(MediaService()); get.registerSingleton(MediaService()); get.registerSingleton(AuthService()); get.registerSingleton( AuthService( get<UserService>(), ), ); } } } }
lib/common/widget/app_wrapper.dart +10 −4 Original line number Original line Diff line number Diff line import 'package:firebase_auth/firebase_auth.dart'; import 'package:flutter/material.dart'; import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; import 'package:stamped/bottom_nav_bar/widget/bottom_nav_bar.dart'; import 'package:stamped/bottom_nav_bar/widget/bottom_nav_bar.dart'; import 'package:stamped/common/service/ioc_container.dart'; import 'package:stamped/common/service/ioc_container.dart'; import 'package:stamped/common/widget/future_builder_handler.dart'; import 'package:stamped/pages/auth/login_page.dart'; import 'package:stamped/pages/auth/login_page.dart'; import 'package:stamped/pages/collections/notifiers/user_notifier.dart'; import 'package:stamped/service/auth_service.dart'; import 'package:stamped/service/auth_service.dart'; class AppWrapper extends StatelessWidget { class AppWrapper extends StatelessWidget { Loading @@ -16,7 +18,7 @@ class AppWrapper extends StatelessWidget { @override @override Widget build(BuildContext context) { Widget build(BuildContext context) { final authService = get<AuthService>(); final authService = get<AuthService>(); final userNotifier = context.watch<UserNotifier>(); return MaterialApp( return MaterialApp( title: 'Stamped!', title: 'Stamped!', theme: ThemeData( theme: ThemeData( Loading @@ -33,8 +35,12 @@ class AppWrapper extends StatelessWidget { if (!snapshot.hasData) { if (!snapshot.hasData) { return LoginPage(); return LoginPage(); } } return FutureBuilderHandler( future: authService.getUser(), builder: (context, data) { userNotifier.user = data; return BottomNavBar(); return BottomNavBar(); }); }, }, ), ), ); ); Loading
lib/data/entities/user.dart +2 −0 Original line number Original line Diff line number Diff line Loading @@ -5,6 +5,7 @@ part 'user.g.dart'; @JsonSerializable() @JsonSerializable() class User { class User { final String id; final String id; final String googleAuthId; final String userName; final String userName; final String profilePicture; final String profilePicture; final String lastLocation; final String lastLocation; Loading @@ -12,6 +13,7 @@ class User { const User({ const User({ required this.id, required this.id, required this.googleAuthId, required this.userName, required this.userName, required this.profilePicture, required this.profilePicture, required this.lastLocation, required this.lastLocation, Loading
lib/data/entities/user.g.dart +2 −0 Original line number Original line Diff line number Diff line Loading @@ -8,6 +8,7 @@ part of 'user.dart'; User _$UserFromJson(Map<String, dynamic> json) => User( User _$UserFromJson(Map<String, dynamic> json) => User( id: json['id'] as String, id: json['id'] as String, googleAuthId: json['googleAuthId'] as String, userName: json['userName'] as String, userName: json['userName'] as String, profilePicture: json['profilePicture'] as String, profilePicture: json['profilePicture'] as String, lastLocation: json['lastLocation'] as String, lastLocation: json['lastLocation'] as String, Loading @@ -16,6 +17,7 @@ User _$UserFromJson(Map<String, dynamic> json) => User( Map<String, dynamic> _$UserToJson(User instance) => <String, dynamic>{ Map<String, dynamic> _$UserToJson(User instance) => <String, dynamic>{ 'id': instance.id, 'id': instance.id, 'googleAuthId': instance.googleAuthId, 'userName': instance.userName, 'userName': instance.userName, 'profilePicture': instance.profilePicture, 'profilePicture': instance.profilePicture, 'lastLocation': instance.lastLocation, 'lastLocation': instance.lastLocation, Loading
lib/main.dart +8 −1 Original line number Original line Diff line number Diff line import 'package:firebase_core/firebase_core.dart'; import 'package:firebase_core/firebase_core.dart'; import 'package:flutter/material.dart'; import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; import 'package:stamped/common/service/ioc_container.dart'; import 'package:stamped/common/service/ioc_container.dart'; import 'package:stamped/common/widget/app_wrapper.dart'; import 'package:stamped/common/widget/app_wrapper.dart'; import 'package:stamped/pages/collections/notifiers/user_notifier.dart'; import 'firebase_options.dart'; import 'firebase_options.dart'; Future<void> main() async { Future<void> main() async { Loading @@ -12,5 +14,10 @@ Future<void> main() async { ); ); IoCContainer.initialize(); IoCContainer.initialize(); runApp(AppWrapper()); runApp( ChangeNotifierProvider( create: (BuildContext context) => UserNotifier(), child: AppWrapper(), ), ); } }