Created
January 20, 2022 17:41
-
-
Save RageshAntony/2288a47a8fdc24af1e570a0c7cb9ed08 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@AdaptiveAutoRouter(routes: <AutoRoute>[ | |
AutoRoute(page: AuthMainView,initial: true), | |
AutoRoute(page: LoginView), | |
AutoRoute(page: RegisterPage), | |
AutoRoute(page: ThirdPage), | |
]) | |
class $FlutterRouter { | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class AuthController extends ChangeNotifier { | |
var _isLoading = false; | |
set isLoading(bool isLoading) {_isLoading = isLoading; notifyListeners();} // auto call notifyListers when variable changed | |
bool get isLoading => _isLoading; | |
Cable? _cable; | |
set cable(Cable? cable) {_cable = cable; notifyListeners();} | |
Cable? get cable => _cable; | |
final authRepo = AuthRepo(); | |
final phoneController = TextEditingController(); | |
final passController = TextEditingController(); | |
final emailController = TextEditingController(); | |
final cableController = TextEditingController(); | |
final addressController = TextEditingController(); | |
Future<BuiltList<GloginData_cable_opr>?> login() async{ | |
print("login"); | |
isLoading = true; | |
final cables = await authRepo.login(phoneController.text.trim(), passController.text.trim()); | |
isLoading = false; | |
return cables; | |
} | |
Future<GcreateCableProviderData_insert_cable_opr_one?> register() async{ | |
print("login"); | |
isLoading = true; | |
final cables = await authRepo.register(phoneController.text.trim(),passController.text.trim(),emailController.text.trim(),addressController.text.trim(),cableController.text.trim()); | |
isLoading = false; | |
return cables; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class AuthMainView extends HookConsumerWidget { | |
final controllerProvider = ChangeNotifierProvider<AuthController>( | |
(ref) => AuthController(), | |
); | |
@override | |
Widget build(BuildContext context,WidgetRef ref) { | |
final controller = ref.watch(controllerProvider); | |
return Scaffold( | |
body:SingleChildScrollView( | |
child:Container( | |
padding: EdgeInsets.symmetric(horizontal: 20), | |
height: MediaQuery.of(context).size.height, | |
decoration: BoxDecoration( | |
borderRadius: BorderRadius.all(Radius.circular(5)), | |
boxShadow: <BoxShadow>[ | |
BoxShadow( | |
color: Colors.grey.shade200, | |
offset: Offset(2, 4), | |
blurRadius: 5, | |
spreadRadius: 2) | |
], | |
gradient: LinearGradient( | |
begin: Alignment.topCenter, | |
end: Alignment.bottomCenter, | |
colors: [Color(0xfffbb448), Color(0xffe46b10)])), | |
child: Column( | |
crossAxisAlignment: CrossAxisAlignment.center, | |
mainAxisAlignment: MainAxisAlignment.center, | |
children: <Widget>[ | |
_title(context), | |
SizedBox( | |
height: 80, | |
), | |
_submitButton(context), | |
SizedBox( | |
height: 20, | |
), | |
_signUpButton(context), | |
SizedBox( | |
height: 20, | |
), | |
_label() | |
], | |
), | |
), | |
), | |
); | |
} | |
Widget _submitButton(BuildContext context) { | |
return InkWell( | |
onTap: () { | |
context.router.push(LoginViewRoute(),); | |
}, | |
child: Container( | |
width: MediaQuery.of(context).size.width, | |
padding: EdgeInsets.symmetric(vertical: 13), | |
alignment: Alignment.center, | |
decoration: BoxDecoration( | |
borderRadius: BorderRadius.all(Radius.circular(5)), | |
boxShadow: <BoxShadow>[ | |
BoxShadow( | |
color: Color(0xffdf8e33).withAlpha(100), | |
offset: Offset(2, 4), | |
blurRadius: 8, | |
spreadRadius: 2) | |
], | |
color: Colors.white), | |
child: Text( | |
t.login, | |
style: TextStyle(fontSize: 20, color: Color(0xfff7892b)), | |
), | |
), | |
); | |
} | |
Widget _signUpButton(BuildContext context) { | |
return InkWell( | |
onTap: () { | |
context.router.push(RegisterPageRoute(),); | |
}, | |
child: Container( | |
width: MediaQuery.of(context).size.width, | |
padding: EdgeInsets.symmetric(vertical: 13), | |
alignment: Alignment.center, | |
decoration: BoxDecoration( | |
borderRadius: BorderRadius.all(Radius.circular(5)), | |
border: Border.all(color: Colors.white, width: 2), | |
), | |
child: Text( | |
t.reg_now, | |
style: TextStyle(fontSize: 20, color: Colors.white), | |
), | |
), | |
); | |
} | |
Widget _label() { | |
return Container( | |
margin: EdgeInsets.only(top: 40, bottom: 20), | |
child: Column( | |
children: <Widget>[ | |
Text( | |
'Quick login with Touch ID', | |
style: TextStyle(color: Colors.white, fontSize: 17), | |
), | |
SizedBox( | |
height: 20, | |
), | |
Icon(Icons.fingerprint, size: 90, color: Colors.white), | |
SizedBox( | |
height: 20, | |
), | |
Text( | |
'Touch ID', | |
style: TextStyle( | |
color: Colors.white, | |
fontSize: 15, | |
decoration: TextDecoration.underline, | |
), | |
), | |
], | |
)); | |
} | |
Widget _title(BuildContext context) { | |
return RichText( | |
textAlign: TextAlign.center, | |
text: TextSpan( | |
text: 'cab', | |
style: GoogleFonts.portLligatSans( | |
textStyle: Theme.of(context).textTheme.headline1, | |
fontSize: 30, | |
fontWeight: FontWeight.w700, | |
color: Colors.white, | |
), | |
children: [ | |
TextSpan( | |
text: 'col', | |
style: TextStyle(color: Colors.black, fontSize: 30), | |
), | |
TextSpan( | |
text: 'now', | |
style: TextStyle(color: Colors.white, fontSize: 30), | |
), | |
]), | |
); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'package:auto_river_trans/app/routes/app_routes.gr.dart'; | |
import 'package:auto_route/src/router/auto_router_x.dart'; | |
import 'package:flutter/material.dart'; | |
import 'package:google_fonts/google_fonts.dart'; | |
import 'package:hooks_riverpod/hooks_riverpod.dart'; | |
import 'i18n/strings.g.dart'; | |
void main() { | |
WidgetsFlutterBinding.ensureInitialized(); // add this | |
LocaleSettings.useDeviceLocale(); // and this | |
runApp(const ProviderScope(child: MyApp())); | |
} | |
class MyApp extends StatelessWidget { | |
const MyApp({Key? key}) : super(key: key); | |
// This widget is the root of your application. | |
@override | |
Widget build(BuildContext context) { | |
final _flutterRoute = FlutterRouter(); | |
return MaterialApp.router( | |
//title: 'Flutter Demo', | |
theme: ThemeData( | |
fontFamily: GoogleFonts.rambla().fontFamily | |
), | |
locale: Locale('en','US'), | |
// home: const MyHomePage(title: 'Flutter Demo Home Page'), | |
title: 'Navigation Tutorial', | |
routeInformationParser: _flutterRoute.defaultRouteParser(), | |
routerDelegate: _flutterRoute.delegate(), | |
builder: (context, router) => router!, | |
); | |
} | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: auto_river_trans | |
description: A new Flutter project. | |
publish_to: 'none' # Remove this line if you wish to publish to pub.dev | |
version: 1.0.0+1 | |
environment: | |
sdk: ">=2.15.1 <3.0.0" | |
dependencies: | |
auto_route: ^3.2.1 | |
google_fonts: ^2.2.0 | |
ferry: ^0.10.4 | |
gql_http_link: ^0.4.0 | |
hooks_riverpod: ^1.0.3 | |
flutter: | |
sdk: flutter | |
cupertino_icons: ^1.0.2 | |
dev_dependencies: | |
auto_route_generator: ^3.2.1 | |
build_runner: ^2.1.7 | |
fast_i18n: 5.8.0 | |
ferry_generator: ^0.4.4 | |
flutter_test: | |
sdk: flutter | |
dependency_overrides: | |
analyzer: ^3.1.0 | |
flutter_lints: ^1.0.0 | |
flutter: | |
# The following line ensures that the Material Icons font is | |
# included with your application, so that you can use the icons in | |
# the material Icons class. | |
uses-material-design: true | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Change your main.dart file to the below code and try again
import 'package:auto_river_trans/app/routes/app_routes.gr.dart';
import 'package:auto_route/src/router/auto_router_x.dart';
import 'package:flutter/material.dart';
import 'package:google_fonts/google_fonts.dart';
import 'package:hooks_riverpod/hooks_riverpod.dart';
import 'i18n/strings.g.dart';
void main() {
WidgetsFlutterBinding.ensureInitialized(); // add this
LocaleSettings.useDeviceLocale(); // and this
runApp(const ProviderScope(child: MyApp()));
}
final _flutterRoute = FlutterRouter();
class MyApp extends StatelessWidget {
const MyApp({Key? key}) : super(key: key);
// This widget is the root of your application.
@OverRide
Widget build(BuildContext context) {
}
}``