repo_id
stringlengths
21
168
file_path
stringlengths
36
210
content
stringlengths
1
9.98M
__index_level_0__
int64
0
0
mirrored_repositories/flutter_spacexopedia/lib/ui/pages
mirrored_repositories/flutter_spacexopedia/lib/ui/pages/roadster/roadster_page.dart
import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:flutter_spacexopedia/bloc/roadster/index.dart'; import 'package:flutter_spacexopedia/ui/pages/common/error_page.dart'; import 'package:flutter_spacexopedia/ui/pages/common/no_connection.dart'; import 'package:flutter_spacexopedia/ui/pages/common/no_content.dart'; import 'package:flutter_spacexopedia/ui/pages/roadster/roadster_screen.dart'; class RoadsterPage extends StatefulWidget { @override _RoadsterPageState createState() => _RoadsterPageState(); } class _RoadsterPageState extends State<RoadsterPage> { final _roadsterBloc = RoadsterBloc(); @override void initState() { super.initState(); _load(); } @override void dispose() { super.dispose(); } void _load() { _roadsterBloc.add(LaunchInitial()); } @override Widget build(BuildContext context) { final theme = Theme.of(context); return Scaffold( backgroundColor: theme.backgroundColor, body: BlocBuilder<RoadsterBloc, RoadsterState>( bloc: _roadsterBloc, builder: ( BuildContext context, RoadsterState currentState, ) { if (currentState is ErrorRoadsterState) { return ErrorPage( dsiplayReloadButton: true, message: currentState.error, onReload: _load, ); } else if (currentState is LoadedState) { if (currentState.model == null) return NoContent(); return RoadsterScreen( model: currentState.model, ); } else if (currentState is NoConnectionDragonState) { return NoInternetConnection( message: currentState.errorMessage, onReload: () { BlocProvider.of<RoadsterBloc>(context).add(LaunchInitial()); }, ); } return Center( child: CircularProgressIndicator(), ); }, ), ); } }
0
mirrored_repositories/flutter_spacexopedia/lib/ui/pages
mirrored_repositories/flutter_spacexopedia/lib/ui/pages/common/error_page.dart
import 'package:flutter/material.dart'; class ErrorPage extends StatelessWidget { const ErrorPage({ Key key, this.message, this.messageStyle, this.onReload, this.dsiplayReloadButton = false, }) : super(key: key); final String message; final TextStyle messageStyle; final Function onReload; final bool dsiplayReloadButton; @override Widget build(BuildContext context) { return Center( child: Column( crossAxisAlignment: CrossAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.center, children: <Widget>[ Text( message ?? 'An error occured. Please try again!!', style: messageStyle ?? Theme.of(context).typography.dense.headline6, textAlign: TextAlign.center, ), if (!dsiplayReloadButton) Padding( padding: const EdgeInsets.only(top: 32.0), child: RaisedButton(child: Text('reload'), onPressed: onReload), ), ], ), ); } }
0
mirrored_repositories/flutter_spacexopedia/lib/ui/pages
mirrored_repositories/flutter_spacexopedia/lib/ui/pages/common/no_content.dart
import 'package:flutter/material.dart'; class NoContent extends StatelessWidget { const NoContent({ Key key, this.message, this.messageStyle, this.onReload, this.dsiplayReloadButton = false, }) : super(key: key); final String message; final TextStyle messageStyle; final Function onReload; final bool dsiplayReloadButton; @override Widget build(BuildContext context) { return Center( child: Column( crossAxisAlignment: CrossAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.center, children: <Widget>[ Text( message ?? 'No content found!!', style: messageStyle ?? Theme.of(context).typography.dense.headline6, textAlign: TextAlign.center, ), if (!dsiplayReloadButton) Padding( padding: const EdgeInsets.only(top: 32.0), child: RaisedButton(child: Text('reload'), onPressed: onReload), ), ], ), ); } }
0
mirrored_repositories/flutter_spacexopedia/lib/ui/pages
mirrored_repositories/flutter_spacexopedia/lib/ui/pages/common/no_connection.dart
import 'package:flutter/material.dart'; class NoInternetConnection extends StatelessWidget { const NoInternetConnection({ Key key, this.message, this.messageStyle, this.onReload, this.hideReloadButton = false, }) : super(key: key); final String message; final TextStyle messageStyle; final Function onReload; final bool hideReloadButton; @override Widget build(BuildContext context) { return Center( child: Column( crossAxisAlignment: CrossAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.center, children: <Widget>[ Text( message ?? 'No internet connection!!', style: messageStyle ?? Theme.of(context) .typography .dense .headline5 .copyWith(color: Theme.of(context).errorColor), textAlign: TextAlign.center, ), if(!hideReloadButton) Padding( padding: const EdgeInsets.only(top: 32.0), child: RaisedButton(child: Text('reload'), onPressed: onReload), ), ], ), ); } }
0
mirrored_repositories/flutter_spacexopedia/lib/ui/pages
mirrored_repositories/flutter_spacexopedia/lib/ui/pages/rockets/rocket_screen.dart
import 'package:flutter/material.dart'; import 'package:flutter_spacexopedia/bloc/rocket/rocket_model.dart'; import 'package:flutter_spacexopedia/helper/utils.dart'; import 'package:flutter_spacexopedia/ui/pages/rockets/rocket_detail.dart'; import 'package:flutter_spacexopedia/ui/widgets/list_card.dart'; import 'package:flutter_spacexopedia/ui/widgets/title_text.dart'; import 'package:flutter_spacexopedia/ui/widgets/title_value.dart'; class RocketScreen extends StatelessWidget { final List<RocketModel> rockets; const RocketScreen({Key key, this.rockets}) : super(key: key); @override Widget build(BuildContext context) { return ListView.builder( itemCount: rockets.length, itemBuilder: (context, index) => RocketCard( model: rockets[index], ), ); } } class RocketCard extends StatelessWidget { final RocketModel model; const RocketCard({Key key, this.model}) : super(key: key); @override Widget build(BuildContext context) { return ListCard( imagePath: model.flickrImages.first, onPressed: () { Navigator.push(context,MaterialPageRoute(builder: (_) => RocketDetail(model: model,))); }, bodyContent: Column( mainAxisAlignment: MainAxisAlignment.spaceEvenly, crossAxisAlignment: CrossAxisAlignment.start, children: <Widget>[ TitleText(model.rocketName, fontSize:14), TitleValue( title: "Rocket Id:", value: model.rocketId, ), TitleValue( title: "First flight date:", value: Utils.toformattedDate(model.firstFlight), ), TitleValue( title: "company:", value: model.company, ), ], ), ); } }
0
mirrored_repositories/flutter_spacexopedia/lib/ui/pages
mirrored_repositories/flutter_spacexopedia/lib/ui/pages/rockets/rocket_detail.dart
import 'package:flutter/material.dart'; import 'package:flutter_spacexopedia/bloc/rocket/rocket_model.dart'; import 'package:flutter_spacexopedia/ui/theme/extentions.dart'; import 'package:flutter_spacexopedia/ui/widgets/custom_heading_tile.dart'; import 'package:flutter_spacexopedia/ui/widgets/custom_list_tile.dart'; import 'package:flutter_spacexopedia/ui/widgets/image_slider.dart'; import 'package:flutter_spacexopedia/ui/widgets/title_text.dart'; class RocketDetail extends StatelessWidget { const RocketDetail({Key key, this.model}) : super(key: key); final RocketModel model; @override Widget build(BuildContext context) { final theme = Theme.of(context); return Scaffold( body: Column( children: <Widget>[ Expanded( child: CustomScrollView( slivers: <Widget>[ SliverAppBar( title: Title( color: theme.backgroundColor, child: Text(model.rocketName), title: model.rocketName, ), pinned: true, stretch: true, expandedHeight: 260, flexibleSpace: PhotoPageView( imageList: model.flickrImages, ), ), SliverList( delegate: SliverChildListDelegate( [ SizedBox(height: model.description == null ? 0 : 16), model.description == null ? SizedBox.shrink() : ListTile( title: TitleText("Description", fontSize: 15), subtitle: TitleText( model.description ?? "", fontSize: 14, fontWeight: FontWeight.w400, textAlign: TextAlign.justify, ).vP8, ), SizedBox(height: 10), Divider(height: 0), SHeadingTile("Basic info"), SListTile("Name", model.rocketName), Divider(height: 0), SListTile("Layout", model.engines.layout), Divider(height: 0), SListTile("Diameter", "${model.diameter.meters} m"), Divider(height: 0), SListTile("Height", "${model.height.meters} m"), Divider(height: 0), SListTile("Weight", "${model.mass.kg} Kg"), Divider(height: 0), SListTile("Engines", "${model.engines.number}"), Divider(height: 0), SListTile("Landing legs", "${model.landingLegs.number}"), Divider(height: 0), SListTile( "Landing legs material", "${model.landingLegs.material}", ), Divider(height: 0), SListTile("Boosters", model.boosters.toString()), Divider(height: 0), SListTile("Sucess rate", "${model.successRatePct} %"), Divider(height: 0), SListTile( "Cost per launch", model.costPerLaunch.toString(), ), SHeadingTile("Engine"), Divider(height: 0), SListTile("Type ", "${model.engines.type}"), Divider(height: 0), SListTile("Version", "${model.engines.version}"), Divider(height: 0), SListTile("Layout", "${model.engines.layout}"), Divider(height: 0), SListTile("Propellant 1", "${model.engines.propellant1}"), Divider(height: 0), SListTile("Propellant 1", "${model.engines.propellant2}"), Divider(height: 0), SListTile( "Thrust sea level", "${model.engines.thrustSeaLevel.kN} Kn", ), Divider(height: 0), SListTile( "Thrust to weight", "${model.engines.thrustToWeight}", ), Divider(height: 0), SListTile( "Thrust to vaccum", "${model.engines.thrustVacuum.kN} Kn", ), ], ), ), ], ), ), ], ), ); } }
0
mirrored_repositories/flutter_spacexopedia/lib/ui/pages
mirrored_repositories/flutter_spacexopedia/lib/ui/pages/rockets/rocket_page.dart
import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:flutter_spacexopedia/bloc/rocket/index.dart'; import 'package:flutter_spacexopedia/ui/pages/common/error_page.dart'; import 'package:flutter_spacexopedia/ui/pages/common/no_connection.dart'; import 'package:flutter_spacexopedia/ui/pages/common/no_content.dart'; import 'package:flutter_spacexopedia/ui/pages/rockets/rocket_screen.dart'; class RocketPage extends StatefulWidget { @override _RocketPageState createState() => _RocketPageState(); } class _RocketPageState extends State<RocketPage> { final _rocketBloc = RocketBloc(); @override void initState() { super.initState(); _load(); } @override void dispose() { super.dispose(); } @override Widget build(BuildContext context) { return BlocBuilder<RocketBloc, RocketState>( bloc: _rocketBloc, builder: ( BuildContext context, RocketState currentState, ) { if (currentState is LoadingRockets) { return Center( child: CircularProgressIndicator(), ); } else if (currentState is ErrorRocketState) { /// If any error occured during data fetching return ErrorPage( dsiplayReloadButton: true, message: currentState.errorMessage, onReload: _load, ); } else if (currentState is LoadedRocketState) { /// If content is null if (currentState.list == null) return NoContent(); /// If content is not null return RocketScreen( rockets: currentState.list, ); } else if (currentState is NoConnectionDragonState) { /// If internet is not connected return NoInternetConnection( message: currentState.errorMessage, onReload: () { BlocProvider.of<RocketBloc>(context).add(LaunchInitial()); }, ); } return Center( child: CircularProgressIndicator(), ); }, ); } void _load() { _rocketBloc.add(LaunchInitial()); } }
0
mirrored_repositories/flutter_spacexopedia/lib/ui
mirrored_repositories/flutter_spacexopedia/lib/ui/theme/custom_theme.dart
import 'package:flutter/material.dart'; import 'package:flutter_spacexopedia/ui/theme/app_theme_provider.dart'; import 'package:flutter_spacexopedia/ui/theme/theme.dart'; class CustomTheme extends StatefulWidget { final Widget child; final ThemeType initialThemeKey; const CustomTheme({ Key key, this.initialThemeKey, @required this.child, }) : super(key: key); @override CustomThemeState createState() => new CustomThemeState(); static ThemeData of(BuildContext context) { ThemeProvider inherited = (context.dependOnInheritedWidgetOfExactType<ThemeProvider>()); return inherited.data.theme; } static CustomThemeState instanceOf(BuildContext context) { ThemeProvider inherited = (context.dependOnInheritedWidgetOfExactType<ThemeProvider>()); return inherited.data; } } class CustomThemeState extends State<CustomTheme> { ThemeData _theme; ThemeData get theme => _theme; @override void initState() { _theme = AppTheme.getThemeFromKey(widget.initialThemeKey); super.initState(); } void changeTheme(ThemeType themeKey) { setState(() { _theme = AppTheme.getThemeFromKey(themeKey); }); } @override Widget build(BuildContext context) { return ThemeProvider( data: this, child: widget.child, ); } }
0
mirrored_repositories/flutter_spacexopedia/lib/ui
mirrored_repositories/flutter_spacexopedia/lib/ui/theme/text_styles.dart
import 'package:flutter/material.dart'; class TextStyles { static TextStyle titleStyle = const TextStyle(fontSize: 16); static TextStyle subTitleStyle = const TextStyle(fontSize: 12); static TextStyle h1Style = const TextStyle(fontSize: 24, fontWeight: FontWeight.bold); static TextStyle h2Style = const TextStyle(fontSize: 22); static TextStyle h3Style = const TextStyle(fontSize: 20); static TextStyle h4Style = const TextStyle(fontSize: 18); static TextStyle h5Style = const TextStyle(fontSize: 16); static TextStyle h6Style = const TextStyle(fontSize: 14); }
0
mirrored_repositories/flutter_spacexopedia/lib/ui
mirrored_repositories/flutter_spacexopedia/lib/ui/theme/app_theme_provider.dart
import 'package:flutter/material.dart'; import 'package:flutter_spacexopedia/ui/theme/custom_theme.dart'; class ThemeProvider extends InheritedWidget { final CustomThemeState data; ThemeProvider({ Widget child, Key key, this.data }) : assert(data != null), super( child: child, key: key, ); static ThemeProvider of(BuildContext context) =>context.dependOnInheritedWidgetOfExactType<ThemeProvider>(); @override bool updateShouldNotify(ThemeProvider oldWidget) { return true; } }
0
mirrored_repositories/flutter_spacexopedia/lib/ui
mirrored_repositories/flutter_spacexopedia/lib/ui/theme/theme.dart
import 'package:flutter/material.dart'; import 'package:flutter_spacexopedia/ui/theme/colors/dark_color.dart'; import 'colors/light_color.dart'; enum ThemeType { LIGHT, DARK } class AppTheme { const AppTheme._(); static ThemeData lightTheme = ThemeData.light().copyWith( backgroundColor: LightColor.background, primaryColor: LightColor.primaryColor, cardTheme: CardTheme(color: LightColor.background), iconTheme: IconThemeData(color: LightColor.iconColor), bottomAppBarColor: LightColor.bottomAppBarColor, dividerColor: LightColor.grey, cardColor: LightColor.primaryExtraLightColor, appBarTheme: AppBarTheme( brightness: Brightness.light, color: LightColor.primaryColor, iconTheme: IconThemeData( color: LightColor.background ) ), disabledColor: LightColor.grey, primaryTextTheme: TextTheme( bodyText1: TextStyle( color: LightColor.titleTextColor, )), brightness: Brightness.light, tabBarTheme: TabBarTheme( labelPadding: EdgeInsets.symmetric(vertical: 16), ), buttonTheme: ButtonThemeData( buttonColor: LightColor.buttonColor, disabledColor: LightColor.disableButtonColor, textTheme: ButtonTextTheme.normal, ), primaryIconTheme: IconThemeData(color: LightColor.secondaryColor), colorScheme: ColorScheme( primary: LightColor.primaryColor, primaryVariant: LightColor.primaryLightColor, secondary: LightColor.secondaryColor, secondaryVariant: LightColor.secondaryLightColor, surface: LightColor.background, background: LightColor.background, error: Colors.red, onPrimary: LightColor.onBackground, onSecondary: LightColor.black, onSurface: LightColor.titleTextColor, onBackground: LightColor.titleTextColor, onError: LightColor.titleTextColor, brightness: Brightness.dark), textTheme: TextTheme( bodyText1: TextStyle(color: LightColor.titleTextColor), subtitle1: TextStyle( color: LightColor.subTitleTextColor, fontWeight: FontWeight.bold, ), ), popupMenuTheme: PopupMenuThemeData( textStyle: TextStyle( fontSize: 20, color: LightColor.titleTextColor, ), color: LightColor.background)); static ThemeData darkTheme = ThemeData.dark().copyWith( backgroundColor: DarkColor.background, primaryColor: DarkColor.primaryColor, primaryColorDark: DarkColor.Darker, primaryColorLight: DarkColor.Brighter, appBarTheme: AppBarTheme( brightness: Brightness.dark, color: DarkColor.Brighter, iconTheme: IconThemeData( color: LightColor.secondaryColor ) ), tabBarTheme: TabBarTheme( labelPadding: EdgeInsets.symmetric(vertical: 16), ), buttonTheme: ButtonThemeData( buttonColor: DarkColor.buttonColor, disabledColor: DarkColor.disableButtonColor, textTheme: ButtonTextTheme.normal), bottomAppBarColor: DarkColor.bottomAppBarColor, primaryIconTheme: IconThemeData(color: DarkColor.secondaryColor), colorScheme: ColorScheme( primary: DarkColor.primaryColor, primaryVariant: DarkColor.primaryLightColor, secondary: DarkColor.secondaryColor, secondaryVariant: DarkColor.secondaryLightColor, surface: DarkColor.background, background: DarkColor.background, error: Colors.red, onPrimary: DarkColor.titleTextColor, onSecondary: DarkColor.white, onSurface: DarkColor.titleTextColor, onBackground: DarkColor.titleTextColor, onError: DarkColor.titleTextColor, brightness: Brightness.dark), textTheme: TextTheme( bodyText1: TextStyle(color: Color(0xffd1d1d0)), subtitle1: TextStyle( color: DarkColor.subTitleTextColor, fontWeight: FontWeight.bold, ), ), iconTheme: IconThemeData(color: DarkColor.lightGrey), brightness: Brightness.dark, popupMenuTheme: PopupMenuThemeData( textStyle: TextStyle( fontSize: 20, color: DarkColor.titleTextColor, ), color: DarkColor.background),); static EdgeInsets hPadding = const EdgeInsets.symmetric( horizontal: 16, ); static double fullWidth(BuildContext context) { return MediaQuery.of(context).size.width; } static double fullHeight(BuildContext context) { return MediaQuery.of(context).size.height; } static ThemeData getThemeFromKey(ThemeType themeKey) { switch (themeKey) { case ThemeType.LIGHT: return lightTheme; case ThemeType.DARK: return darkTheme; default: return lightTheme; } } }
0
mirrored_repositories/flutter_spacexopedia/lib/ui
mirrored_repositories/flutter_spacexopedia/lib/ui/theme/extentions.dart
import 'package:flutter/material.dart'; import 'package:flutter_spacexopedia/ui/theme/colors/light_color.dart'; extension TextStyleHelpers on TextStyle { TextStyle get bold => copyWith(fontWeight: FontWeight.bold); TextStyle get white => copyWith(color: Colors.white); TextStyle get subTitleColor => copyWith(color: LightColor.subTitleTextColor); } extension PaddingHelper on Widget { Padding get p16 => Padding(padding: EdgeInsets.all(16), child: this); /// Set padding according to `value` Padding p(double value) => Padding(padding: EdgeInsets.all(value), child: this); /// Set padding only according to `value` Padding pO({double left = 0, double top = 0,double right = 0, double bottom = 0}) => Padding(padding: EdgeInsets.only(top:top,right: right, bottom:bottom, left:left), child: this); /// Horizontal Padding 16 Padding get hP4 => Padding(padding: EdgeInsets.symmetric(horizontal: 4), child: this); Padding get hP8 => Padding(padding: EdgeInsets.symmetric(horizontal: 8), child: this); Padding get hP16 => Padding(padding: EdgeInsets.symmetric(horizontal: 16), child: this); /// Vertical Padding 16 Padding get vP16 => Padding(padding: EdgeInsets.symmetric(vertical: 16), child: this); Padding get vP8 => Padding(padding: EdgeInsets.symmetric(vertical: 8), child: this); Padding get vP4 => Padding(padding: EdgeInsets.symmetric(vertical: 8), child: this); } extension Extented on Widget { Expanded get extended => Expanded( child: this, ); } extension CornerRadius on Widget { ClipRRect get circular => ClipRRect( borderRadius: BorderRadius.all(Radius.circular(1000)), child: this, ); } extension OnPressed on Widget { Widget ripple(Function onPressed, {BorderRadiusGeometry borderRadius = const BorderRadius.all(Radius.circular(5))}) => Stack( children: <Widget>[ this, Positioned( left: 0, right: 0, top: 0, bottom: 0, child: FlatButton( shape: RoundedRectangleBorder(borderRadius: borderRadius), onPressed: () { if (onPressed != null) { onPressed(); } }, child: Container()), ) ], ); } extension ExAlignment on Widget { Widget get alignTopCenter => Align( child: this, alignment: Alignment.topCenter, ); Widget get alignCenter => Align( child: this, alignment: Alignment.center, ); Widget get alignBottomCenter => Align( child: this, alignment: Alignment.bottomCenter, ); Widget get alignBottomLeft => Align( child: this, alignment: Alignment.bottomLeft, ); }
0
mirrored_repositories/flutter_spacexopedia/lib/ui/theme
mirrored_repositories/flutter_spacexopedia/lib/ui/theme/colors/dark_color.dart
import 'package:flutter/material.dart'; class DarkColor { static const Color background = Color(0xff2a2a2a); static const Color black = Color(0xff000000); static const Color white = Color(0xffffffff); static const Color lightGrey = Color(0xff797878); static const Color Brighter = Color(0xff1a1a1c); static const Color Darker = Colors.black; static const Color titleTextColor = const Color(0xffd1d1d0); static const Color subTitleTextColor = const Color(0xff797878); static const Color bottomAppBarColor = const Color(0xff252525); static const Color primaryColor = const Color(0xff4f4f4f); static const Color secondaryColor = const Color(0xff4cd1bc); static const Color secondaryLightColor = const Color(0xff85ffee); static const Color primaryDarkColor = const Color(0xff000000); static const Color primaryLightColor = const Color(0xff272727); static const Color buttonColor = const Color(0xff121212); static const Color disableButtonColor = const Color(0xff252525); }
0
mirrored_repositories/flutter_spacexopedia/lib/ui/theme
mirrored_repositories/flutter_spacexopedia/lib/ui/theme/colors/light_color.dart
import 'package:flutter/material.dart'; class LightColor { static const Color background = Color(0XFFfefefe); static const Color titleTextColor = const Color(0xff1b1718); static const Color subTitleTextColor = const Color(0xffb9bfcd); static const Color grey = Color(0xffb8bfce); static const Color iconColor = Color(0xffcbd0db); static const Color Brighter = Color(0xffa5a5a5); static const Color Darker = Colors.black; static const Color black = Color(0xff20262C); static const Color onBackground = Color(0xff5F5F60); static const Color bottomAppBarColor = const Color(0xffffffff); static const Color secondaryColor = const Color(0xff4cd1bc); static const Color secondaryLightColor = const Color(0xff85ffee); static const Color primaryColor = const Color(0xff8873f4); static const Color primaryLightColor = const Color(0xff9489f4); static const Color primaryExtraLightColor = const Color(0xffb1a5f6); static const Color buttonColor = const Color(0xff71b4fb); static const Color disableButtonColor = const Color(0xffb8bfce); }
0
mirrored_repositories/flutter_spacexopedia
mirrored_repositories/flutter_spacexopedia/test/widget_test.dart
// This is a basic Flutter widget test. // // To perform an interaction with a widget in your test, use the WidgetTester // utility that Flutter provides. For example, you can send tap and scroll // gestures. You can also use WidgetTester to find child widgets in the widget // tree, read text, and verify that the values of widget properties are correct. void main() { }
0
mirrored_repositories/ecommerc-app
mirrored_repositories/ecommerc-app/lib/main.dart
import 'package:app/screen/home/home_page.dart'; import 'package:flutter/material.dart'; import 'package:get/get_navigation/src/root/get_material_app.dart'; void main() => runApp(const GetMaterialApp(home: HomePage()));
0
mirrored_repositories/ecommerc-app
mirrored_repositories/ecommerc-app/lib/constant.dart
import 'package:flutter/material.dart'; const double kSpace = 10; const kPrimaryColor = Color(0xFF3366FF); const kPrimaryLightColor = Color(0xFF00CCFF); const kPrimaryGradientColor = LinearGradient( begin: Alignment.topLeft, end: Alignment.bottomRight, colors: [Color(0xFF3366FF), Color(0xFF00CCFF)], ); const kSecondaryColor = Color(0xFF979797); const kTextColor = Color(0xFF757575);
0
mirrored_repositories/ecommerc-app/lib
mirrored_repositories/ecommerc-app/lib/components/_star_rating.dart
import 'package:flutter/material.dart'; import 'package:smooth_star_rating_null_safety/smooth_star_rating_null_safety.dart'; showStarRating(rating, color) { return SmoothStarRating( allowHalfRating: false, onRatingChanged: (v) {}, starCount: 5, rating: rating, size: 20.0, halfFilledIconData: Icons.blur_on, color: color, borderColor: Colors.grey.shade400, spacing: 0.0); }
0
mirrored_repositories/ecommerc-app/lib
mirrored_repositories/ecommerc-app/lib/components/_close_activity.dart
import 'package:flutter/material.dart'; import 'package:get/get.dart'; GestureDetector closeActivity() { return GestureDetector( onTap: () => Get.back(), child: const Padding( padding: EdgeInsets.all(10), child: CircleAvatar( child: Icon( Icons.close, color: Colors.white, ), ), ), ); } const borderRadius = BorderRadius.all( Radius.circular(10.0), );
0
mirrored_repositories/ecommerc-app/lib
mirrored_repositories/ecommerc-app/lib/components/_input_fields.dart
import 'package:flutter/material.dart'; class CustomInputField extends StatelessWidget { final Icon fieldIcon; final String hintText; const CustomInputField( Key? key, this.fieldIcon, this.hintText, ) : super(key: key); @override Widget build(BuildContext context) { return SizedBox( width: 350, child: Material( elevation: 5.0, borderRadius: const BorderRadius.all(Radius.circular(10.0)), color: Colors.white, child: TextFormField( decoration: InputDecoration( hintText: hintText, prefixIcon: fieldIcon, border: OutlineInputBorder( borderRadius: BorderRadius.circular(5.0), borderSide: const BorderSide( color: Colors.amber, style: BorderStyle.solid, ), ), ), ), ), ); } }
0
mirrored_repositories/ecommerc-app/lib
mirrored_repositories/ecommerc-app/lib/components/theme.dart
import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:app/constant.dart'; ThemeData theme() { return ThemeData( scaffoldBackgroundColor: Colors.white, fontFamily: "Muli", appBarTheme: appBarTheme(), textTheme: textTheme(), inputDecorationTheme: inputDecorationTheme(), visualDensity: VisualDensity.adaptivePlatformDensity, ); } AppBarTheme appBarTheme() { return AppBarTheme( color: Colors.white, elevation: 0, systemOverlayStyle: SystemUiOverlayStyle.light, iconTheme: const IconThemeData(color: Colors.black), toolbarTextStyle: const TextTheme( headline6: TextStyle( color: Colors.white, fontSize: 18, //TextStyle(color: Color(0XFF8B8B8B), fontSize: 18), ), ).bodyText2, titleTextStyle: const TextTheme( headline6: TextStyle( color: Colors.white, fontSize: 18, //TextStyle(color: Color(0XFF8B8B8B), fontSize: 18), ), ).headline6); } TextTheme textTheme() { return const TextTheme( bodyText1: TextStyle(color: kTextColor), bodyText2: TextStyle(color: kTextColor), ); } InputDecorationTheme inputDecorationTheme() { OutlineInputBorder outlineInputBorder = OutlineInputBorder( borderRadius: BorderRadius.circular(28), borderSide: const BorderSide(color: kTextColor), gapPadding: 10, ); return InputDecorationTheme( floatingLabelBehavior: FloatingLabelBehavior.always, contentPadding: const EdgeInsets.symmetric(horizontal: 42, vertical: 20), enabledBorder: outlineInputBorder, focusedBorder: outlineInputBorder, border: outlineInputBorder, ); }
0
mirrored_repositories/ecommerc-app/lib
mirrored_repositories/ecommerc-app/lib/models/_res_files.dart
import 'package:flutter/material.dart'; import 'Product.dart'; import '_payment_cart_model.dart'; class Res { static const String lamp = "assets/images/lamp.png"; static const String chair = "assets/images/chair.png"; static const String sofa = "assets/images/sofa.png"; static const String table = "assets/images/table.png"; static const String table1 = "assets/images/table_1.png"; static List<Product> fetchProducts() { List<Product> productList = []; String description = "A product description is the marketing copy that explains what a product is and why it’s worth purchasing. The purpose of a product description is to supply customers with important information about the features and benefits of the product so they’re compelled to buy"; productList.add(Product( color: Colors.amber.shade900, count: "3", description: description, image: Res.sofa, info: "", price: "5000", size: "23/56", tag: "", title: "Sofa")); productList.add(Product( color: Colors.lightBlue.shade500, count: "1", description: description, image: Res.table, info: "", price: "4000", size: "43/506", tag: "", title: "Table")); productList.add(Product( color: Colors.yellow.shade800, count: "30", description: description, image: Res.lamp, info: "", price: "500", size: "23/56", tag: "", title: "Lamp")); productList.add(Product( color: Colors.pink, count: "5", description: description, image: Res.chair, info: "", price: "500", size: "23/56", tag: "", title: "Chair")); productList.add(Product( color: Colors.teal, count: "5", description: description, image: Res.table1, info: "", price: "500", size: "23/56", tag: "", title: "Reading Table")); return productList; } static List<PayCard> getPaymentTypes() { List<PayCard> cards = []; cards.add(PayCard( title: "Net Banking", description: "Pay bill using card", image: "assets/images/paycard.png")); cards.add(PayCard( title: "Credit Card", description: "Pay bill using card", image: "assets/images/paycard.png")); cards.add(PayCard( title: "Debit Card", description: "Pay bill using card", image: "assets/images/paycard.png")); cards.add(PayCard( title: "Wallet pay", description: "Pay bill using card", image: "assets/images/paycard.png")); return cards; } }
0
mirrored_repositories/ecommerc-app/lib
mirrored_repositories/ecommerc-app/lib/models/_payment_cart_model.dart
class PayCard { String title; String description; String image; PayCard( {required this.title, required this.description, required this.image}); }
0
mirrored_repositories/ecommerc-app/lib
mirrored_repositories/ecommerc-app/lib/models/Product.dart
// ignore: file_names import 'package:flutter/material.dart'; class Product { Color color; String title; String image; String price; String tag; String description; String size; String count; String info; Product( {required this.color, required this.title, required this.image, required this.price, required this.tag, required this.description, required this.size, required this.count, required this.info}); }
0
mirrored_repositories/ecommerc-app/lib/screen
mirrored_repositories/ecommerc-app/lib/screen/cart/cart_page.dart
import 'package:flutter/material.dart'; import '../../models/Product.dart'; import '../../models/_res_files.dart'; import 'components/_build_app_bar.dart'; import 'components/_item_cart_view.dart'; class CartPage extends StatefulWidget { @override _CartPageState createState() => _CartPageState(); } class _CartPageState extends State<CartPage> { @override Widget build(BuildContext context) { List<Product> products = Res.fetchProducts(); return Scaffold( //backgroundColor: Colors.grey.shade200, appBar: buildAppBar(context), body: Container( padding: const EdgeInsets.all(10.0), child: ListView.builder( itemCount: products.length, itemBuilder: (context, index) { return buildCartCard(products[index]); }, ), )); } }
0
mirrored_repositories/ecommerc-app/lib/screen/cart
mirrored_repositories/ecommerc-app/lib/screen/cart/components/_item_cart_view.dart
import 'package:flutter/material.dart'; import 'package:app/constant.dart'; import 'package:app/helper/_utils.dart'; import '_card_img.dart'; Card buildCartCard(product) { return Card( elevation: 4, margin: const EdgeInsets.all(10), child: Column( children: [ Row( children: [ cardImage(product), const SizedBox(width: kSpace), Expanded( child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( product.title, style: mediumText, ), Text( "Cocktail dress", style: smallText, ), Text("Size: XS", style: smallText), Text( "Color: Yellow", style: smallText, ), const SizedBox(height: kSpace), _cartPriceDescriptionRightToImg(product), ], ), ) ], ), const Divider(color: Colors.grey), Padding( padding: const EdgeInsets.all(kSpace), child: Column( children: [ _viewSubtotal(product), _viewDeliveryPrice(), _viewDiscountPrice(), _viewTotalPrice(product), ], ), ) ], ), ); } Row _cartPriceDescriptionRightToImg(product) { return Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Text("\$ ${product.price}", style: mediumText), Row( mainAxisAlignment: MainAxisAlignment.end, children: [ const Icon(Icons.add_circle), const SizedBox(width: kSpace), Text("1", style: mediumText), const SizedBox(width: kSpace), const Icon(Icons.remove_circle), ], ) ], ); } Row _viewTotalPrice(product) { return Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Text( "Total", style: mediumText, ), Text( "\$ ${product.price}", style: mediumText, ), ], ); } Row _viewDiscountPrice() { return Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Text( "Discount", style: smallText, ), Text( "No discount", style: smallText, ), ], ); } Row _viewDeliveryPrice() { return Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Text( "Delivery", style: smallText, ), Text( "\$0", style: smallText, ), ], ); } Row _viewSubtotal(product) { return Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Text( "Subtotal", style: smallText, ), Text( product.price, style: smallText, ), ], ); }
0
mirrored_repositories/ecommerc-app/lib/screen/cart
mirrored_repositories/ecommerc-app/lib/screen/cart/components/_card_img.dart
import 'package:flutter/material.dart'; Image cardImage(product) { return Image.asset( product.image, width: 150, height: 180, fit: BoxFit.fill, color: product.color, ); }
0
mirrored_repositories/ecommerc-app/lib/screen/cart
mirrored_repositories/ecommerc-app/lib/screen/cart/components/_build_app_bar.dart
import 'package:app/components/_close_activity.dart'; import 'package:get/get.dart'; import 'package:flutter/material.dart'; import '../../payment/payment_page.dart'; AppBar buildAppBar(BuildContext context) { return AppBar( elevation: 0, leading: closeActivity(), title: const Text("Cart", style: TextStyle(color: Colors.black)), backgroundColor: Colors.grey.shade100, actions: [ Container( padding: const EdgeInsets.all(10), child: buildGoPaymentBtn(context), ), ], ); } OutlinedButton buildGoPaymentBtn(BuildContext context) { return OutlinedButton( style: OutlinedButton.styleFrom( animationDuration: const Duration(seconds: 5), padding: const EdgeInsets.all(10)), onPressed: () => Get.to(() => PaymentPage()), child: const Text('Payment')); }
0
mirrored_repositories/ecommerc-app/lib/screen
mirrored_repositories/ecommerc-app/lib/screen/login/login_page.dart
import 'package:flutter/material.dart'; import 'components/_body.dart'; class LoginScreen extends StatefulWidget { const LoginScreen({Key? key}) : super(key: key); @override _LoginScreenState createState() => _LoginScreenState(); } class _LoginScreenState extends State<LoginScreen> { @override Widget build(BuildContext context) { return Scaffold( body: loginBody(context), ); } }
0
mirrored_repositories/ecommerc-app/lib/screen/login
mirrored_repositories/ecommerc-app/lib/screen/login/components/_body.dart
import 'package:flutter/material.dart'; import '../../../components/_input_fields.dart'; import '../../../constant.dart'; import '../../../components/_close_activity.dart'; import 'package:get/get.dart'; Stack loginBody(context) { final deviceWidth = MediaQuery.of(context).size.width; return Stack( children: <Widget>[ Container(decoration: boxGradientDecoration()), SafeArea( child: GestureDetector( onTap: () => Get.back(), child: closeActivity(), )), Center( child: Center( child: Column( mainAxisAlignment: MainAxisAlignment.center, children: <Widget>[ _iconThumbnail(), const SizedBox(height: kSpace), SizedBox( width: deviceWidth * .80, child: imputFieldLogin('Username'), ), const SizedBox(height: 20), SizedBox( width: deviceWidth * .80, child: imputFieldLogin('Password'), ), const SizedBox(height: 20), Container( width: (deviceWidth * .50) * .50, color: Colors.white, height: 45, child: OutlinedButton( //onPressed: () => print('Login btn tapped'), onPressed: () {}, child: const Text('Login'), ), ) ], ), ), ), ], ); } BoxDecoration boxGradientDecoration() { return const BoxDecoration( gradient: LinearGradient( colors: [ kPrimaryColor, kPrimaryLightColor, ], begin: FractionalOffset(0.0, 0.0), end: FractionalOffset(1.0, 0.0), stops: [0.0, 1.0], tileMode: TileMode.clamp), ); } CustomInputField imputFieldLogin(field) { return CustomInputField( null, const Icon( Icons.person, color: Colors.redAccent, size: 30, ), field, ); } Image _iconThumbnail() { return Image.asset( 'assets/images/sofa.png', width: 150, height: 150, ); }
0
mirrored_repositories/ecommerc-app/lib/screen
mirrored_repositories/ecommerc-app/lib/screen/details/detail_page.dart
import 'package:flutter/material.dart'; import '../../constant.dart'; import '../../models/Product.dart'; import 'component/_build_app_bar.dart'; import 'component/_build_cart_btn.dart'; import 'component/_image_view.dart'; import 'component/_row_price_rating.dart'; class ProductDetail extends StatelessWidget { const ProductDetail({ Key? key, required this.product, }) : super(key: key); final Product product; @override Widget build(BuildContext context) { return Scaffold( appBar: detailAppBar(product), body: Stack( children: [ showImageView(context, product), const SizedBox(height: kSpace), Positioned( bottom: 50, left: 20, right: 20, child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ buildRowPriceRating(product), const SizedBox(height: kSpace), Text( product.description, textAlign: TextAlign.justify, overflow: TextOverflow.ellipsis, style: const TextStyle(fontSize: 16.0, color: Colors.white), maxLines: 5, ), const SizedBox(height: 20), Center(child: btnAddToCart(context, product)), ], ), ), ], ), ); } }
0
mirrored_repositories/ecommerc-app/lib/screen/details
mirrored_repositories/ecommerc-app/lib/screen/details/component/_build_cart_btn.dart
import 'package:flutter/material.dart'; import '../../cart/cart_page.dart'; import 'package:get/get.dart'; OutlinedButton btnAddToCart(BuildContext context, product) { return OutlinedButton( style: OutlinedButton.styleFrom( animationDuration: const Duration(seconds: 5), backgroundColor: product.color, side: const BorderSide(width: 1, color: Colors.white), padding: const EdgeInsets.all(10)), onPressed: () => Get.to(() => CartPage()), child: const Text( 'ADD TO CART', style: TextStyle( color: Colors.white, fontWeight: FontWeight.bold, ), )); }
0
mirrored_repositories/ecommerc-app/lib/screen/details
mirrored_repositories/ecommerc-app/lib/screen/details/component/_image_view.dart
import 'package:flutter/material.dart'; Container showImageView(BuildContext context, product) { var screenSize = MediaQuery.of(context).size; var screenHeight = (screenSize.height); return Container( padding: const EdgeInsets.all(20), color: product.color, child: Image.asset( product.image, alignment: Alignment.centerRight, height: screenHeight * 50, ), ); }
0
mirrored_repositories/ecommerc-app/lib/screen/details
mirrored_repositories/ecommerc-app/lib/screen/details/component/_build_app_bar.dart
import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:app/components/_close_activity.dart'; AppBar detailAppBar(product) { return AppBar( elevation: 0, backgroundColor: product.color, title: Text( product.title, style: const TextStyle( color: Colors.white, fontWeight: FontWeight.bold, ), ), leading: closeActivity(), centerTitle: true, actions: const [ Padding( padding: EdgeInsets.all(8), child: CircleAvatar( child: Icon( CupertinoIcons.cart, size: 30, color: Colors.white, ), ), ), ], ); }
0
mirrored_repositories/ecommerc-app/lib/screen/details
mirrored_repositories/ecommerc-app/lib/screen/details/component/_row_price_rating.dart
import 'package:flutter/material.dart'; import '../../../components/_star_rating.dart'; Row buildRowPriceRating(product) { return Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Text("Price: \$${product.price}", style: const TextStyle( fontSize: 22, fontWeight: FontWeight.bold, color: Colors.white, )), showStarRating(3.0, Colors.white) ], ); }
0
mirrored_repositories/ecommerc-app/lib/screen
mirrored_repositories/ecommerc-app/lib/screen/home/home_page.dart
import 'package:flutter/material.dart'; import 'package:app/screen/home/components/_body.dart'; import '../../models/_res_files.dart'; class HomePage extends StatelessWidget { const HomePage({Key? key}) : super(key: key); @override Widget build(BuildContext context) { var products = Res.fetchProducts(); return Scaffold( backgroundColor: Colors.grey.shade200, body: SafeArea( child: Padding( padding: const EdgeInsets.symmetric(horizontal: 15), child: detailBody(products, context), ), ), ); } }
0
mirrored_repositories/ecommerc-app/lib/screen/home
mirrored_repositories/ecommerc-app/lib/screen/home/components/_body.dart
import 'package:flutter/material.dart'; import '../../../constant.dart'; import '../../../models/Product.dart'; import '_action_bar.dart'; import '_categories.dart'; import '_product_category.dart'; import '_search_filter_view.dart'; Column detailBody(List<Product> products, BuildContext context) { return Column( crossAxisAlignment: CrossAxisAlignment.center, children: [ buildActionBar(), const SizedBox(height: kSpace), buildSearchRow(), const SizedBox(height: kSpace), section('Categories'), const SizedBox(height: kSpace), SizedBox( height: 140, child: category(products), ), const SizedBox(height: kSpace), section('Most popular'), const SizedBox(height: kSpace), Expanded(child: mostPopularCategory(context, products)) ], ); }
0
mirrored_repositories/ecommerc-app/lib/screen/home
mirrored_repositories/ecommerc-app/lib/screen/home/components/_search_filter_view.dart
import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:app/components/_close_activity.dart'; Row buildSearchRow() { return Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Expanded(child: _showTextField()), const SizedBox(width: 20), Container( color: Colors.grey.shade300, height: 45, width: 45, child: _buildFilterBtn(), ), ], ); } _showTextField() { return TextField( decoration: InputDecoration( suffixIcon: const Icon(Icons.search), focusedBorder: InputBorder.none, enabledBorder: InputBorder.none, border: const OutlineInputBorder( gapPadding: 8, borderRadius: borderRadius, ), filled: true, hintStyle: TextStyle(color: Colors.grey[800]), hintText: "Search products", fillColor: Colors.grey.shade300), ); } IconButton _buildFilterBtn() { return IconButton( alignment: Alignment.center, icon: const Icon(CupertinoIcons.sort_down, size: 20), onPressed: () => print("Filter clicked"), tooltip: "Filter", iconSize: 35, padding: const EdgeInsets.all(10), color: Colors.teal, ); }
0
mirrored_repositories/ecommerc-app/lib/screen/home
mirrored_repositories/ecommerc-app/lib/screen/home/components/_build_popular_card.dart
import 'package:flutter/material.dart'; import 'package:app/models/Product.dart'; import 'package:app/screen/details/detail_page.dart'; import 'package:get/get.dart'; buildPopularCard(Product product) { return Padding( padding: const EdgeInsets.all(2), child: GestureDetector( onTap: () { Get.to(ProductDetail(product: product)); }, child: _productCard(product), )); } Card _productCard(Product product) { return Card( elevation: 8, color: product.color, child: GridTile( child: Column( children: [ _imageIcon(product), Padding( padding: const EdgeInsets.symmetric(horizontal: 8), child: _title(product), ), ], ), ), ); } Text _title(Product product) { return Text( product.title, style: const TextStyle( fontWeight: FontWeight.bold, color: Colors.white, ), ); } Container _imageIcon(Product product) { return Container( height: 100, width: 120, padding: const EdgeInsets.all(20), child: Image.asset( product.image, fit: BoxFit.cover, height: 80, width: 80, ), ); }
0
mirrored_repositories/ecommerc-app/lib/screen/home
mirrored_repositories/ecommerc-app/lib/screen/home/components/_action_bar.dart
import 'package:flutter/cupertino.dart'; import 'package:app/screen/login/login_page.dart'; import 'package:get/get.dart'; Row buildActionBar() { return Row( children: [ const Text( 'Discover', style: TextStyle(fontSize: 30, fontWeight: FontWeight.bold), ), const Spacer(), GestureDetector( onTap: () => Get.to(const LoginScreen()), child: const Icon( CupertinoIcons.profile_circled, size: 45, ), ), ], ); }
0
mirrored_repositories/ecommerc-app/lib/screen/home
mirrored_repositories/ecommerc-app/lib/screen/home/components/_categories.dart
import 'package:flutter/material.dart'; Row section(title) { return Row( children: [ Text( title, style: const TextStyle(fontSize: 18, fontWeight: FontWeight.bold), ), const Spacer(), const Icon(Icons.arrow_forward) ], ); }
0
mirrored_repositories/ecommerc-app/lib/screen/home
mirrored_repositories/ecommerc-app/lib/screen/home/components/_build_category_card.dart
import 'package:flutter/material.dart'; import '../../../components/_star_rating.dart' show showStarRating; import '../../../models/Product.dart'; buildCard(Product product) { return Padding( padding: const EdgeInsets.all(2), child: Card( elevation: 4, child: Container( height: 140, decoration: BoxDecoration( borderRadius: BorderRadius.circular(15), ), child: GridTile( header: Padding( padding: const EdgeInsets.all(12), child: imageIcon(product), ), footer: _buildPriceRating(product), child: Container(), ), ), ), ); } Padding _buildPriceRating(Product product) { return Padding( padding: const EdgeInsets.all(10), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ _titlePrice(product), const SizedBox(height: 8), showStarRating(3.0, product.color) ], ), ); } Text description(Product product) { return Text( product.description, maxLines: 2, ); } Row _titlePrice(Product product) { return Row( children: [ Text( product.title, style: const TextStyle( fontWeight: FontWeight.bold, ), ), const Spacer(), Text( '\$ ${product.price}', style: const TextStyle( fontWeight: FontWeight.bold, color: Colors.blue, ), ) ], ); } Image imageIcon(Product product) { return Image.asset( product.image, fit: BoxFit.cover, height: 100, width: 100, ); }
0
mirrored_repositories/ecommerc-app/lib/screen/home
mirrored_repositories/ecommerc-app/lib/screen/home/components/_product_category.dart
import 'package:flutter/material.dart'; import '../../details/detail_page.dart'; import 'package:get/get.dart'; import '_build_category_card.dart'; import '_build_popular_card.dart'; ListView category(productList) { return ListView.builder( padding: const EdgeInsets.only(left: 0), itemCount: productList.length, scrollDirection: Axis.horizontal, itemBuilder: (BuildContext context, int index) { return GestureDetector( onTap: () => {Get.to(ProductDetail)}, child: buildPopularCard(productList[index]), ); }); } GridView mostPopularCategory(context, product) { return GridView.count( crossAxisCount: 2, children: List.generate(product.length, (index) { return GestureDetector( onTap: () => Get.to(ProductDetail(product: product[index])), child: buildCard(product[index]), ); }), ); }
0
mirrored_repositories/ecommerc-app/lib/screen
mirrored_repositories/ecommerc-app/lib/screen/payment/payment_page.dart
import 'package:flutter/material.dart'; import '../../models/_payment_cart_model.dart'; import '../../models/_res_files.dart'; import 'components/_body.dart'; class PaymentPage extends StatelessWidget { @override Widget build(BuildContext context) { List<PayCard> payemnts = Res.getPaymentTypes(); // ignore: unused_local_variable for (var element in payemnts) { //print(element.title); } return Scaffold( appBar: payActionbar(), body: Column( children: [ creditcardImage(), choosePaymentType(), ], ), ); } }
0
mirrored_repositories/ecommerc-app/lib/screen/payment
mirrored_repositories/ecommerc-app/lib/screen/payment/components/_body.dart
import 'package:flutter/material.dart'; import 'package:app/components/_close_activity.dart'; import 'package:font_awesome_flutter/font_awesome_flutter.dart'; import 'package:get/get.dart'; import '../../../constant.dart'; Container choosePaymentType() { return Container( padding: const EdgeInsets.symmetric(horizontal: 30), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ const Text( 'Choose payemnt method', style: TextStyle( color: Colors.black, fontWeight: FontWeight.bold, fontSize: 16), ), const SizedBox(height: 20), paymenOptions(), const SizedBox(height: 30), const Text( 'Promo Code', style: TextStyle( color: Colors.black, fontWeight: FontWeight.bold, fontSize: 16), ), const SizedBox(height: 20), promoCodeWidget(), const SizedBox(height: 120), Row( children: const [ Text( 'Total payment', style: TextStyle(color: Colors.black, fontSize: 16), ), Spacer(), Text( '\$500.99', style: TextStyle( color: Colors.black, fontWeight: FontWeight.bold, fontSize: 18), ), ], ), const SizedBox(height: 30), SizedBox( height: 45, width: double.infinity, child: OutlinedButton( style: OutlinedButton.styleFrom( backgroundColor: Colors.black, shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(25.0), ), side: BorderSide(width: 2, color: Colors.grey.shade500), ), onPressed: () { Get.snackbar("Processing", 'Payment is processing', animationDuration: const Duration(seconds: 2)); }, child: const Text( 'PAY', style: TextStyle(color: Colors.white), ), ), ) ], ), ); } Row paymenOptions() { return Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: const [ CircleAvatar( maxRadius: 25, child: FaIcon(FontAwesomeIcons.amazonPay, size: 35)), FaIcon(FontAwesomeIcons.ccVisa, size: 35), FaIcon(FontAwesomeIcons.paypal, size: 35), FaIcon(FontAwesomeIcons.apple, size: 35), FaIcon(FontAwesomeIcons.donate, size: 35), ], ); } Padding creditcardImage() { return Padding( padding: const EdgeInsets.all(30), child: Container( padding: const EdgeInsets.all(20), height: 200, width: double.infinity, decoration: creditcardDecoration(), child: creditCardView(), ), ); } AppBar payActionbar() { return AppBar( elevation: 0, backgroundColor: Colors.white, leading: closeActivity(), ); } Container promoCodeWidget() { return Container( width: double.infinity, height: 40, clipBehavior: Clip.none, decoration: BoxDecoration( color: Colors.grey.shade300, borderRadius: const BorderRadius.all(Radius.circular(20))), child: Align( alignment: Alignment.centerRight, child: OutlinedButton( style: OutlinedButton.styleFrom( backgroundColor: Colors.black, shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(18.0), ), side: const BorderSide(width: 2, color: Colors.black), ), onPressed: () {}, child: const Text( 'Apply', style: TextStyle(color: Colors.white), ), ), ), ); } Column creditCardView() { return Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ const Text( 'Credit Card', style: TextStyle( color: Colors.white, ), ), const Spacer(), const Text( '3763 4367 7346 0046', style: TextStyle( color: Colors.white, fontSize: 18, ), ), const SizedBox(height: kSpace), Row( children: const [ Text( 'Shailesh Mishra', style: TextStyle( color: Colors.white, ), ), Spacer(), Icon( Icons.ac_unit_outlined, ) ], ) ], ); } BoxDecoration creditcardDecoration() { return BoxDecoration( color: Colors.grey.shade800, borderRadius: const BorderRadius.all( Radius.circular(20), )); }
0
mirrored_repositories/ecommerc-app/lib
mirrored_repositories/ecommerc-app/lib/helper/_keyboard.dart
import 'package:flutter/cupertino.dart'; class KeyboardUtil { static void hideKeyboard(BuildContext context) { FocusScopeNode currentFocus = FocusScope.of(context); if (!currentFocus.hasPrimaryFocus) { currentFocus.unfocus(); } } }
0
mirrored_repositories/ecommerc-app/lib
mirrored_repositories/ecommerc-app/lib/helper/_utils.dart
import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:google_fonts/google_fonts.dart'; TextStyle smallText = GoogleFonts.ptSans( fontSize: 12, fontWeight: FontWeight.normal, ); TextStyle normalText = GoogleFonts.ptSansCaption( fontSize: 14, fontWeight: FontWeight.normal, ); TextStyle mediumText = GoogleFonts.ptSans( fontSize: 18, ); TextStyle largeText = GoogleFonts.ptSans( fontSize: 22, fontWeight: FontWeight.bold, ); TextStyle extraLargeText = GoogleFonts.ptSansCaption( fontSize: 35, fontWeight: FontWeight.bold, ); TextStyle xxLargeText = GoogleFonts.ptSans( fontSize: 45, );
0
mirrored_repositories/ecommerc-app
mirrored_repositories/ecommerc-app/test/widget_test.dart
// This is a basic Flutter widget test. // // To perform an interaction with a widget in your test, use the WidgetTester // utility in the flutter_test package. For example, you can send tap and scroll // gestures. You can also use WidgetTester to find child widgets in the widget // tree, read text, and verify that the values of widget properties are correct. import 'package:app/screen/home/home_page.dart'; import 'package:flutter/material.dart'; import 'package:flutter_test/flutter_test.dart'; void main() { testWidgets('Counter increments smoke test', (WidgetTester tester) async { // Build our app and trigger a frame. await tester.pumpWidget(const HomePage()); // Verify that our counter starts at 0. expect(find.text('0'), findsOneWidget); expect(find.text('1'), findsNothing); // Tap the '+' icon and trigger a frame. await tester.tap(find.byIcon(Icons.add)); await tester.pump(); // Verify that our counter has incremented. expect(find.text('0'), findsNothing); expect(find.text('1'), findsOneWidget); }); }
0
mirrored_repositories/Flutter_Performance_Demo
mirrored_repositories/Flutter_Performance_Demo/lib/main.dart
import 'package:flutter/material.dart'; final style = TextStyle(fontSize: 40); void main() => runApp( WidgetsApp( debugShowCheckedModeBanner: false, color: Color(0xFFFFFFFF), builder: (context, _) => MyApp(), ), ); class MyApp extends StatefulWidget { @override _MyHomePageState createState() => _MyHomePageState(); } class _MyHomePageState extends State<MyApp> { var switchTree = true; Widget get firstTree => Row( mainAxisAlignment: MainAxisAlignment.center, children: <Widget>[ RichText( text: TextSpan(text: "Hello Dart", style: style), ), SizedBox( width: 10, ), Image.asset( 'assets/dart_logo.png', height: 40, ) ], ); Widget get secondTree => Row( mainAxisAlignment: MainAxisAlignment.center, children: <Widget>[ RichText( text: TextSpan(text: "Hello Flutter", style: style), ), SizedBox( width: 10, ), // Padding(padding: EdgeInsets.only(right: 10)), Image.asset( 'assets/flutter_logo.png', height: 40, ) ], ); Widget get switchButton => GestureDetector( child: Padding( padding: const EdgeInsets.only(bottom: 20), child: RichText( text: TextSpan(text: "Switch Tree"), ), ), onTap: () => setState( () => switchTree = !switchTree, ), ); @override Widget build(BuildContext context) { return Column( children: <Widget>[ Expanded(child: switchTree == true ? firstTree : secondTree), switchButton ], ); } }
0
mirrored_repositories/Flutter_Performance_Demo
mirrored_repositories/Flutter_Performance_Demo/test/widget_test.dart
// This is a basic Flutter widget test. // // To perform an interaction with a widget in your test, use the WidgetTester // utility that Flutter provides. For example, you can send tap and scroll // gestures. You can also use WidgetTester to find child widgets in the widget // tree, read text, and verify that the values of widget properties are correct. import 'package:flutter/material.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:flutter_performance_demo/main.dart'; void main() { testWidgets('Counter increments smoke test', (WidgetTester tester) async { // Build our app and trigger a frame. await tester.pumpWidget(MyApp()); // Verify that our counter starts at 0. expect(find.text('0'), findsOneWidget); expect(find.text('1'), findsNothing); // Tap the '+' icon and trigger a frame. await tester.tap(find.byIcon(Icons.add)); await tester.pump(); // Verify that our counter has incremented. expect(find.text('0'), findsNothing); expect(find.text('1'), findsOneWidget); }); }
0
mirrored_repositories/Login-Register-FlutterApp
mirrored_repositories/Login-Register-FlutterApp/lib/main.dart
import 'package:flutter/material.dart'; import 'package:task/results_screen/ForgotPassword.dart'; import 'package:task/main_screens/LoginPage.dart'; import 'package:task/main_screens/RegisterPage.dart'; import 'results_screen/Done.dart'; void main() => runApp(Home()); class Home extends StatelessWidget { @override Widget build(BuildContext context) { return MaterialApp( debugShowCheckedModeBanner: false, theme: ThemeData(fontFamily: 'Abel'), initialRoute: RegisterPage.id, routes: { RegisterPage.id: (context) => RegisterPage(), LoginPage.id: (context) => LoginPage(), ForgotPassword.id: (context) => ForgotPassword(), Done.id: (context) => Done(), }, ); } }
0
mirrored_repositories/Login-Register-FlutterApp/lib
mirrored_repositories/Login-Register-FlutterApp/lib/results_screen/GoogleDone.dart
import 'package:firebase_auth/firebase_auth.dart'; import 'package:flutter/material.dart'; import 'package:google_sign_in/google_sign_in.dart'; // ignore: must_be_immutable class GoogleDone extends StatelessWidget { GoogleSignIn _googleSignIn; FirebaseUser _user; GoogleDone(FirebaseUser user, GoogleSignIn signIn) { _user = user; _googleSignIn = signIn; print(_user); print(_googleSignIn); } @override Widget build(BuildContext context) { return Scaffold( body: Center( child: Column( mainAxisAlignment: MainAxisAlignment.center, children: [ ClipOval( child: _user.photoUrl != null ? Image.network( _user.photoUrl, width: 100, height: 100, fit: BoxFit.cover, ) : Image.network( 'https://lh3.googleusercontent.com/6UgEjh8Xuts4nwdWzTnWH8QtLuHqRMUB7dp24JYVE2xcYzq4HA8hFfcAbU-R-PC_9uA1', width: 100, height: 100, fit: BoxFit.cover, ), ), Text(_user.displayName, textAlign: TextAlign.center, style: TextStyle(fontWeight: FontWeight.bold, fontSize: 25)), FlatButton( shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(20)), onPressed: () { _googleSignIn.signOut(); Navigator.pop(context); }, child: Text('Google sign in Done!'), ), ], ), ), ); } }
0
mirrored_repositories/Login-Register-FlutterApp/lib
mirrored_repositories/Login-Register-FlutterApp/lib/results_screen/ForgotPassword.dart
import 'package:firebase_auth/firebase_auth.dart'; import 'package:flutter/material.dart'; import 'package:awesome_dialog/awesome_dialog.dart'; // ignore: must_be_immutable class ForgotPassword extends StatelessWidget { static String id = '/ForgotPassword'; final _auth = FirebaseAuth.instance; String email; Future<void> resetPassword(String email) async { await _auth.sendPasswordResetEmail(email: email); } @override Widget build(BuildContext context) { return Scaffold( resizeToAvoidBottomInset: false, backgroundColor: Colors.white, body: Stack( children: [ Align( alignment: Alignment.topRight, child: Image.asset('assets/images/background.png'), ), Padding( padding: EdgeInsets.only( top: 60.0, bottom: 20.0, left: 20.0, right: 20.0), child: Column( crossAxisAlignment: CrossAxisAlignment.stretch, mainAxisAlignment: MainAxisAlignment.spaceAround, children: [ Text( 'Reset Password', style: TextStyle(fontSize: 40.0), ), Column( crossAxisAlignment: CrossAxisAlignment.start, mainAxisAlignment: MainAxisAlignment.start, children: [ Text( 'Enter your email', style: TextStyle(fontSize: 30.0), ), SizedBox(height: 20.0), TextField( keyboardType: TextInputType.emailAddress, onChanged: (value) { email = value; }, decoration: InputDecoration( hintText: 'Email', ), ), ], ), RaisedButton( padding: EdgeInsets.symmetric(vertical: 10.0), color: Color(0xff447def), onPressed: () { resetPassword(email); AwesomeDialog( context: context, dialogType: DialogType.SUCCES, animType: AnimType.SCALE, title: 'Email Sent ✈️', desc: 'Check your email to reset password!', btnCancelOnPress: () {}, btnOkOnPress: () {}, )..show(); }, child: Text( 'Reset Password', style: TextStyle(fontSize: 25.0, color: Colors.white), ), ), ], ), ), ], ), ); } }
0
mirrored_repositories/Login-Register-FlutterApp/lib
mirrored_repositories/Login-Register-FlutterApp/lib/results_screen/Done.dart
import 'package:firebase_auth/firebase_auth.dart'; import 'package:flutter/material.dart'; FirebaseUser loggedInUser; // ignore: must_be_immutable class Done extends StatefulWidget { static String id = '/Done'; @override _DoneState createState() => _DoneState(); } class _DoneState extends State<Done> { final _auth = FirebaseAuth.instance; void getCurrentUser() async { try { //TODO 10 : New user variable to check if a newUser is signed in final user = await _auth.currentUser(); //Equal to null if no user is signed in, else equal to new user details //TODO 11 : Use if else block to get the loggedInUser details if (user != null) { loggedInUser = user; } } catch (e) { print(e); } } @override void initState() { super.initState(); getCurrentUser(); } @override Widget build(BuildContext context) { return Scaffold( body: Container( decoration: BoxDecoration( image: DecorationImage( image: AssetImage("assets/images/done.jpg"), fit: BoxFit.cover, ), ), child: Container( decoration: BoxDecoration( gradient: LinearGradient( begin: Alignment.bottomRight, stops: [0.5, 1], colors: [ Colors.black.withOpacity(.9), Colors.black.withOpacity(.2) ], ), ), child: Center( child: Text( 'Welcome User!', style: TextStyle(fontSize: 50.0, color: Colors.white), ), ), ), ), ); } }
0
mirrored_repositories/Login-Register-FlutterApp/lib
mirrored_repositories/Login-Register-FlutterApp/lib/main_screens/LoginPage.dart
import 'package:firebase_auth/firebase_auth.dart'; import 'package:flutter/material.dart'; import 'package:task/results_screen/ForgotPassword.dart'; import 'package:task/results_screen/GoogleDone.dart'; import 'package:task/main_screens/RegisterPage.dart'; import 'package:google_sign_in/google_sign_in.dart'; import '../results_screen/Done.dart'; import 'package:modal_progress_hud/modal_progress_hud.dart'; bool _wrongEmail = false; bool _wrongPassword = false; FirebaseUser _user; // ignore: must_be_immutable class LoginPage extends StatefulWidget { static String id = '/LoginPage'; @override _LoginPageState createState() => _LoginPageState(); } class _LoginPageState extends State<LoginPage> { String email; String password; bool _showSpinner = false; final GoogleSignIn _googleSignIn = GoogleSignIn(); final FirebaseAuth _auth = FirebaseAuth.instance; Future<FirebaseUser> _handleSignIn() async { // hold the instance of the authenticated user // FirebaseUser user; // flag to check whether we're signed in already bool isSignedIn = await _googleSignIn.isSignedIn(); if (isSignedIn) { // if so, return the current user _user = await _auth.currentUser(); } else { final GoogleSignInAccount googleUser = await _googleSignIn.signIn(); final GoogleSignInAuthentication googleAuth = await googleUser.authentication; // get the credentials to (access / id token) // to sign in via Firebase Authentication final AuthCredential credential = GoogleAuthProvider.getCredential( accessToken: googleAuth.accessToken, idToken: googleAuth.idToken); _user = (await _auth.signInWithCredential(credential)).user; } return _user; } void onGoogleSignIn(BuildContext context) async { setState(() { _showSpinner = true; }); FirebaseUser user = await _handleSignIn(); setState(() { _showSpinner = true; }); Navigator.push( context, MaterialPageRoute( builder: (context) => GoogleDone(user, _googleSignIn))); } String emailText = 'Email doesn\'t match'; String passwordText = 'Password doesn\'t match'; @override Widget build(BuildContext context) { return Scaffold( resizeToAvoidBottomInset: false, backgroundColor: Colors.white, body: ModalProgressHUD( inAsyncCall: _showSpinner, color: Colors.blueAccent, child: Stack( children: [ Align( alignment: Alignment.topRight, child: Image.asset('assets/images/background.png'), ), Padding( padding: EdgeInsets.only( top: 60.0, bottom: 20.0, left: 20.0, right: 20.0), child: Column( crossAxisAlignment: CrossAxisAlignment.stretch, mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Text( 'Login', style: TextStyle(fontSize: 50.0), ), Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( 'Welcome back,', style: TextStyle(fontSize: 30.0), ), Text( 'please login', style: TextStyle(fontSize: 30.0), ), Text( 'to your account', style: TextStyle(fontSize: 30.0), ), ], ), Column( children: [ TextField( keyboardType: TextInputType.emailAddress, onChanged: (value) { email = value; }, decoration: InputDecoration( hintText: 'Email', labelText: 'Email', errorText: _wrongEmail ? emailText : null, ), ), SizedBox(height: 20.0), TextField( obscureText: true, keyboardType: TextInputType.visiblePassword, onChanged: (value) { password = value; }, decoration: InputDecoration( hintText: 'Password', labelText: 'Password', errorText: _wrongPassword ? passwordText : null, ), ), SizedBox(height: 10.0), Align( alignment: Alignment.topRight, child: GestureDetector( onTap: () { Navigator.pushNamed(context, ForgotPassword.id); }, child: Text( 'Forgot Password?', style: TextStyle(fontSize: 20.0, color: Colors.blue), ), ), ), ], ), RaisedButton( padding: EdgeInsets.symmetric(vertical: 10.0), color: Color(0xff447def), onPressed: () async { setState(() { _showSpinner = true; }); try { setState(() { _wrongEmail = false; _wrongPassword = false; }); final newUser = await _auth.signInWithEmailAndPassword( email: email, password: password); if (newUser != null) { Navigator.pushNamed(context, Done.id); } } catch (e) { print(e.code); if (e.code == 'ERROR_WRONG_PASSWORD') { setState(() { _wrongPassword = true; }); } else { setState(() { emailText = 'User doesn\'t exist'; passwordText = 'Please check your email'; _wrongPassword = true; _wrongEmail = true; }); } } }, child: Text( 'Login', style: TextStyle(fontSize: 25.0, color: Colors.white), ), ), Row( mainAxisAlignment: MainAxisAlignment.center, children: [ Padding( padding: EdgeInsets.symmetric(horizontal: 10.0), child: Container( height: 1.0, width: 60.0, color: Colors.black87, ), ), Text( 'Or', style: TextStyle(fontSize: 25.0), ), Padding( padding: EdgeInsets.symmetric(horizontal: 10.0), child: Container( height: 1.0, width: 60.0, color: Colors.black87, ), ), ], ), Row( children: [ Expanded( child: RaisedButton( padding: EdgeInsets.symmetric(vertical: 5.0), color: Colors.white, shape: ContinuousRectangleBorder( side: BorderSide(width: 0.5, color: Colors.grey[400]), ), onPressed: () { onGoogleSignIn(context); }, child: Row( mainAxisAlignment: MainAxisAlignment.center, children: [ Image.asset('assets/images/google.png', fit: BoxFit.contain, width: 40.0, height: 40.0), Text( 'Google', style: TextStyle( fontSize: 25.0, color: Colors.black), ), ], ), ), ), SizedBox(width: 20.0), Expanded( child: RaisedButton( padding: EdgeInsets.symmetric(vertical: 5.0), color: Colors.white, shape: ContinuousRectangleBorder( side: BorderSide(width: 0.5, color: Colors.grey[400]), ), onPressed: () { //TODO: Implement facebook functionality }, child: Row( mainAxisAlignment: MainAxisAlignment.center, children: [ Image.asset('assets/images/facebook.png', fit: BoxFit.cover, width: 40.0, height: 40.0), Text( 'Facebook', style: TextStyle( fontSize: 25.0, color: Colors.black), ), ], ), ), ), ], ), Row( mainAxisAlignment: MainAxisAlignment.center, children: [ Text( 'Don\'t have an account?', style: TextStyle(fontSize: 25.0), ), GestureDetector( onTap: () { Navigator.pushNamed(context, RegisterPage.id); }, child: Text( ' Sign Up', style: TextStyle(fontSize: 25.0, color: Colors.blue), ), ), ], ), ], ), ), ], ), ), ); } }
0
mirrored_repositories/Login-Register-FlutterApp/lib
mirrored_repositories/Login-Register-FlutterApp/lib/main_screens/RegisterPage.dart
import 'package:flutter/material.dart'; import 'package:task/results_screen/Done.dart'; import 'package:task/results_screen/GoogleDone.dart'; import 'package:task/main_screens/LoginPage.dart'; import 'package:firebase_auth/firebase_auth.dart'; import 'package:google_sign_in/google_sign_in.dart'; import 'package:modal_progress_hud/modal_progress_hud.dart'; import 'package:validators/validators.dart' as validator; // ignore: must_be_immutable class RegisterPage extends StatefulWidget { static String id = '/RegisterPage'; @override _RegisterPageState createState() => _RegisterPageState(); } class _RegisterPageState extends State<RegisterPage> { String name; String email; String password; bool _showSpinner = false; bool _wrongEmail = false; bool _wrongPassword = false; String _emailText = 'Please use a valid email'; String _passwordText = 'Please use a strong password'; final GoogleSignIn _googleSignIn = GoogleSignIn(); final FirebaseAuth _auth = FirebaseAuth.instance; Future<FirebaseUser> _handleSignIn() async { // hold the instance of the authenticated user FirebaseUser user; // flag to check whether we're signed in already bool isSignedIn = await _googleSignIn.isSignedIn(); if (isSignedIn) { // if so, return the current user user = await _auth.currentUser(); } else { final GoogleSignInAccount googleUser = await _googleSignIn.signIn(); final GoogleSignInAuthentication googleAuth = await googleUser.authentication; // get the credentials to (access / id token) // to sign in via Firebase Authentication final AuthCredential credential = GoogleAuthProvider.getCredential( accessToken: googleAuth.accessToken, idToken: googleAuth.idToken); user = (await _auth.signInWithCredential(credential)).user; } return user; } void onGoogleSignIn(BuildContext context) async { FirebaseUser user = await _handleSignIn(); Navigator.push( context, MaterialPageRoute( builder: (context) => GoogleDone(user, _googleSignIn))); } @override Widget build(BuildContext context) { return Scaffold( backgroundColor: Colors.white, resizeToAvoidBottomInset: false, body: ModalProgressHUD( inAsyncCall: _showSpinner, color: Colors.blueAccent, child: Stack( children: [ Align( alignment: Alignment.topRight, child: Image.asset('assets/images/background.png'), ), Padding( padding: EdgeInsets.only( top: 60.0, bottom: 20.0, left: 20.0, right: 20.0), child: Column( crossAxisAlignment: CrossAxisAlignment.stretch, mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Text( 'Register', style: TextStyle(fontSize: 50.0), ), Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( 'Lets get', style: TextStyle(fontSize: 30.0), ), Text( 'you on board', style: TextStyle(fontSize: 30.0), ), ], ), Column( children: [ TextField( keyboardType: TextInputType.name, onChanged: (value) { name = value; }, decoration: InputDecoration( hintText: 'Full Name', labelText: 'Full Name', ), ), SizedBox(height: 20.0), TextField( keyboardType: TextInputType.emailAddress, onChanged: (value) { email = value; }, decoration: InputDecoration( labelText: 'Email', errorText: _wrongEmail ? _emailText : null, ), ), SizedBox(height: 20.0), TextField( obscureText: true, keyboardType: TextInputType.visiblePassword, onChanged: (value) { password = value; }, decoration: InputDecoration( labelText: 'Password', errorText: _wrongPassword ? _passwordText : null, ), ), SizedBox(height: 10.0), ], ), RaisedButton( padding: EdgeInsets.symmetric(vertical: 10.0), color: Color(0xff447def), onPressed: () async { setState(() { _wrongEmail = false; _wrongPassword = false; }); try { if (validator.isEmail(email) & validator.isLength(password, 6)) { setState(() { _showSpinner = true; }); final newUser = await _auth.createUserWithEmailAndPassword( email: email, password: password, ); if (newUser != null) { print('user authenticated by registration'); Navigator.pushNamed(context, Done.id); } } setState(() { if (!validator.isEmail(email)) { _wrongEmail = true; } else if (!validator.isLength(password, 6)) { _wrongPassword = true; } else { _wrongEmail = true; _wrongPassword = true; } }); } catch (e) { setState(() { _wrongEmail = true; if (e.code == 'ERROR_EMAIL_ALREADY_IN_USE') { _emailText = 'The email address is already in use by another account'; } }); } }, child: Text( 'Register', style: TextStyle(fontSize: 25.0, color: Colors.white), ), ), Row( mainAxisAlignment: MainAxisAlignment.center, children: [ Padding( padding: EdgeInsets.symmetric(horizontal: 10.0), child: Container( height: 1.0, width: 60.0, color: Colors.black87, ), ), Text( 'Or', style: TextStyle(fontSize: 25.0), ), Padding( padding: EdgeInsets.symmetric(horizontal: 10.0), child: Container( height: 1.0, width: 60.0, color: Colors.black87, ), ), ], ), Row( children: [ Expanded( child: RaisedButton( padding: EdgeInsets.symmetric(vertical: 5.0), color: Colors.white, shape: ContinuousRectangleBorder( side: BorderSide(width: 0.5, color: Colors.grey[400]), ), onPressed: () { onGoogleSignIn(context); }, child: Row( mainAxisAlignment: MainAxisAlignment.center, children: [ Image.asset('assets/images/google.png', fit: BoxFit.contain, width: 40.0, height: 40.0), Text( 'Google', style: TextStyle( fontSize: 25.0, color: Colors.black), ), ], ), ), ), SizedBox(width: 20.0), Expanded( child: RaisedButton( padding: EdgeInsets.symmetric(vertical: 5.0), color: Colors.white, shape: ContinuousRectangleBorder( side: BorderSide(width: 0.5, color: Colors.grey[400]), ), onPressed: () { //TODO: Implement facebook functionality }, child: Row( mainAxisAlignment: MainAxisAlignment.center, children: [ Image.asset('assets/images/facebook.png', fit: BoxFit.cover, width: 40.0, height: 40.0), Text( 'Facebook', style: TextStyle( fontSize: 25.0, color: Colors.black), ), ], ), ), ), ], ), Row( mainAxisAlignment: MainAxisAlignment.center, children: [ Text( 'Already have an account?', style: TextStyle(fontSize: 25.0), ), GestureDetector( onTap: () { Navigator.pushNamed(context, LoginPage.id); }, child: Text( ' Sign In', style: TextStyle(fontSize: 25.0, color: Colors.blue), ), ), ], ), ], ), ), ], ), ), ); } }
0
mirrored_repositories/Login-Register-FlutterApp
mirrored_repositories/Login-Register-FlutterApp/test/widget_test.dart
// This is a basic Flutter widget test. // // To perform an interaction with a widget in your test, use the WidgetTester // utility that Flutter provides. For example, you can send tap and scroll // gestures. You can also use WidgetTester to find child widgets in the widget // tree, read text, and verify that the values of widget properties are correct. import 'package:flutter/material.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:task/main.dart'; void main() { testWidgets('Counter increments smoke test', (WidgetTester tester) async { // Build our app and trigger a frame. await tester.pumpWidget(Home()); // Verify that our counter starts at 0. expect(find.text('0'), findsOneWidget); expect(find.text('1'), findsNothing); // Tap the '+' icon and trigger a frame. await tester.tap(find.byIcon(Icons.add)); await tester.pump(); // Verify that our counter has incremented. expect(find.text('0'), findsNothing); expect(find.text('1'), findsOneWidget); }); }
0
mirrored_repositories/Flutter_lifecycle
mirrored_repositories/Flutter_lifecycle/lib/main.dart
import 'package:flutter/material.dart'; import 'package:two_you_friend/pages/test_stateful_widget.dart'; /// APP 核心入口文件 void main() => runApp(MyApp()); /// MyApp 核心入口界面 class MyApp extends StatelessWidget { // This widget is the root of your application. @override Widget build(BuildContext context) { return MaterialApp( title: 'Two You', // APP 名字 debugShowCheckedModeBanner: false, theme: ThemeData( primarySwatch: Colors.blue, // APP 主题 ), home: Scaffold( appBar: AppBar( title: Text('Two You'), // 页面名字 ), body: Center( child: TestStatefulWidget(), ) )); } }
0
mirrored_repositories/Flutter_lifecycle
mirrored_repositories/Flutter_lifecycle/lib/logutil.dart
import 'package:flutter/services.dart'; class LogUtil { static const String _tag = "LogUtil"; static const _perform = const MethodChannel("flutter_android_log"); static void d(String message) { _perform.invokeMethod("logD", {'tag': _tag, 'msg': message}); } static void e(String message) { // ignore: file_names _perform.invokeMethod("logE", {'tag': _tag, 'msg': message}); } }
0
mirrored_repositories/Flutter_lifecycle/lib
mirrored_repositories/Flutter_lifecycle/lib/pages/test_stateful_widget.dart
import 'package:flutter/material.dart'; import 'package:two_you_friend/logutil.dart'; import 'package:two_you_friend/pages/sub_stateful_widget.dart'; /// 创建有状态测试组件 class TestStatefulWidget extends StatefulWidget { @override createState() { LogUtil.e("createState"); return TestState(); } } /// 创建状态管理类,继承状态测试组件 class TestState extends State<TestStatefulWidget> { /// 定义 state [count] 计算器 int count; /// 定义 state [name] 为当前描述字符串 String name; @override initState() { LogUtil.e('init state'); super.initState(); setState(() { count = 1; name = 'test'; }); } @override didChangeDependencies() { LogUtil.e('did change dependencies'); super.didChangeDependencies(); } @override didUpdateWidget(TestStatefulWidget oldWidget) { count++; LogUtil.e('did update widget'); super.didUpdateWidget(oldWidget); } @override deactivate() { LogUtil.e('deactivate'); super.deactivate(); } @override dispose() { LogUtil.e('dispose'); super.dispose(); } @override reassemble() { LogUtil.e('reassemble'); super.reassemble(); } /// 修改 state name void changeName() { setState(() { LogUtil.e('set state'); this.name = 'flutter'; }); } @override Widget build(BuildContext context) { LogUtil.e('build'); return Column( children: <Widget>[ FlatButton( child: Text('$name $count'), // 使用 Text 组件显示描述字符和当前计算 onPressed: () => this.changeName(), // 点击触发修改描述字符 state name ), //SubStatefulWidget() ], ); } }
0
mirrored_repositories/Flutter_lifecycle/lib
mirrored_repositories/Flutter_lifecycle/lib/pages/sub_stateful_widget.dart
import 'package:flutter/material.dart'; import '../logutil.dart'; /// 创建子组件类 class SubStatefulWidget extends StatefulWidget { @override createState() { LogUtil.e('sub create state'); return SubState(); } } class SubState extends State<SubStatefulWidget> { String name = 'sub test'; @override Widget build(BuildContext context) { LogUtil.e('sub build'); return Text('subname $name'); // 使用Text组件显示当前name state } @override void initState() { LogUtil.e('sub init state'); super.initState(); } @override void didChangeDependencies() { LogUtil.e('sub did change dependencies'); super.didChangeDependencies(); } @override void dispose() { LogUtil.e('sub dispose'); super.dispose(); } @override void deactivate() { LogUtil.e('sub deactivate'); super.deactivate(); } @override void setState(VoidCallback fn) { LogUtil.e('sub setState'); } @override void reassemble() { LogUtil.e('sub reassemble'); super.reassemble(); } @override void didUpdateWidget(SubStatefulWidget oldWidget) { LogUtil.e('sub did update widget'); super.didUpdateWidget(oldWidget); } }
0
mirrored_repositories/Flutter_lifecycle
mirrored_repositories/Flutter_lifecycle/test/widget_test.dart
// This is a basic Flutter widget test. // // To perform an interaction with a widget in your test, use the WidgetTester // utility that Flutter provides. For example, you can send tap and scroll // gestures. You can also use WidgetTester to find child widgets in the widget // tree, read text, and verify that the values of widget properties are correct. import 'package:flutter/material.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:two_you_friend/main.dart'; void main() { testWidgets('Counter increments smoke test', (WidgetTester tester) async { // Build our app and trigger a frame. await tester.pumpWidget(MyApp()); // Verify that our counter starts at 0. expect(find.text('0'), findsOneWidget); expect(find.text('1'), findsNothing); // Tap the '+' icon and trigger a frame. await tester.tap(find.byIcon(Icons.add)); await tester.pump(); // Verify that our counter has incremented. expect(find.text('0'), findsNothing); expect(find.text('1'), findsOneWidget); }); }
0
mirrored_repositories/flutter-nbytebank
mirrored_repositories/flutter-nbytebank/lib/main.dart
import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; import 'models/saldo.model.dart'; import 'models/transferencias.model.dart'; import 'pages/dashboard/dashboard.page.dart'; void main() { runApp(MultiProvider( providers: [ ChangeNotifierProvider(create: (context) => SaldoModel(0)), ChangeNotifierProvider(create: (context) => TransferenciasModel()), ], child: const MyApp(), )); } class MyApp extends StatelessWidget { const MyApp({super.key}); // This widget is the root of your application. @override Widget build(BuildContext context) { return MaterialApp( title: 'New ByteBank', theme: ThemeData( // primaryColor: Colors.green[900], // accentColor: Colors.blueAccent[700], // buttonTheme: ButtonThemeData( // buttonColor: Colors.blueAccent[700], // textTheme: ButtonTextTheme.primary, // ), primarySwatch: Colors.green, ), home: const DashboardPage(), ); } }
0
mirrored_repositories/flutter-nbytebank/lib/pages
mirrored_repositories/flutter-nbytebank/lib/pages/dashboard/saldo_card.dart
import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; import '../../models/saldo.model.dart'; class SaldoCard extends StatelessWidget { const SaldoCard({super.key}); @override Widget build(BuildContext context) { return Card( child: Padding( padding: const EdgeInsets.all(20), child: Consumer<SaldoModel>( builder: (context, model, child) { return Text( model.toString(), textAlign: TextAlign.center, style: const TextStyle(fontSize: 40, fontWeight: FontWeight.bold), ); }, ), ), ); } }
0
mirrored_repositories/flutter-nbytebank/lib/pages
mirrored_repositories/flutter-nbytebank/lib/pages/dashboard/dashboard.page.dart
import 'package:flutter/material.dart'; import '../dashboard/saldo_card.dart'; import '../deposito/deposito_form.page.dart'; import '../transferencia/transferencia_form.page.dart'; import '../transferencia/ultimas_transferencias.dart'; class DashboardPage extends StatelessWidget { const DashboardPage({super.key}); @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( title: const Text('New Bytebank'), ), body: Padding( padding: EdgeInsets.all(18), child: ListView(children: [ const Align( alignment: Alignment.topCenter, child: SaldoCard(), ), ButtonBar( alignment: MainAxisAlignment.center, children: [ ElevatedButton( child: const Text('Creditar'), onPressed: () => Navigator.of(context).push( MaterialPageRoute( builder: (context) => DepositoFormPage(), ), ), ), ElevatedButton( child: const Text('Transferência'), onPressed: () => Navigator.of(context).push( MaterialPageRoute( builder: (context) => TransferenciaFormPage(), ), ), ), ], ), UltimasTransferencias(), ]), )); } }
0
mirrored_repositories/flutter-nbytebank/lib/pages
mirrored_repositories/flutter-nbytebank/lib/pages/deposito/deposito_form.page.dart
import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; import '../../components/editor.dart'; import '../../models/saldo.model.dart'; const _title = 'Efetuar depósito'; const _dicaCampoValor = '0.00'; const _rotuloCampoValor = 'Valor'; const _textoBotaoConfirmar = 'Depositar'; class DepositoFormPage extends StatelessWidget { final _controladorCampoValor = TextEditingController(); DepositoFormPage({super.key}); @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( title: const Text(_title), ), body: SingleChildScrollView( child: Column( children: [ Editor( _controladorCampoValor, dica: _dicaCampoValor, rotulo: _rotuloCampoValor, icone: Icons.monetization_on, ), ElevatedButton( child: const Text(_textoBotaoConfirmar), onPressed: () => _depositarSaldo(context), ), ], ), )); } void _depositarSaldo(BuildContext context) { final saldo = double.tryParse(_controladorCampoValor.text); if (saldo != null) { _atualizaState(context, saldo); Navigator.pop(context, saldo); } } void _atualizaState(BuildContext context, double valor) { // Dessa forma, esse componente não é atualizado a cada // mudança do estado, utilizando apenas um método da classe. Provider.of<SaldoModel>(context, listen: false).creditar(valor); } }
0
mirrored_repositories/flutter-nbytebank/lib/pages
mirrored_repositories/flutter-nbytebank/lib/pages/transferencia/ultimas_transferencias.dart
import 'dart:math' as math; import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; import '../../models/transferencias.model.dart'; import '../../pages/transferencia/transferencia_lista.page.dart'; class UltimasTransferencias extends StatelessWidget { const UltimasTransferencias({super.key}); @override Widget build(BuildContext context) { return Column(children: [ const Text( "Últimas Transferências", style: TextStyle( fontSize: 16, fontWeight: FontWeight.bold, ), ), Consumer<TransferenciasModel>( builder: (context, model, child) { final transferencias = model.transferencias.reversed.toList(); final int iCount = math.min(2, transferencias.length); if (iCount == 0) { return const SemTransferencias(); } return ListView.builder( padding: const EdgeInsets.all(8), itemCount: iCount, shrinkWrap: true, itemBuilder: (context, index) { return ItemTransferencia(transferencias[index]); }, ); }, ), ElevatedButton( child: const Text('Lista de Transferências'), onPressed: () => Navigator.of(context).push( MaterialPageRoute( builder: (context) => const TransferenciaListaPage(), ), ), ), ]); } } class SemTransferencias extends StatelessWidget { const SemTransferencias({Key? key}) : super(key: key); @override Widget build(BuildContext context) { return const Card( margin: EdgeInsets.all(40), child: Padding( padding: EdgeInsets.all(8), child: Text( 'Nenhuma transferência realizada... 😊', textAlign: TextAlign.center, ), )); } }
0
mirrored_repositories/flutter-nbytebank/lib/pages
mirrored_repositories/flutter-nbytebank/lib/pages/transferencia/transferencia_lista.page.dart
import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; import '../../models/transferencia.model.dart'; import '../../models/transferencias.model.dart'; import '../../pages/transferencia/transferencia_form.page.dart'; const _tituloAppBar = 'Transferências'; class TransferenciaListaPage extends StatelessWidget { const TransferenciaListaPage({super.key}); @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( title: const Text(_tituloAppBar), ), body: Consumer<TransferenciasModel>(builder: (context, model, child) { return ListView.builder( itemCount: model.transferencias.length, itemBuilder: (context, indice) { final transferencia = model.transferencias[indice]; return ItemTransferencia(transferencia); }, ); }), floatingActionButton: FloatingActionButton( child: const Icon(Icons.add), onPressed: () { Navigator.push(context, MaterialPageRoute(builder: (context) { return TransferenciaFormPage(); })); }, ), ); } } class ItemTransferencia extends StatelessWidget { final TransferenciaModel _transferencia; const ItemTransferencia(this._transferencia, {Key? key}) : super(key: key); @override Widget build(BuildContext context) { return Card( child: ListTile( leading: const Icon(Icons.monetization_on), title: Text(_transferencia.toStringValor()), subtitle: Text(_transferencia.toStringConta()), ), ); } }
0
mirrored_repositories/flutter-nbytebank/lib/pages
mirrored_repositories/flutter-nbytebank/lib/pages/transferencia/transferencia_form.page.dart
import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; import '../../components/editor.dart'; import '../../models/saldo.model.dart'; import '../../models/transferencia.model.dart'; import '../../models/transferencias.model.dart'; const _tituloAppBar = 'Criando Transferência'; const _rotuloCampoValor = 'Valor'; const _dicaCampoValor = '0.00'; const _rotuloCampoNumeroConta = 'Número da conta'; const _dicaCampoNumeroConta = '0000'; const _textoBotaoConfirmar = 'Confirmar'; class TransferenciaFormPage extends StatelessWidget { final _controladorCampoNumeroConta = TextEditingController(); final _controladorCampoValor = TextEditingController(); TransferenciaFormPage({super.key}); @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( title: const Text(_tituloAppBar), ), body: SingleChildScrollView( child: Column( children: <Widget>[ Editor( _controladorCampoNumeroConta, dica: _dicaCampoNumeroConta, rotulo: _rotuloCampoNumeroConta, ), Editor( _controladorCampoValor, dica: _dicaCampoValor, rotulo: _rotuloCampoValor, icone: Icons.monetization_on, ), ElevatedButton( child: const Text(_textoBotaoConfirmar), onPressed: () => _criaTransferencia(context), ), ], ), )); } void _criaTransferencia(BuildContext context) { final numeroConta = int.tryParse(_controladorCampoNumeroConta.text); final valor = double.tryParse(_controladorCampoValor.text); if (_validaTransferencia(context, numeroConta, valor)) { final transferencia = TransferenciaModel(valor!, numeroConta!); _atualizaState(context, transferencia); Navigator.pop(context, transferencia); } } bool _validaTransferencia( BuildContext context, int? numeroConta, double? valor, ) { return numeroConta != null && valor != null && Provider.of<SaldoModel>(context, listen: false).valor >= valor; } void _atualizaState(BuildContext context, TransferenciaModel transferencia) { Provider.of<SaldoModel>(context, listen: false).sacar(transferencia.valor); Provider.of<TransferenciasModel>(context, listen: false).add(transferencia); } }
0
mirrored_repositories/flutter-nbytebank/lib
mirrored_repositories/flutter-nbytebank/lib/components/editor.dart
import 'package:flutter/material.dart'; class Editor extends StatelessWidget { final TextEditingController controlador; final String? rotulo; final String? dica; final IconData? icone; const Editor(this.controlador, {super.key, this.rotulo, this.dica, this.icone}); @override Widget build(BuildContext context) { return Padding( padding: const EdgeInsets.all(16.0), child: TextField( controller: controlador, style: const TextStyle(fontSize: 24.0), decoration: InputDecoration( icon: icone != null ? Icon(icone) : null, labelText: rotulo, hintText: dica, ), keyboardType: TextInputType.number, ), ); } }
0
mirrored_repositories/flutter-nbytebank/lib
mirrored_repositories/flutter-nbytebank/lib/models/transferencia.model.dart
class TransferenciaModel { final double valor; final int numeroConta; TransferenciaModel( this.valor, this.numeroConta, ); @override String toString() { return 'Transferencia{valor: $valor, numeroConta: $numeroConta}'; } String toStringValor() { return 'R\$ ${valor.toStringAsFixed(2)}'; } String toStringConta() { return 'Conta $numeroConta'; } }
0
mirrored_repositories/flutter-nbytebank/lib
mirrored_repositories/flutter-nbytebank/lib/models/transferencias.model.dart
import 'package:flutter/cupertino.dart'; import 'transferencia.model.dart'; class TransferenciasModel extends ChangeNotifier { final List<TransferenciaModel> _transferencias = []; get transferencias => _transferencias; void add(TransferenciaModel transferencia) { _transferencias.add(transferencia); notifyListeners(); } }
0
mirrored_repositories/flutter-nbytebank/lib
mirrored_repositories/flutter-nbytebank/lib/models/saldo.model.dart
import 'package:flutter/material.dart'; class SaldoModel extends ChangeNotifier{ double valor; SaldoModel( this.valor, ); @override String toString() => 'R\$ $valor'; @override bool operator ==(Object other) { if (identical(this, other)) return true; return other is SaldoModel && other.valor == valor; } @override int get hashCode => valor.hashCode; void creditar(double valor){ this.valor += valor; notifyListeners(); } void sacar(double valor){ this.valor -= valor; notifyListeners(); } }
0
mirrored_repositories/flutter-nbytebank
mirrored_repositories/flutter-nbytebank/test/widget_test.dart
// This is a basic Flutter widget test. // // To perform an interaction with a widget in your test, use the WidgetTester // utility that Flutter provides. For example, you can send tap and scroll // gestures. You can also use WidgetTester to find child widgets in the widget // tree, read text, and verify that the values of widget properties are correct. import 'package:flutter/material.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:nbytebank/main.dart'; void main() { testWidgets('Counter increments smoke test', (WidgetTester tester) async { // Build our app and trigger a frame. await tester.pumpWidget(const MyApp()); // Verify that our counter starts at 0. expect(find.text('0'), findsOneWidget); expect(find.text('1'), findsNothing); // Tap the '+' icon and trigger a frame. await tester.tap(find.byIcon(Icons.add)); await tester.pump(); // Verify that our counter has incremented. expect(find.text('0'), findsNothing); expect(find.text('1'), findsOneWidget); }); }
0
mirrored_repositories/flutter_firebase_phone_auth
mirrored_repositories/flutter_firebase_phone_auth/lib/page_home.dart
import 'package:firebase_auth/firebase_auth.dart'; import 'package:flutter/material.dart'; import 'page_phone_auth.dart'; class HomePage extends StatefulWidget { @override _HomePageState createState() => _HomePageState(); } class _HomePageState extends State<HomePage> { _signOut() async { await FirebaseAuth.instance.signOut(); Navigator.pushReplacement( context, MaterialPageRoute(builder: (context) => PhoneAuthPage())); } @override Widget build(BuildContext context) { return SafeArea( child: Scaffold( body: Center( child: Column( crossAxisAlignment: CrossAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.center, children: [ Image.asset( 'assets/images/logo_radius.png', height: 100, width: 100, ), const SizedBox( height: 30.0, ), const Text( "Flutter Firebase Phone Auth", style: TextStyle(fontWeight: FontWeight.bold, fontSize: 22.0), ), const SizedBox( height: 30.0, ), const Text( "Welcome", style: TextStyle(fontSize: 22.0), ), const SizedBox( height: 40.0, ), ElevatedButton( onPressed: () => _signOut, child: const Text("Sign Out")) ], ), ), )); } }
0
mirrored_repositories/flutter_firebase_phone_auth
mirrored_repositories/flutter_firebase_phone_auth/lib/page_phone_auth.dart
import 'package:firebase_auth/firebase_auth.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:flutter_firebase_phone_auth/page_home.dart'; enum PhoneVerificationState { SHOW_PHONE_FORM_STATE, SHOW_OTP_FORM_STATE } class PhoneAuthPage extends StatefulWidget { @override _PhoneAuthPageState createState() => _PhoneAuthPageState(); } class _PhoneAuthPageState extends State<PhoneAuthPage> { final GlobalKey<ScaffoldState> _scaffoldKeyForSnackBar = GlobalKey(); PhoneVerificationState currentState = PhoneVerificationState.SHOW_PHONE_FORM_STATE; final phoneController = TextEditingController(); final otpController = TextEditingController(); String verificationIDFromFirebase; bool spinnerLoading = false; FirebaseAuth _firebaseAuth = FirebaseAuth.instance; _verifyPhoneButton() async { print('Phone Number: ${phoneController.text}'); setState(() { spinnerLoading = true; }); await _firebaseAuth.verifyPhoneNumber( phoneNumber: phoneController.text, verificationCompleted: (phoneAuthCredential) async { setState(() { spinnerLoading = false; }); //TODO: Auto Complete Function //signInWithPhoneAuthCredential(phoneAuthCredential); }, verificationFailed: (verificationFailed) async { setState(() { spinnerLoading = true; }); _scaffoldKeyForSnackBar.currentState.showSnackBar(SnackBar( content: Text( "Verification Code Failed: ${verificationFailed.message}"))); }, codeSent: (verificationId, resendingToken) async { setState(() { spinnerLoading = false; currentState = PhoneVerificationState.SHOW_OTP_FORM_STATE; this.verificationIDFromFirebase = verificationId; }); }, codeAutoRetrievalTimeout: (verificationId) async {}); } _verifyOTPButton() async { PhoneAuthCredential phoneAuthCredential = PhoneAuthProvider.credential( verificationId: verificationIDFromFirebase, smsCode: otpController.text); signInWithPhoneAuthCredential(phoneAuthCredential); } void signInWithPhoneAuthCredential( PhoneAuthCredential phoneAuthCredential) async { setState(() { spinnerLoading = true; }); try { final authCredential = await _firebaseAuth.signInWithCredential(phoneAuthCredential); setState(() { spinnerLoading = false; }); if (authCredential?.user != null) { Navigator.push( context, MaterialPageRoute(builder: (context) => HomePage())); } } on FirebaseAuthException catch (e) { setState(() { spinnerLoading = false; }); _scaffoldKeyForSnackBar.currentState .showSnackBar(SnackBar(content: Text(e.message.toString()))); } } getPhoneFormWidget(context) { return Column( children: [ const Text( "Enter authentication phone number\nUse country code (eg: +94712345678)", style: const TextStyle(fontSize: 16.0), ), const SizedBox( height: 40.0, ), TextField( keyboardType: TextInputType.phone, maxLength: 12, //inputFormatters: [FilteringTextInputFormatter.digitsOnly], controller: phoneController, textAlign: TextAlign.start, decoration: const InputDecoration( hintText: "Phone Number", prefixIcon: Icon(Icons.phone_android_rounded)), ), const SizedBox( height: 20.0, ), ElevatedButton( onPressed: () => _verifyPhoneButton(), style: ElevatedButton.styleFrom( primary: Colors.grey.shade900, // background onPrimary: Colors.white, // foreground ), child: const Text("Verify Phone Number")), ], ); } getOTPFormWidget(context) { return Column( children: [ const Text( "Enter OTP Number", style: const TextStyle(fontSize: 16.0), ), const SizedBox( height: 40.0, ), TextField( controller: otpController, textAlign: TextAlign.start, decoration: const InputDecoration( hintText: "OTP Number", prefixIcon: Icon(Icons.confirmation_number_rounded)), ), const SizedBox( height: 20.0, ), ElevatedButton( onPressed: () => _verifyOTPButton(), style: ElevatedButton.styleFrom( primary: Colors.grey.shade900, // background onPrimary: Colors.white, // foreground ), child: const Text("Verify OTP Number"), ), ], ); } @override Widget build(BuildContext context) { return SafeArea( child: Scaffold( key: _scaffoldKeyForSnackBar, body: SingleChildScrollView( child: Padding( padding: const EdgeInsets.all(20.0), child: Column( mainAxisAlignment: MainAxisAlignment.center, children: [ const SizedBox( height: 20.0, ), Column( children: [ Image.asset( 'assets/images/logo_radius.png', height: 60, width: 60, ), const SizedBox( height: 30.0, ), const Text( "Flutter Firebase Phone Auth", style: TextStyle(fontSize: 22.0, fontWeight: FontWeight.bold), ), const SizedBox( height: 20.0, ), Row( mainAxisAlignment: MainAxisAlignment.spaceEvenly, children: [ Image.asset( 'assets/images/firebase_127px.png', scale: 2, ), Image.asset( 'assets/images/hand_with_phone_127px.png', scale: 2, ), Image.asset( 'assets/images/verified_127px.png', scale: 2, ), ], ), ], ), const SizedBox( height: 40.0, ), spinnerLoading ? const Center( child: CircularProgressIndicator(), ) : currentState == PhoneVerificationState.SHOW_PHONE_FORM_STATE ? getPhoneFormWidget(context) : getOTPFormWidget(context), ], ), ), ), )); } }
0
mirrored_repositories/flutter_firebase_phone_auth
mirrored_repositories/flutter_firebase_phone_auth/lib/main.dart
import 'package:firebase_auth/firebase_auth.dart'; import 'package:firebase_core/firebase_core.dart'; import 'package:flutter/material.dart'; import 'package:flutter_firebase_phone_auth/page_home.dart'; import 'page_phone_auth.dart'; void main() async { WidgetsFlutterBinding.ensureInitialized(); await Firebase.initializeApp(); runApp(MyApp()); } class MyApp extends StatelessWidget { FirebaseAuth firebaseAuth = FirebaseAuth.instance; @override Widget build(BuildContext context) { return MaterialApp( title: 'Flutter Firebase Phone Auth', debugShowCheckedModeBanner: false, theme: ThemeData( primarySwatch: Colors.blue, ), // home: PhoneAuthPage(), // NOTE: This will check if the user is already signed in home: StreamBuilder<User>( stream: firebaseAuth.authStateChanges(), builder: (context, snapshot) { if (snapshot.hasData) { return HomePage(); } return PhoneAuthPage(); }), ); } }
0
mirrored_repositories/flutter_firebase_phone_auth
mirrored_repositories/flutter_firebase_phone_auth/test/widget_test.dart
// This is a basic Flutter widget test. // // To perform an interaction with a widget in your test, use the WidgetTester // utility that Flutter provides. For example, you can send tap and scroll // gestures. You can also use WidgetTester to find child widgets in the widget // tree, read text, and verify that the values of widget properties are correct. import 'package:flutter/material.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:flutter_firebase_phone_auth/main.dart'; void main() { testWidgets('Counter increments smoke test', (WidgetTester tester) async { // Build our app and trigger a frame. await tester.pumpWidget(MyApp()); // Verify that our counter starts at 0. expect(find.text('0'), findsOneWidget); expect(find.text('1'), findsNothing); // Tap the '+' icon and trigger a frame. await tester.tap(find.byIcon(Icons.add)); await tester.pump(); // Verify that our counter has incremented. expect(find.text('0'), findsNothing); expect(find.text('1'), findsOneWidget); }); }
0
mirrored_repositories/flutter-nfc-app
mirrored_repositories/flutter-nfc-app/lib/main.dart
import 'package:flutter/material.dart'; import 'dart:async'; import 'package:flutter/services.dart'; void main() { //runApp(new MyApp()); runApp(new MaterialApp(home: new PlatformChannel())); } class PlatformChannel extends StatefulWidget { @override _PlatformChannelState createState() => new _PlatformChannelState(); } class _PlatformChannelState extends State<PlatformChannel> { static const MethodChannel methodChannel = // const MethodChannel('samples.flutter.io/battery'); const MethodChannel('nfc'); //static const EventChannel eventChannel = //const EventChannel('samples.flutter.io/charging'); String _cardUid = 'card uid unknown.'; String _getVersion1 = 'getVersion1 init'; String _getVersion2 = 'getVersion2 init'; String _getVersion3 = 'getVersion3 init'; String _getVersionAll = 'getVersionAll init'; //String _chargingStatus = 'Battery status: unknown.'; Future<Null> _getCardUID() async { String response; try { // final int result = await methodChannel.invokeMethod('getBatteryLevel'); final String result = await methodChannel.invokeMethod('getCardUID'); if (result != null) { response = 'Get UID: $result'; } else { response = 'Get UID failed'; } } on PlatformException { response = 'Get UID failed, PlatformException'; } setState(() { _cardUid = response; }); } Future<Null> _getVersionMethod(String cmd, int turn) async { String response; try { // final int result = await methodChannel.invokeMethod('getBatteryLevel'); final String result = await methodChannel.invokeMethod('getVersion', <String, dynamic>{ 'commands': cmd, }); if (result != null) { response = 'getVersion: $result'; print(response); } else { response = 'getVersion failed'; } } on PlatformException { response = 'getVersion failed, PlatformException'; } setState(() { if (turn == 1) { _getVersion1 = response; } else if (turn == 2) { _getVersion2 = response; } else if (turn == 3) { _getVersion3 = response; } else if (turn == 4) { _getVersionAll = response; } }); } // @override // void initState() { // super.initState(); // //eventChannel.receiveBroadcastStream().listen(_onEvent, onError: _onError); // } // // void _onEvent(Object event) { // setState(() { // //_chargingStatus = // //"Battery status: ${event == 'charging' ? '' : 'dis'}charging."; // }); // } // // void _onError(Object error) { // setState(() { // //_chargingStatus = 'Battery status: unknown.'; // }); // } String getVersionArray = "9060000000#90AF000000#90AF000000"; @override Widget build(BuildContext context) { return new Material( child: new Column( mainAxisAlignment: MainAxisAlignment.spaceEvenly, children: <Widget>[ new Column( mainAxisAlignment: MainAxisAlignment.center, children: <Widget>[ new Text(_cardUid, key: const Key('get uid label')), new Padding( padding: const EdgeInsets.all(16.0), child: new RaisedButton( child: const Text('get uid'), onPressed: _getCardUID, ), ), new Text(_getVersion1, key: const Key('getversion1 label')), new Padding( padding: const EdgeInsets.all(16.0), child: new RaisedButton( child: const Text('getVersionPart1'), onPressed: () => _getVersionMethod("9060000000", 1), ), ), new Text(_getVersion2, key: const Key('getversion2 label')), new Padding( padding: const EdgeInsets.all(16.0), child: new RaisedButton( child: const Text('getVersionPart2'), onPressed: () => _getVersionMethod("90AF000000", 2), ), ), new Text(_getVersion3, key: const Key('getversion3 label')), new Padding( padding: const EdgeInsets.all(16.0), child: new RaisedButton( child: const Text('getVersionPart3'), onPressed: () => _getVersionMethod("90AF000000", 3), ), ), new Text(_getVersionAll, key: const Key('getversionAll label')), new Padding( padding: const EdgeInsets.all(16.0), child: new RaisedButton( child: const Text('getVersionAll'), onPressed: () => _getVersionMethod(getVersionArray, 4), ), ) ], ), //new Text(_chargingStatus), ], ), ); } }
0
mirrored_repositories/flutter-nfc-app
mirrored_repositories/flutter-nfc-app/test/widget_test.dart
// This is a basic Flutter widget test. // To perform an interaction with a widget in your test, use the WidgetTester utility that Flutter // provides. For example, you can send tap and scroll gestures. You can also use WidgetTester to // find child widgets in the widget tree, read text, and verify that the values of widget properties // are correct. import 'package:flutter/material.dart'; import 'package:flutter_nfc/main.dart'; import 'package:flutter_test/flutter_test.dart'; void main() { testWidgets('Counter increments smoke test', (WidgetTester tester) async { // Build our app and trigger a frame. await tester.pumpWidget(new MyApp()); // Verify that our counter starts at 0. expect(find.text('0'), findsOneWidget); expect(find.text('1'), findsNothing); // Tap the '+' icon and trigger a frame. await tester.tap(find.byIcon(Icons.add)); await tester.pump(); // Verify that our counter has incremented. expect(find.text('0'), findsNothing); expect(find.text('1'), findsOneWidget); }); }
0
mirrored_repositories/Shoes-Shopping-App-In-Flutter
mirrored_repositories/Shoes-Shopping-App-In-Flutter/lib/LoginPage.dart
// ignore_for_file: prefer_const_constructors, unused_import import 'package:firebase_auth/firebase_auth.dart'; import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; import 'package:flutter_firebase/RegisterPage.dart'; // import 'package:flutter_firebase/HomePage.dart'; import 'package:flutter_firebase/pages/home_page.dart'; class LoginPage extends StatefulWidget { @override _LoginPageState createState() => _LoginPageState(); } class _LoginPageState extends State<LoginPage> { final _formKey = GlobalKey<FormState>(); final TextEditingController emailController = TextEditingController(); final TextEditingController passwordController = TextEditingController(); bool passToggle = true; bool isLoad = false; // Sign In Function signInWithEmailAndPassword() async { try { setState(() { isLoad = true; }); final credential = await FirebaseAuth.instance.signInWithEmailAndPassword( email: emailController.text, password: passwordController.text); setState(() { isLoad = false; }); if (credential != null) { Navigator.pushReplacement( context, MaterialPageRoute(builder: (context) => HomePage()), ); } } on FirebaseAuthException catch (e) { setState(() { isLoad = false; }); if (e.code == 'user-not-found') { ScaffoldMessenger.of(context).showSnackBar( SnackBar(content: Text('No user found for that email.'))); } else if (e.code == 'wrong-password') { ScaffoldMessenger.of(context).showSnackBar( SnackBar(content: Text("Wrong password provided for that user."))); } } } @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( title: Center( // Wrap the title text with Center widget child: Text('Login Page'), ), ), body: SingleChildScrollView( child: Padding( padding: const EdgeInsets.all(16.0), child: Form( key: _formKey, child: Column( crossAxisAlignment: CrossAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.center, children: <Widget>[ Text( "Login", style: TextStyle( fontSize: 40, // Set the font size fontWeight: FontWeight.bold, // Set the font weight (optional) color: Colors.indigo, // You can also set other text styles such as color, font family, etc. here. ), ), SizedBox(height: 20.0), TextFormField( controller: emailController, decoration: InputDecoration( labelText: 'Email', border: OutlineInputBorder(), prefixIcon: Icon(Icons.email), ), validator: (value) { // You can add more email validation logic here if needed. bool emailValid = RegExp( r"^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$") .hasMatch(value!); if (value!.isEmpty) { return 'Please enter your email'; } if (!emailValid) { return "Enter Valid Email"; } return null; }, ), SizedBox(height: 16.0), TextFormField( controller: passwordController, obscureText: passToggle, decoration: InputDecoration( labelText: 'Password', border: OutlineInputBorder(), prefixIcon: Icon(Icons.lock), suffixIcon: InkWell( onTap: () { setState(() { passToggle = !passToggle; }); }, child: Icon( passToggle ? Icons.visibility : Icons.visibility_off), ), ), validator: (value) { if (value!.isEmpty) { return 'Please enter a password'; } else if (passwordController.text.length < 4) { return "Password Length Should be more than 4 characters"; } // You can add more password validation logic here if needed. return null; }, ), SizedBox(height: 16.0), ElevatedButton( onPressed: () { if (_formKey.currentState!.validate()) { // call SignIn Function signInWithEmailAndPassword(); } }, child: isLoad ? const Center( child: CircularProgressIndicator( color: Colors.white, ), ) : const Text('Login'), ), Row( mainAxisAlignment: MainAxisAlignment.center, children: [ Text("Don't have an account? ", style: TextStyle( fontSize: 16, )), TextButton( onPressed: () { // Add navigation to the registration page here. Navigator.pushReplacement( context, MaterialPageRoute( builder: (context) => RegisterPage()), ); }, child: Text("SignUp", style: TextStyle( fontSize: 20, fontWeight: FontWeight.bold)), ) ], ), ], ), ), ), ), ); } @override void dispose() { emailController.dispose(); passwordController.dispose(); super.dispose(); } }
0
mirrored_repositories/Shoes-Shopping-App-In-Flutter
mirrored_repositories/Shoes-Shopping-App-In-Flutter/lib/RegisterPage.dart
// ignore_for_file: prefer_const_constructors import 'package:flutter/material.dart'; import 'package:flutter_firebase/LoginPage.dart'; import 'package:firebase_auth/firebase_auth.dart'; class RegisterPage extends StatefulWidget { @override _RegisterPageState createState() => _RegisterPageState(); } class _RegisterPageState extends State<RegisterPage> { final _formKey = GlobalKey<FormState>(); final TextEditingController nameController = TextEditingController(); final TextEditingController emailController = TextEditingController(); final TextEditingController passwordController = TextEditingController(); bool passToggle = true; bool isLoad = false; // SignUp createUserWithEmailAndPassword() async { try { setState(() { isLoad = true; }); final credential = await FirebaseAuth.instance.createUserWithEmailAndPassword( email: emailController.text, password: passwordController.text, ); setState(() { isLoad = false; }); if (credential != null) { Navigator.pushReplacement( context, MaterialPageRoute(builder: (context) => LoginPage()), ); } } on FirebaseAuthException catch (e) { setState(() { isLoad = false; }); if (e.code == 'weak-password') { ScaffoldMessenger.of(context).showSnackBar( SnackBar(content: Text('The password provided is too weak.'))); } else if (e.code == 'email-already-in-use') { ScaffoldMessenger.of(context).showSnackBar(SnackBar( content: Text('The account already exists for that email.'))); } } catch (e) { print(e); } } @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( title: Center( // Wrap the title text with Center widget child: Text('SignUp Page'), ), ), body: SingleChildScrollView( child: Padding( padding: const EdgeInsets.all(16.0), child: Form( key: _formKey, child: Column( crossAxisAlignment: CrossAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.center, children: <Widget>[ Text( "Sign Up", style: TextStyle( fontSize: 40, // Set the font size fontWeight: FontWeight.bold, // Set the font weight (optional) color: Colors.indigo, // You can also set other text styles such as color, font family, etc. here. ), ), SizedBox(height: 20.0), TextFormField( controller: emailController, decoration: InputDecoration( labelText: 'Email', border: OutlineInputBorder(), prefixIcon: Icon(Icons.email), ), validator: (value) { // You can add more email validation logic here if needed. bool emailValid = RegExp( r"^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$") .hasMatch(value!); if (value!.isEmpty) { return 'Please enter your email'; } if (!emailValid) { return "Enter Valid Email"; } return null; }, ), SizedBox(height: 16.0), TextFormField( controller: passwordController, obscureText: passToggle, decoration: InputDecoration( labelText: 'Password', border: OutlineInputBorder(), prefixIcon: Icon(Icons.lock), suffixIcon: InkWell( onTap: () { setState(() { passToggle = !passToggle; }); }, child: Icon( passToggle ? Icons.visibility : Icons.visibility_off), ), ), validator: (value) { if (value!.isEmpty) { return 'Please enter a password'; } else if (passwordController.text.length < 4) { return "Password Length Should be more than 4 characters"; } // You can add more password validation logic here if needed. return null; }, ), SizedBox(height: 16.0), ElevatedButton( onPressed: () { if (_formKey.currentState!.validate()) { // SignUp createUserWithEmailAndPassword(); } }, child: isLoad ? const Center( child: CircularProgressIndicator( color: Colors.white, ), ) : const Text('SignUp'), ), Row( mainAxisAlignment: MainAxisAlignment.center, children: [ Text("Already have an account? ", style: TextStyle( fontSize: 16, )), TextButton( onPressed: () { // Add navigation to the login page here. Navigator.pushReplacement( context, MaterialPageRoute(builder: (context) => LoginPage()), ); }, child: Text("Login", style: TextStyle( fontSize: 20, fontWeight: FontWeight.bold)), ) ], ), ], ), ), ), ), ); } @override void dispose() { nameController.dispose(); emailController.dispose(); passwordController.dispose(); super.dispose(); } }
0
mirrored_repositories/Shoes-Shopping-App-In-Flutter
mirrored_repositories/Shoes-Shopping-App-In-Flutter/lib/AuthRouter.dart
import 'package:flutter/material.dart'; import 'package:flutter_firebase/LoginPage.dart'; import 'package:firebase_auth/firebase_auth.dart'; class AuthRouter extends StatelessWidget { const AuthRouter({Key? key}); @override Widget build(BuildContext context) { return Scaffold( body: StreamBuilder<User?>( stream: FirebaseAuth.instance.authStateChanges(), builder: (BuildContext context, AsyncSnapshot<User?> snapshot) { if (snapshot.connectionState == ConnectionState.waiting) { // Show a loading indicator while checking the authentication state return const CircularProgressIndicator(); } // else { // if (snapshot.hasData) { // // User is logged in, navigate to the home page // } else { // // User is not logged in, navigate to the login page // return HomePage(); // } // } return LoginPage(); }, ), // StreamBuilder ); // Scaffold } }
0
mirrored_repositories/Shoes-Shopping-App-In-Flutter
mirrored_repositories/Shoes-Shopping-App-In-Flutter/lib/global_variables.dart
final products = [ { 'id': '0', 'title': 'Men\'s Nike Shoes', 'price': 14.0, 'imageUrl': 'assets/images/shoes_1.png', 'company': 'Nike', 'sizes': [9, 10, 11, 12], }, { 'id': '1', 'title': 'Addidas Shoes', 'price': 12.0, 'imageUrl': 'assets/images/shoes_2.png', 'company': 'Addidas', 'sizes': [9, 10, 12], }, { 'id': '2', 'title': 'Bata Women\'s Shoes', 'price': 18.0, 'imageUrl': 'assets/images/shoes_3.png', 'company': 'Bata', 'sizes': [8, 9, 10], }, { 'id': '3', 'title': 'Puma Shoes', 'price': 14.5, 'imageUrl': 'assets/images/shoes_4.png', 'company': 'Puma', 'sizes': [8, 9, 10], }, { 'id': '4', 'title': 'Nike Shoes', 'price': 15.5, 'imageUrl': 'assets/images/shoes_5.jpeg', 'company': 'Nike', 'sizes': [9, 10], }, { 'id': '5', 'title': 'Puma Shoes', 'price': 16.5, 'imageUrl': 'assets/images/shoes_6.jpg', 'company': 'Puma', 'sizes': [8, 9], }, ];
0
mirrored_repositories/Shoes-Shopping-App-In-Flutter
mirrored_repositories/Shoes-Shopping-App-In-Flutter/lib/firebase_options.dart
// File generated by FlutterFire CLI. // ignore_for_file: lines_longer_than_80_chars, avoid_classes_with_only_static_members import 'package:firebase_core/firebase_core.dart' show FirebaseOptions; import 'package:flutter/foundation.dart' show defaultTargetPlatform, kIsWeb, TargetPlatform; /// Default [FirebaseOptions] for use with your Firebase apps. /// /// Example: /// ```dart /// import 'firebase_options.dart'; /// // ... /// await Firebase.initializeApp( /// options: DefaultFirebaseOptions.currentPlatform, /// ); /// ``` class DefaultFirebaseOptions { static FirebaseOptions get currentPlatform { if (kIsWeb) { return web; } switch (defaultTargetPlatform) { case TargetPlatform.android: return android; case TargetPlatform.iOS: return ios; case TargetPlatform.macOS: return macos; case TargetPlatform.windows: throw UnsupportedError( 'DefaultFirebaseOptions have not been configured for windows - ' 'you can reconfigure this by running the FlutterFire CLI again.', ); case TargetPlatform.linux: throw UnsupportedError( 'DefaultFirebaseOptions have not been configured for linux - ' 'you can reconfigure this by running the FlutterFire CLI again.', ); default: throw UnsupportedError( 'DefaultFirebaseOptions are not supported for this platform.', ); } } static const FirebaseOptions web = FirebaseOptions( apiKey: 'AIzaSyCJZ1oucejcbT4huymbXYcZv6uLZ7l4JUA', appId: '1:757815644679:web:d021a21037d24700e2d0a2', messagingSenderId: '757815644679', projectId: 'flutter-firebase-29ae0', authDomain: 'flutter-firebase-29ae0.firebaseapp.com', storageBucket: 'flutter-firebase-29ae0.appspot.com', measurementId: 'G-XLCCZ6T36E', ); static const FirebaseOptions android = FirebaseOptions( apiKey: 'AIzaSyB25ldhi8jT_5Q68SaKIG3Q_SZhb1i-Rhs', appId: '1:757815644679:android:33f51c3d43c94541e2d0a2', messagingSenderId: '757815644679', projectId: 'flutter-firebase-29ae0', storageBucket: 'flutter-firebase-29ae0.appspot.com', ); static const FirebaseOptions ios = FirebaseOptions( apiKey: 'AIzaSyChZdK7SxW9mEIh5kTwXJ1jvZIqzDWqjfg', appId: '1:757815644679:ios:5455a5cd52301367e2d0a2', messagingSenderId: '757815644679', projectId: 'flutter-firebase-29ae0', storageBucket: 'flutter-firebase-29ae0.appspot.com', iosBundleId: 'com.example.flutterFirebase', ); static const FirebaseOptions macos = FirebaseOptions( apiKey: 'AIzaSyChZdK7SxW9mEIh5kTwXJ1jvZIqzDWqjfg', appId: '1:757815644679:ios:1ad484b62921978de2d0a2', messagingSenderId: '757815644679', projectId: 'flutter-firebase-29ae0', storageBucket: 'flutter-firebase-29ae0.appspot.com', iosBundleId: 'com.example.flutterFirebase.RunnerTests', ); }
0
mirrored_repositories/Shoes-Shopping-App-In-Flutter
mirrored_repositories/Shoes-Shopping-App-In-Flutter/lib/main.dart
import 'package:flutter/material.dart'; import 'package:firebase_core/firebase_core.dart'; import 'package:flutter_firebase/AuthRouter.dart'; import 'firebase_options.dart'; import 'package:flutter_firebase/providers/cart_provider.dart'; import 'package:provider/provider.dart'; void main() async { // WidgetsFlutterBinding.ensureInitialized(); // firebase await Firebase.initializeApp( options: DefaultFirebaseOptions.currentPlatform, ); runApp(MyApp()); } class MyApp extends StatelessWidget { const MyApp({super.key}); @override Widget build(BuildContext context) { return MultiProvider( providers: [ ChangeNotifierProvider(create: (context) => CartProvider()), ], child: MaterialApp( title: 'Shopping App', theme: ThemeData( fontFamily: 'Lato', colorScheme: ColorScheme.fromSeed( seedColor: const Color.fromRGBO(254, 206, 1, 1), primary: const Color.fromRGBO(254, 206, 1, 1), ), appBarTheme: const AppBarTheme( titleTextStyle: TextStyle( fontSize: 20, color: Colors.black, ), ), inputDecorationTheme: const InputDecorationTheme( hintStyle: TextStyle( fontWeight: FontWeight.bold, fontSize: 16, ), prefixIconColor: Color.fromRGBO(119, 119, 119, 1), ), textTheme: const TextTheme( titleLarge: TextStyle( fontWeight: FontWeight.bold, fontSize: 35, ), titleMedium: TextStyle( fontWeight: FontWeight.bold, fontSize: 20, ), bodySmall: TextStyle( fontWeight: FontWeight.bold, fontSize: 16, ), ), useMaterial3: true, ), home: const AuthRouter(), debugShowCheckedModeBanner: false, ), ); } }
0
mirrored_repositories/Shoes-Shopping-App-In-Flutter/lib
mirrored_repositories/Shoes-Shopping-App-In-Flutter/lib/widgets/product_list.dart
import 'package:flutter/material.dart'; import 'package:flutter_firebase/global_variables.dart'; import 'package:flutter_firebase/widgets/product_card.dart'; import 'package:flutter_firebase/pages/product_details_page.dart'; import 'package:firebase_auth/firebase_auth.dart'; import 'package:flutter_firebase/LoginPage.dart'; class ProductList extends StatefulWidget { const ProductList({super.key}); @override State<ProductList> createState() => _ProductListState(); } class _ProductListState extends State<ProductList> { final List<String> filters = const ['All']; late String selectedFilter; @override void initState() { super.initState(); selectedFilter = filters[0]; } @override Widget build(BuildContext context) { const border = OutlineInputBorder( borderSide: BorderSide( color: Color.fromRGBO(225, 225, 225, 1), ), borderRadius: BorderRadius.horizontal( left: Radius.circular(50), ), ); return SafeArea( child: Column( children: [ Row( children: [ Padding( padding: const EdgeInsets.all(20.0), child: Text( 'Shoes Shop', style: Theme.of(context).textTheme.titleLarge, ), ), ElevatedButton( onPressed: () async { // Logout await FirebaseAuth.instance.signOut(); { Navigator.pushReplacement( context, MaterialPageRoute(builder: (context) => LoginPage()), ); } }, child: Text('Log Out'), ), ], ), SizedBox( height: 120, child: ListView.builder( itemCount: filters.length, scrollDirection: Axis.horizontal, itemBuilder: (context, index) { final filter = filters[index]; return Padding( padding: const EdgeInsets.symmetric( horizontal: 8.0, ), child: GestureDetector( onTap: () { setState(() { selectedFilter = filter; }); }, child: Chip( backgroundColor: selectedFilter == filter ? Theme.of(context).colorScheme.primary : const Color.fromRGBO(245, 247, 249, 1), side: const BorderSide( color: Color.fromRGBO(245, 247, 249, 1), ), label: Text(filter), labelStyle: const TextStyle( fontSize: 16, ), padding: const EdgeInsets.symmetric( horizontal: 20, vertical: 15, ), shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(30), ), ), ), ); }, ), ), Expanded( child: LayoutBuilder( builder: (context, constraints) { if (constraints.maxWidth > 1080) { return GridView.builder( itemCount: products.length, gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount( crossAxisCount: 2, childAspectRatio: 1.75, ), itemBuilder: (context, index) { final product = products[index]; return GestureDetector( onTap: () { Navigator.of(context).push( MaterialPageRoute( builder: (context) { return ProductDetailsPage(product: product); }, ), ); }, child: ProductCard( title: product['itle'] as String, price: product['price'] as double, image: product['imageUrl'] as String, backgroundColor: index.isEven ? const Color.fromRGBO(216, 240, 253, 1) : const Color.fromRGBO(245, 247, 249, 1), ), ); }, ); } else { return ListView.builder( itemCount: products.length, itemBuilder: (context, index) { final product = products[index]; return GestureDetector( onTap: () { Navigator.of(context).push( MaterialPageRoute( builder: (context) { return ProductDetailsPage(product: product); }, ), ); }, child: ProductCard( title: product['title'] as String, price: product['price'] as double, image: product['imageUrl'] as String, backgroundColor: index.isEven ? const Color.fromRGBO(216, 240, 253, 1) : const Color.fromRGBO(245, 247, 249, 1), ), ); }, ); } }, ), ), ], ), ); } }
0
mirrored_repositories/Shoes-Shopping-App-In-Flutter/lib
mirrored_repositories/Shoes-Shopping-App-In-Flutter/lib/widgets/product_card.dart
import 'package:flutter/material.dart'; class ProductCard extends StatelessWidget { final String title; final double price; final String image; final Color backgroundColor; const ProductCard({ super.key, required this.title, required this.price, required this.image, required this.backgroundColor, }); @override Widget build(BuildContext context) { return Container( margin: const EdgeInsets.all(20), padding: const EdgeInsets.all(16.0), decoration: BoxDecoration( color: backgroundColor, borderRadius: BorderRadius.circular(20), ), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( title, style: Theme.of(context).textTheme.titleMedium, ), const SizedBox(height: 5), Text( '\$$price', style: Theme.of(context).textTheme.bodySmall, ), const SizedBox(height: 5), Center( child: Image.asset(image, height: 175), ), ], ), ); } }
0
mirrored_repositories/Shoes-Shopping-App-In-Flutter/lib
mirrored_repositories/Shoes-Shopping-App-In-Flutter/lib/pages/home_page.dart
import 'package:flutter/material.dart'; import 'package:flutter_firebase/pages/cart_page.dart'; import 'package:flutter_firebase/widgets/product_list.dart'; class HomePage extends StatefulWidget { const HomePage({super.key}); @override State<HomePage> createState() => _HomePageState(); } class _HomePageState extends State<HomePage> { int currentPage = 0; List<Widget> pages = const [ProductList(), CartPage()]; @override Widget build(BuildContext context) { return Scaffold( body: IndexedStack( index: currentPage, children: pages, ), bottomNavigationBar: BottomNavigationBar( iconSize: 35, selectedFontSize: 0, unselectedFontSize: 0, onTap: (value) { setState(() { currentPage = value; }); }, currentIndex: currentPage, items: const [ BottomNavigationBarItem( icon: Icon(Icons.home), label: '', ), BottomNavigationBarItem( icon: Icon(Icons.shopping_cart), label: '', ), ], ), ); } }
0
mirrored_repositories/Shoes-Shopping-App-In-Flutter/lib
mirrored_repositories/Shoes-Shopping-App-In-Flutter/lib/pages/product_details_page.dart
import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; import 'package:flutter_firebase/providers/cart_provider.dart'; class ProductDetailsPage extends StatefulWidget { final Map<String, Object> product; const ProductDetailsPage({ super.key, required this.product, }); @override State<ProductDetailsPage> createState() => _ProductDetailsPageState(); } class _ProductDetailsPageState extends State<ProductDetailsPage> { int selectedSize = 0; void onTap() { if (selectedSize != 0) { Provider.of<CartProvider>(context, listen: false).addProduct( { 'id': widget.product['id'], 'title': widget.product['title'], 'price': widget.product['price'], 'imageUrl': widget.product['imageUrl'], 'company': widget.product['company'], 'size': selectedSize, }, ); ScaffoldMessenger.of(context).showSnackBar( const SnackBar( content: Text('Product added successfully!'), ), ); } else { ScaffoldMessenger.of(context).showSnackBar( const SnackBar( content: Text('Please select a size!'), ), ); } } @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( title: const Text('Details'), ), body: Column( children: [ Text( widget.product['title'] as String, style: Theme.of(context).textTheme.titleLarge, ), const Spacer(), Padding( padding: const EdgeInsets.all(16.0), child: Image.asset( widget.product['imageUrl'] as String, height: 250, ), ), const Spacer(flex: 2), Container( height: 250, decoration: BoxDecoration( color: const Color.fromRGBO(245, 247, 249, 1), borderRadius: BorderRadius.circular(40), ), child: Column( mainAxisAlignment: MainAxisAlignment.center, children: [ Text( '\$${widget.product['price']}', style: Theme.of(context).textTheme.titleLarge, ), const SizedBox(height: 10), SizedBox( height: 50, child: ListView.builder( scrollDirection: Axis.horizontal, itemCount: (widget.product['sizes'] as List<int>).length, itemBuilder: (context, index) { final size = (widget.product['sizes'] as List<int>)[index]; return Padding( padding: const EdgeInsets.all(8.0), child: GestureDetector( onTap: () { setState(() { selectedSize = size; }); }, child: Chip( label: Text(size.toString()), backgroundColor: selectedSize == size ? Theme.of(context).colorScheme.primary : null, ), ), ); }, ), ), Padding( padding: const EdgeInsets.all(20.0), child: ElevatedButton( onPressed: onTap, style: ElevatedButton.styleFrom( backgroundColor: Theme.of(context).colorScheme.primary, fixedSize: const Size(350, 50), ), child: const Text( 'Add To Cart', style: TextStyle( color: Colors.black, fontSize: 18, ), ), ), ), ], ), ), ], ), ); } }
0
mirrored_repositories/Shoes-Shopping-App-In-Flutter/lib
mirrored_repositories/Shoes-Shopping-App-In-Flutter/lib/pages/cart_page.dart
import 'package:flutter/material.dart'; import 'package:flutter_firebase/pages/home_page.dart'; import 'package:provider/provider.dart'; import 'package:flutter_firebase/providers/cart_provider.dart'; class CartPage extends StatelessWidget { const CartPage({super.key}); @override Widget build(BuildContext context) { final cart = context.watch<CartProvider>().cart; return Scaffold( appBar: AppBar( title: const Text('Cart'), ), body: ListView.builder( itemCount: cart.length, itemBuilder: (context, index) { final cartItem = cart[index]; return ListTile( leading: CircleAvatar( backgroundImage: AssetImage(cartItem['imageUrl'] as String), radius: 30, ), trailing: IconButton( onPressed: () { showDialog( context: context, builder: (context) { return AlertDialog( title: Text( 'Delete Product', style: Theme.of(context).textTheme.titleMedium, ), content: const Text( 'Are you sure you want to remove the product from your cart?', ), actions: [ TextButton( onPressed: () { Navigator.of(context).pop(); }, child: const Text( 'No', style: TextStyle( color: Colors.blue, fontWeight: FontWeight.bold, ), ), ), TextButton( onPressed: () { context .read<CartProvider>() .removeProduct(cartItem); Navigator.of(context).pop(); }, child: const Text( 'Yes', style: TextStyle( color: Colors.red, fontWeight: FontWeight.bold, ), ), ), ], ); }, ); }, icon: const Icon( Icons.delete, color: Colors.red, ), ), title: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( cartItem['title'].toString(), style: Theme.of(context).textTheme.bodySmall, ), Text( 'Price: ${cartItem['price']}', style: Theme.of(context).textTheme.bodySmall, ), ], ), subtitle: Text('Size: ${cartItem['size']}'), ); }, ), bottomNavigationBar: ElevatedButton( onPressed: () { ScaffoldMessenger.of(context).showSnackBar( SnackBar( content: Text('Your order has been placed.'), ), ); Navigator.pushReplacement( context, MaterialPageRoute(builder: (context) => HomePage()), ); // Clear the cart cart.clear(); }, style: ElevatedButton.styleFrom( primary: Colors.black, // Background color textStyle: TextStyle( color: Colors.white, // Text color fontWeight: FontWeight.bold, ), ), child: Text('Check Out'), ), ); } }
0
mirrored_repositories/Shoes-Shopping-App-In-Flutter/lib
mirrored_repositories/Shoes-Shopping-App-In-Flutter/lib/providers/cart_provider.dart
import 'package:flutter/material.dart'; class CartProvider extends ChangeNotifier { final List<Map<String, dynamic>> cart = []; void addProduct(Map<String, dynamic> product) { cart.add(product); notifyListeners(); } void removeProduct(Map<String, dynamic> product) { cart.remove(product); notifyListeners(); } }
0
mirrored_repositories/pizza-app-ui-flutter
mirrored_repositories/pizza-app-ui-flutter/lib/main.dart
import 'package:flutter/material.dart'; void main() { runApp(const MyApp()); } class MyApp extends StatefulWidget { const MyApp({super.key}); @override _MyApp createState() => _MyApp(); } class _MyApp extends State<MyApp> { String _currentState = "Starter"; List<String> list = <String>[ "Starter", "Asian", "Placha & Roasts & Grills", "Classic", "Indian", "Italian" ]; @override Widget build(BuildContext context) { return MaterialApp( home: Scaffold( appBar: AppBar( backgroundColor: Colors.red, title: const Text("Jayant Kumar"), leading: IconButton( icon: const Icon(Icons.menu), onPressed: () {}, color: Colors.white, ), actions: [ IconButton( icon: const Icon(Icons.search), onPressed: () {}, color: Colors.white, ), ], centerTitle: false, elevation: 0, ), body: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ SingleChildScrollView( scrollDirection: Axis.horizontal, child: Row( children: [ for (int i = 0; i < list.length; i++) customChip( list[i] == _currentState, list[i], (p0) => { setState(() { _currentState = p0; }) }) ], ), ), Expanded( child: GridView( gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount( crossAxisCount: 2, crossAxisSpacing: 2, mainAxisSpacing: 2), children: [ showPizzaRow(), showPizzaRow(), showPizzaRow(), showPizzaRow(), showPizzaRow(), showPizzaRow(), showPizzaRow(), showPizzaRow(), ], ), ) ], ), ), ); } } Widget customChip(bool selected, String title, Function(String) onValueChange) { return Padding( padding: const EdgeInsets.all(10), child: TextButton( onPressed: () { onValueChange(title); }, style: TextButton.styleFrom( foregroundColor: selected ? Colors.white : Colors.black, backgroundColor: selected ? Colors.red : Colors.transparent, elevation: 0, shape: const RoundedRectangleBorder( borderRadius: BorderRadius.all(Radius.circular(25)))), child: Padding( padding: const EdgeInsets.all(5), child: Text( title, style: const TextStyle(fontSize: 14, fontWeight: FontWeight.w600), ), ), ), ); } Widget showPizzaRow() { return SizedBox( width: 175, child: Card( elevation: 1, shape: const RoundedRectangleBorder( borderRadius: BorderRadius.all(Radius.circular(5))), child: Column( crossAxisAlignment: CrossAxisAlignment.center, children: [ Image.asset( "assets/images/pizza.png", width: 109, height: 109, ), spacerHeight(5), const Text( "£14.25", style: TextStyle( fontSize: 14, fontWeight: FontWeight.w400, color: Colors.red, ), textAlign: TextAlign.center, ), spacerHeight(5), const Text( "Fresh Farm House", style: TextStyle( fontSize: 14, fontWeight: FontWeight.w600, color: Colors.black), textAlign: TextAlign.center, ), spacerHeight(5), const Text( "crisp capsicum, succulent mushrooms and fresh tomatoes", style: TextStyle( fontSize: 10, fontWeight: FontWeight.w300, color: Colors.grey, ), textAlign: TextAlign.center, ), ], ), ), ); } Widget spacerHeight(double height) { return SizedBox(height: height); }
0
mirrored_repositories/pizza-app-ui-flutter
mirrored_repositories/pizza-app-ui-flutter/test/widget_test.dart
// This is a basic Flutter widget test. // // To perform an interaction with a widget in your test, use the WidgetTester // utility in the flutter_test package. For example, you can send tap and scroll // gestures. You can also use WidgetTester to find child widgets in the widget // tree, read text, and verify that the values of widget properties are correct. import 'package:flutter/material.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:pizza_app_ui/main.dart'; void main() { testWidgets('Counter increments smoke test', (WidgetTester tester) async { // Build our app and trigger a frame. await tester.pumpWidget(const MyApp()); // Verify that our counter starts at 0. expect(find.text('0'), findsOneWidget); expect(find.text('1'), findsNothing); // Tap the '+' icon and trigger a frame. await tester.tap(find.byIcon(Icons.add)); await tester.pump(); // Verify that our counter has incremented. expect(find.text('0'), findsNothing); expect(find.text('1'), findsOneWidget); }); }
0
mirrored_repositories
mirrored_repositories/Clima/scratch.dart
import 'dart:io'; void main() { performTask(); } void performTask() async { task1(); String task2Data = await task2(); task3(task2Data); } void task1() { String result = 'task 1 data'; print('Task 1 complete'); } Future<String> task2() async { Duration threeSeconds = Duration(seconds: 3); String result; // simulating loading of data await Future.delayed(threeSeconds, () { result = 'task 2 data'; print('Task 2 complete'); }); return result; } void task3(String task2Data) { String result = 'task 3 data'; print('Task 3 complete with $task2Data'); }
0
mirrored_repositories/Clima
mirrored_repositories/Clima/lib/main.dart
import 'package:flutter/material.dart'; import 'package:clima/screens/loading_screen.dart'; void main() => runApp(MyApp()); class MyApp extends StatelessWidget { @override Widget build(BuildContext context) { return MaterialApp( debugShowCheckedModeBanner: false, theme: ThemeData.dark(), home: LoadingScreen(), ); } }
0
mirrored_repositories/Clima/lib
mirrored_repositories/Clima/lib/utilities/constants.dart
import 'package:flutter/material.dart'; const kTempTextStyle = TextStyle( fontFamily: 'Spartan MB', fontSize: 60.0, ); const kMessageTextStyle = TextStyle( fontFamily: 'Spartan MB', fontSize: 30.0, ); const kButtonTextStyle = TextStyle( fontSize: 30.0, fontFamily: 'Spartan MB', ); const kConditionTextStyle = TextStyle( fontSize: 60.0, ); const kTextFieldInputDecoration = InputDecoration( filled: true, fillColor: Colors.white, icon: Icon( Icons.location_city, color: Colors.white, ), hintText: 'Enter City Name', hintStyle: TextStyle( color: Colors.grey, ), border: OutlineInputBorder( borderRadius: BorderRadius.all( Radius.circular(10.0), ), borderSide: BorderSide.none, ), );
0
mirrored_repositories/Clima/lib
mirrored_repositories/Clima/lib/services/networking.dart
import 'package:http/http.dart' as http; import 'dart:convert'; class NetworkHelper { NetworkHelper(this.url); final String url; Future getData() async { http.Response response = await http.get(url); if(response.statusCode == 200) { String data = response.body; return jsonDecode(data); } else { print(response.statusCode); } } }
0
mirrored_repositories/Clima/lib
mirrored_repositories/Clima/lib/services/location.dart
import 'package:geolocator/geolocator.dart'; class Location { double latitude; double longitude; Future<void> getCurrentLocation() async { try { print('getting position'); Position position = await getCurrentPosition( desiredAccuracy: LocationAccuracy.low, ); latitude = position.latitude; longitude = position.longitude; print('saved data'); } catch(e) { print(e); } } Future<void> getLastKnownLocation() async { try { print('getting position'); Position position = await getLastKnownPosition( forceAndroidLocationManager: true ); print(position); latitude = position.latitude; longitude = position.longitude; print('saved data'); } catch(e) { print(e); } } }
0
mirrored_repositories/Clima/lib
mirrored_repositories/Clima/lib/services/weather.dart
import 'package:clima/services/location.dart'; import 'package:clima/services/networking.dart'; const apiKey = '240729411a55042c0295ea0532ce366c'; const openWeatherMapURL = 'http://api.openweathermap.org/data/2.5/weather'; class WeatherModel { Future<dynamic> getCityWeather(String cityName) async { NetworkHelper networkHelper = NetworkHelper( '$openWeatherMapURL?' 'q=$cityName&' 'appid=$apiKey&' 'units=metric' ); var weatherData = await networkHelper.getData(); return weatherData; } Future<dynamic> getCurrentLocationWeather() async { Location location = Location(); try { print('trying to get location'); await location.getCurrentLocation(); print('got location data'); } catch(e) { print(e); } var weatherData; weatherData = getWeatherUsingLocation(location); return weatherData; } Future<dynamic> getLastLocationWeather() async { Location location = Location(); try { print('trying to get last location'); await location.getLastKnownLocation(); print('got last location data'); } catch (e) { print(e); } var weatherData; weatherData = getWeatherUsingLocation(location); return weatherData; } Future<dynamic> getWeatherUsingLocation(Location location) async { NetworkHelper networkHelper = NetworkHelper( '$openWeatherMapURL?' 'lat=${location.latitude}&' 'lon=${location.longitude}&' 'appid=$apiKey&' 'units=metric' ); var weatherData; try { print('trying to get weather data'); weatherData = await networkHelper.getData(); } catch(e) { print(e); } return weatherData; } String getWeatherIcon(int condition) { if (condition < 300) { return '🌩'; } else if (condition < 400) { return '🌧'; } else if (condition < 600) { return '☔️'; } else if (condition < 700) { return '☃️'; } else if (condition < 800) { return '🌫'; } else if (condition == 800) { return '☀️'; } else if (condition <= 804) { return '☁️'; } else { return '🤷‍'; } } String getMessage(int temp, String cityName) { if (temp > 25) { return 'It\'s 🍦 time in $cityName'; } else if (temp > 20) { return 'Time for shorts and 👕 in $cityName'; } else if (temp < 10) { return 'You\'ll need 🧣 and 🧤 in $cityName'; } else { return 'Bring a 🧥 just in case in $cityName'; } } }
0