repo_id
stringlengths
21
168
file_path
stringlengths
36
210
content
stringlengths
1
9.98M
__index_level_0__
int64
0
0
mirrored_repositories/My-Shop/lib
mirrored_repositories/My-Shop/lib/widgets/product_item.dart
import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; import '../providers/auth.dart'; import '../providers/cart_.dart'; import '../providers/product.dart'; import 'package:stateManagement/screens/product_details_screen.dart'; class ProductItem extends StatelessWidget { // final String id; // final String title; // final String description; // final String imageUrl; // const ProductItem(this.id, this.title, this.description, this.imageUrl); @override Widget build(BuildContext context) { final product = Provider.of<Product>(context, listen: false); final cart = Provider.of<Cart>(context, listen: false); final authData = Provider.of<Auth>(context, listen: false); /// this will not listen hole product print('product Rebuild'); return ClipRRect( borderRadius: BorderRadius.circular(10), child: GridTile( child: GestureDetector( onTap: () { Navigator.of(context).pushNamed(ProductDetailsScreen.routeName, arguments: product.id); }, child: Hero( tag: product.id, child: FadeInImage( placeholder: AssetImage('assets/images/product-placeholder.png'), image: NetworkImage(product.imageUrl), fit: BoxFit.cover, ), ), ), footer: GridTileBar( backgroundColor: Colors.black87, /* consimer will listen only favorite changes child of consumer used to assign as const */ leading: Consumer<Product>( builder: (ctx, product, child) => IconButton( icon: Icon( product.isFavorite ? Icons.favorite : Icons.favorite_border), onPressed: () { product.toggleFavoriteStatus( authData.token, authData.userId, ); }, color: Theme.of(context).accentColor, ), ), trailing: IconButton( icon: Icon(Icons.shopping_cart), onPressed: () { cart.addItem( productId: product.id, price: product.price, title: product.title); //hiding overlap snackbar Scaffold.of(context).hideCurrentSnackBar(); Scaffold.of(context).showSnackBar( SnackBar( content: Text( "Added ${product.title} to cart!", ), duration: Duration( seconds: 1, milliseconds: 500, ), action: SnackBarAction( label: "Undo", onPressed: () { cart.removeSingleItem(product.id); }, ), ), ); }, color: Theme.of(context).accentColor, ), title: Text( product.title, textAlign: TextAlign.center, ), ), ), ); } }
0
mirrored_repositories/My-Shop/lib
mirrored_repositories/My-Shop/lib/utils/coustom_route.dart
import 'package:flutter/material.dart'; class CustomRoute<T> extends MaterialPageRoute<T> { CustomRoute({ WidgetBuilder builder, RouteSettings settings, }) : super( builder: builder, settings: settings, ); @override Widget buildTransitions( BuildContext context, Animation<double> animation, Animation<double> secondaryAnimation, Widget child, ) { //: isInitialRoute invalide why if (settings.name=='/') { return child; } return FadeTransition( opacity: animation, child: child, ); } } class CustomPageTransitionBuilder extends PageTransitionsBuilder { @override Widget buildTransitions<T>( PageRoute<T> route, BuildContext context, Animation<double> animation, Animation<double> secondaryAnimation, Widget child, ) { //FIXed: isInitialRoute invalide why if (route.settings.name=='/') { return child; } return FadeTransition( opacity: animation, child: child, ); } }
0
mirrored_repositories/My-Shop/lib
mirrored_repositories/My-Shop/lib/utils/https_exception.dart
class HttpException implements Exception { final String message; HttpException(this.message); @override String toString() { return message; } }
0
mirrored_repositories/My-Shop/lib
mirrored_repositories/My-Shop/lib/utils/constants.dart
// const BASE_API_REALTIMEdb = 'https://my-shop-2233f.firebaseio.com'; const WEB_API_KEY = 'AIzaSyB0BzP8riJqMFL3z-gEWJggG0sPoi1JH84';
0
mirrored_repositories/My-Shop/lib
mirrored_repositories/My-Shop/lib/screens/cart_screen.dart
import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; import '../providers/cart_.dart' show Cart; // only import Cart import '../providers/orders.dart'; import '../widgets/cart_item.dart' as ci; /// using prefix [ci] class CartScreen extends StatelessWidget { static const routeName = "/card_Screen"; const CartScreen({Key key}) : super(key: key); @override Widget build(BuildContext context) { final cart = Provider.of<Cart>(context); return Scaffold( appBar: AppBar( title: Text("Your Cart"), ), body: Column( children: [ Card( margin: EdgeInsets.all(15), child: Padding( padding: EdgeInsets.all(7), child: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: <Widget>[ Text( "Total ", style: TextStyle(fontSize: 20), ), Spacer(), // take all space Chip( label: Text( '\$${cart.totalAmount.toStringAsFixed(2)}', style: TextStyle(color: Colors.white), ), backgroundColor: Theme.of(context).primaryColor, ), OrderButton(cart: cart), ], ), ), ), SizedBox( height: 10, ), // listview will take as much height it get, because listview doesn't work in column directly Expanded( child: ListView.builder( itemCount: cart.items.length, itemBuilder: (ctx, i) => ci.CartItem( id: cart.items.values.toList()[i].id, title: cart.items.values.toList()[i].title, productID: cart.items.keys.toList()[i], price: cart.items.values.toList()[i].price, quantity: cart.items.values.toList()[i].quantity), ), ), ], ), ); } } class OrderButton extends StatefulWidget { const OrderButton({ Key key, @required this.cart, }) : super(key: key); final Cart cart; @override _OrderButtonState createState() => _OrderButtonState(); } class _OrderButtonState extends State<OrderButton> { var _isLoading = false; @override Widget build(BuildContext context) { return FlatButton( child: _isLoading ? CircularProgressIndicator() : Text( "ORDER NOW", ), textColor: Theme.of(context).primaryColor, onPressed: (widget.cart.totalAmount <= 0 || _isLoading) ? null : () async { setState(() { _isLoading = true; }); // print(widget.cart.items.values.map((item) { // print(item.title); // }).toList()); await Provider.of<Orders>(context, listen: false).addOrder( widget.cart.items.values.toList(), widget.cart.totalAmount, ); setState(() { _isLoading = false; }); widget.cart.clearCart(); }, ); } }
0
mirrored_repositories/My-Shop/lib
mirrored_repositories/My-Shop/lib/screens/user_product_screen.dart
import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; import '../screens/edit_product_screen.dart'; import '../providers/products_provider.dart'; import '../widgets/user_product_item.dart'; import '../widgets/main_drawer.dart'; class UserProductScreen extends StatelessWidget { static const routeName = '/user-product-screen'; @override Widget build(BuildContext context) { // final productData = Provider.of<Products>(context); Future<void> _refreshProducts(BuildContext context) async { // TODO: if wanna filter pass true, it is an optional argument, // set false as default await Provider.of<Products>(context, listen: false).fetchAndSetProducts(); } return Scaffold( drawer: AppDrawer(), appBar: AppBar( title: const Text('Your Product'), actions: <Widget>[ IconButton( icon: const Icon(Icons.add), onPressed: () { Navigator.of(context).pushNamed(EditProductScreen.routeName); }, ), ], ), body: FutureBuilder( future: _refreshProducts(context), builder: (ctx, snapshot) => snapshot.connectionState == ConnectionState.waiting ? Center( child: CircularProgressIndicator(), ) : RefreshIndicator( onRefresh: () => _refreshProducts(context), child: Consumer<Products>( builder: (ctx, productData, _unchanged) => Padding( padding: EdgeInsets.all(10), child: ListView.builder( itemCount: productData.items.length, itemBuilder: (ctx, i) => Column( children: [ UserProductItem( id: productData.items[i].id, title: productData.items[i].title, imageUrl: productData.items[i].imageUrl, ), Divider(), ], ), ), ), ), ), ), ); } }
0
mirrored_repositories/My-Shop/lib
mirrored_repositories/My-Shop/lib/screens/edit_product_screen.dart
import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; import '../providers/product.dart'; import '../providers/products_provider.dart'; class EditProductScreen extends StatefulWidget { static const routeName = '/edit-product-screen'; EditProductScreen({Key key}) : super(key: key); @override _EditProductScreenState createState() => _EditProductScreenState(); } class _EditProductScreenState extends State<EditProductScreen> { final _priceFocusNode = FocusNode(); final _descriptionNode = FocusNode(); final _imageUrlControler = TextEditingController(); final _imageurlFocus = FocusNode(); final _form = GlobalKey<FormState>(); var _product = Product( id: null, description: '', imageUrl: '', price: 0, title: '', ); var _isInit = true; var _initValues = { 'title': '', 'description': '', 'price': '', 'imageUrl': '' }; var _isLoading = false; @override void initState() { _imageurlFocus.addListener(_updateImageUrl); super.initState(); } @override void didChangeDependencies() { if (_isInit) { final productId = ModalRoute.of(context).settings.arguments as String; if (productId != null) { _product = Provider.of<Products>(context, listen: false).findByID(productId); _initValues = { 'title': _product.title, 'description': _product.description, 'price': _product.price.toString(), 'imageUrl': '' }; _imageUrlControler.text = _product.imageUrl; } } _isInit = false; super.didChangeDependencies(); } // it will auto update and create new State void _updateImageUrl() { if (!_imageurlFocus.hasFocus) { if (_imageUrlControler.text.isEmpty && (!_imageUrlControler.text.startsWith('http') || !_imageUrlControler.text.startsWith('https')) && (!_imageUrlControler.text.endsWith('.png') || !_imageUrlControler.text.endsWith('.jpg') || !_imageUrlControler.text.endsWith('.jpeg'))) return; setState(() {}); } } @override void dispose() { _imageurlFocus.removeListener(_updateImageUrl); _priceFocusNode.dispose(); _descriptionNode.dispose(); _imageUrlControler.dispose(); _imageurlFocus.dispose(); super.dispose(); } Future<void> _saveform() async { final isValid = _form.currentState.validate(); if (!isValid) return; _form.currentState.save(); setState(() { _isLoading = true; }); if (_product.id != null) { await Provider.of<Products>(context, listen: false) .updateProduct(_product.id, _product); } else { try { await Provider.of<Products>(context, listen: false) .addProduct(_product); } catch (_) { await showDialog( context: context, builder: (ctx) => AlertDialog( title: Text("An Error occured"), content: Text('Something went wrong :('), actions: <Widget>[ FlatButton( child: Text('Okay'), onPressed: () { Navigator.of(ctx).pop(); }, ), ], )); } // finally { // setState(() { // _isLoading = false; // }); // Navigator.of(context).pop(); } setState(() { _isLoading = false; }); Navigator.of(context).pop(); } @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( title: Text('Edit Product'), actions: <Widget>[ IconButton( icon: Icon( Icons.save, ), onPressed: _saveform), ], ), body: _isLoading ? Center( child: CircularProgressIndicator(), ) : Padding( padding: const EdgeInsets.all(16.0), child: Form( key: _form, child: ListView( children: <Widget>[ TextFormField( initialValue: _initValues['title'], decoration: InputDecoration( labelText: 'Title', ), textInputAction: TextInputAction.next, onFieldSubmitted: (_) { FocusScope.of(context).requestFocus(_priceFocusNode); }, onSaved: (value) { _product = Product( id: _product.id, title: value, description: _product.description, price: _product.price, imageUrl: _product.imageUrl, isFavorite: _product.isFavorite); }, validator: (value) { if (value.isEmpty) { return "Provide a title"; } return null; }, ), TextFormField( initialValue: _initValues['price'], decoration: InputDecoration( labelText: 'Price', ), textInputAction: TextInputAction.next, keyboardType: TextInputType.number, focusNode: _priceFocusNode, onFieldSubmitted: (_) => FocusScope.of(context).requestFocus(_descriptionNode), onSaved: (value) { _product = Product( id: _product.id, title: _product.title, description: _product.description, price: double.parse(value), imageUrl: _product.imageUrl, isFavorite: _product.isFavorite); }, validator: (value) { if (value.isEmpty) { return "Please enter a price"; } if (double.tryParse(value) == null) { return "Please enter a valid number."; } if (double.parse(value) <= 0) { return 'Please enter a number greater than zero.'; } return null; }, ), TextFormField( initialValue: _initValues['description'], decoration: InputDecoration( labelText: 'Description', ), focusNode: _descriptionNode, maxLines: 3, keyboardType: TextInputType.multiline, // textInputAction: TextInputAction.next, onSaved: (value) { _product = Product( id: _product.id, title: _product.title, description: value, price: _product.price, imageUrl: _product.imageUrl, isFavorite: _product.isFavorite); }, validator: (value) { if (value.isEmpty) { return 'write something about product.'; } if (value.length > 50) { return 'max 50 charecter'; } return null; }, ), Row( crossAxisAlignment: CrossAxisAlignment.end, children: <Widget>[ Container( width: 100, height: 100, margin: EdgeInsets.only(top: 8, right: 10), decoration: BoxDecoration( border: Border.all( width: 1, color: Colors.grey, ), ), child: _imageUrlControler.text.isEmpty ? Center( child: Text( "Enter a Url", textAlign: TextAlign.center, ), ) : FittedBox( child: Image.network( _imageUrlControler.text, fit: BoxFit.cover, ), )), Expanded( child: TextFormField( // initialValue: _initValues['imageUrl'], ///[cant have controler and initValues togather here] decoration: InputDecoration(labelText: 'Image URL'), keyboardType: TextInputType.url, textInputAction: TextInputAction.done, controller: _imageUrlControler, focusNode: _imageurlFocus, onFieldSubmitted: (_) => _saveform(), onSaved: (value) { _product = Product( id: _product.id, title: _product.title, description: _product.description, price: _product.price, imageUrl: value, isFavorite: _product.isFavorite); }, validator: (value) { if (value.isEmpty) { return "Please enter a url"; } if (!value.startsWith('http') && !value.startsWith('https')) { return 'Enter a valid URL'; } if (!value.endsWith('.png') && !value.endsWith('.jpg') && !value.endsWith('.jpeg')) { return 'Not valid Image'; } return null; }, ), ), ], ), ], ), ), ), ); } }
0
mirrored_repositories/My-Shop/lib
mirrored_repositories/My-Shop/lib/screens/splash_screen.dart
import 'package:flutter/material.dart'; class SplashScreen extends StatelessWidget { @override Widget build(BuildContext context) { return Scaffold( body: Center( child: Text('Loading...'), ), ); } }
0
mirrored_repositories/My-Shop/lib
mirrored_repositories/My-Shop/lib/screens/order_screen.dart
import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; import '../widgets/main_drawer.dart'; import '../providers/orders.dart' show Orders; import '../widgets/order_item.dart'; class OrderScreen extends StatelessWidget { static const routename = "/orders_"; @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( title: Text("Your Orders"), ), drawer: AppDrawer(), body: FutureBuilder( future: Provider.of<Orders>(context, listen: false).fetchAndSetOrders(), builder: (ctx, dataSnapShot) { if (dataSnapShot.connectionState == ConnectionState.waiting) { return Center(child: CircularProgressIndicator()); } else { if (dataSnapShot.error != null) { return Center( child: Text("Data Collection Error"), ); } else { return Consumer<Orders>( builder: (ctx, orderData, child) => ListView.builder( itemCount: orderData.orders.length, itemBuilder: (ctx, i) => OrderItem( orderData.orders[i], ), ), ); } } }, ), ); } }
0
mirrored_repositories/My-Shop/lib
mirrored_repositories/My-Shop/lib/screens/products_overView.dart
import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; import '../providers/cart_.dart'; import '../screens/cart_screen.dart'; import '../widgets/badge.dart'; import '../widgets/grid_item.dart'; import '../widgets/main_drawer.dart'; import '../providers/products_provider.dart'; enum FilterOptions { Favorite, All, } class ProductOverViewScreen extends StatefulWidget { @override _ProductOverViewScreenState createState() => _ProductOverViewScreenState(); } class _ProductOverViewScreenState extends State<ProductOverViewScreen> { var _showOnlyFavorite = false; var _isInit = true; var _isLoading = true; @override void initState() { /* if we wanna get context,use future approce here */ // Future.delayed(Duration.zero).then((value) { // /// we are able to use context here. // }); super.initState(); } @override void didChangeDependencies() { if (_isInit) { setState(() { _isLoading = true; }); Provider.of<Products>(context).fetchAndSetProducts().then((_) { setState(() { _isLoading = false; }); }); } _isInit = false; super.didChangeDependencies(); } @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( title: Text("My Shop"), actions: <Widget>[ PopupMenuButton( icon: Icon( Icons.more_vert, ), onSelected: (FilterOptions value) { print("choosen value " + value.toString()); setState(() { if (value == FilterOptions.Favorite) { _showOnlyFavorite = true; } else { _showOnlyFavorite = false; } }); }, itemBuilder: (_) => [ PopupMenuItem( child: Text("Favorite Only"), value: FilterOptions.Favorite, ), PopupMenuItem( child: Text( "Show All", ), value: FilterOptions.All, ), ], ), Consumer<Cart>( builder: (_, cart, ch) => Badge( child: ch, value: cart.itemCount.toString(), ), child: IconButton( icon: Icon(Icons.shopping_cart), onPressed: () { Navigator.of(context).pushNamed(CartScreen.routeName); }, ), ), ], ), body: _isLoading ? Center( child: CircularProgressIndicator(), ) : ProductGrid(_showOnlyFavorite), drawer: AppDrawer(), ); } }
0
mirrored_repositories/My-Shop/lib
mirrored_repositories/My-Shop/lib/screens/product_details_screen.dart
import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; import '../providers/products_provider.dart'; class ProductDetailsScreen extends StatelessWidget { static const routeName = "/product_detail"; @override Widget build(BuildContext context) { final productId = ModalRoute.of(context).settings.arguments as String; final product = Provider.of<Products>(context, listen: false // we dont need to update ) .findByID(productId); return Scaffold( // appBar: AppBar( // title: Text(product.title), // ), body: CustomScrollView( slivers: <Widget>[ SliverAppBar( expandedHeight: 300, pinned: true, flexibleSpace: FlexibleSpaceBar( title: Text(product.title), background: Hero( tag: productId, child: Image.network( product.imageUrl, fit: BoxFit.cover, ), ), ), ), SliverList( delegate: SliverChildListDelegate( [ SizedBox( height: 10, ), Text( '\$${product.price}', style: TextStyle( color: Colors.grey, fontSize: 20, ), textAlign: TextAlign.center, ), SizedBox( height: 10, ), Container( padding: EdgeInsets.symmetric(horizontal: 10), width: double.infinity, child: Text( product.description, textAlign: TextAlign.center, softWrap: true, style: TextStyle(color: Colors.black, fontSize: 22), ), ), // TODO: add more details // added for test // SizedBox(height:800), ], ), ), ], ), ); } }
0
mirrored_repositories/My-Shop/lib
mirrored_repositories/My-Shop/lib/screens/auth_screen.dart
import 'dart:math'; import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; import '../providers/auth.dart'; import '../utils/https_exception.dart'; enum AuthMode { Signup, Login } class AuthScreen extends StatelessWidget { static const routeName = '/auth'; @override Widget build(BuildContext context) { final deviceSize = MediaQuery.of(context).size; // final transformConfig = Matrix4.rotationZ(-8 * pi / 180); // transformConfig.translate(-10.0); return Scaffold( // resizeToAvoidBottomInset: false, body: Stack( children: <Widget>[ Container( decoration: BoxDecoration( gradient: LinearGradient( colors: [ Color.fromRGBO(215, 117, 255, 1).withOpacity(0.5), Color.fromRGBO(255, 188, 117, 1).withOpacity(0.9), ], begin: Alignment.topLeft, end: Alignment.bottomRight, stops: [0, 1], ), ), ), SingleChildScrollView( child: Container( height: deviceSize.height, width: deviceSize.width, child: Column( mainAxisAlignment: MainAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.center, children: <Widget>[ Flexible( child: Container( margin: EdgeInsets.only(bottom: 20.0), padding: EdgeInsets.symmetric(vertical: 8.0, horizontal: 94.0), transform: Matrix4.rotationZ(-8 * pi / 180) ..translate(-10.0), // ..translate(-10.0), decoration: BoxDecoration( borderRadius: BorderRadius.circular(20), color: Colors.deepOrange.shade900, boxShadow: [ BoxShadow( blurRadius: 8, color: Colors.black26, offset: Offset(0, 2), ) ], ), child: Text( 'MyShop', style: TextStyle( color: Theme.of(context).accentTextTheme.title.color, fontSize: 50, fontFamily: 'Anton', fontWeight: FontWeight.normal, ), ), ), ), Flexible( flex: deviceSize.width > 600 ? 2 : 1, child: AuthCard(), ), ], ), ), ), ], ), ); } } class AuthCard extends StatefulWidget { const AuthCard({ Key key, }) : super(key: key); @override _AuthCardState createState() => _AuthCardState(); } class _AuthCardState extends State<AuthCard> with SingleTickerProviderStateMixin { final GlobalKey<FormState> _formKey = GlobalKey(); AuthMode _authMode = AuthMode.Login; Map<String, String> _authData = { 'email': '', 'password': '', }; var _isLoading = false; final _passwordController = TextEditingController(); //TODO:For Animation AnimationController _controller; Animation<Offset> _slideAnimation; Animation<double> _opacityAnimation; @override void initState() { _controller = AnimationController( vsync: this, duration: Duration( milliseconds: 250, ), ); _slideAnimation = Tween<Offset>( begin: Offset(0, -1.5), end: Offset(0, 0), ).animate( CurvedAnimation( parent: _controller, curve: Curves.easeInOutQuad, ), ); // _heightAnimation.addListener(() => setState(() {})); _opacityAnimation = Tween( begin: 0.0, end: 1.0, ).animate( CurvedAnimation( parent: _controller, curve: Curves.easeIn, ), ); super.initState(); } @override void dispose() { _controller.dispose(); super.dispose(); } void _showErrorDialod(String message) { showDialog( context: context, builder: (ctx) => AlertDialog( title: Text("An Error Occured!"), content: Text(message), actions: <Widget>[ FlatButton( child: Text('Ok'), onPressed: () { Navigator.of(ctx).pop(); }, ) ], ), ); } Future<void> _submit() async { if (!_formKey.currentState.validate()) { // Invalid! return; } _formKey.currentState.save(); setState( () { _isLoading = true; }, ); try { if (_authMode == AuthMode.Login) { // Log user in await Provider.of<Auth>(context, listen: false).logIn( _authData['email'], _authData['password'], ); } else { // Sign user up await Provider.of<Auth>(context, listen: false).signUp( _authData['email'], _authData['password'], ); } } on HttpException catch (e) { var em = 'Authentication Failed'; if (e.message.contains('EMAIL_EXISTS')) { em = 'This email address is already in use.'; } else if (e.message.contains('INVALID_EMAIL')) { em = 'This email address is not valid.'; } else if (e.message.contains('WEAK_PASSWORD')) { em = 'This password is week.'; } else if (e.message.contains('EMAIL_NOT_FOUND')) { em = 'This email address could not found.'; } else if (e.message.contains('INVALID_PASSWORD')) { em = 'invalid password.'; } _showErrorDialod(em); } catch (e) { const em = 'Could not authenticate you.'; _showErrorDialod(em); } setState(() { _isLoading = false; }); } void _switchAuthMode() { if (_authMode == AuthMode.Login) { setState(() { _authMode = AuthMode.Signup; }); _controller.forward(); } else { setState(() { _authMode = AuthMode.Login; }); _controller.reverse(); } } @override Widget build(BuildContext context) { final deviceSize = MediaQuery.of(context).size; return Card( shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(10.0), ), elevation: 8.0, child: AnimatedContainer( duration: Duration(milliseconds: 300), curve: Curves.easeIn, height: _authMode == AuthMode.Signup ? 320 : 260, // height: _heightAnimation.value.height, //animated setup constraints: // todo: animated setup BoxConstraints( minHeight: _authMode == AuthMode.Signup ? 320 : 260, ), width: deviceSize.width * 0.75, padding: EdgeInsets.all(16.0), child: Form( key: _formKey, child: SingleChildScrollView( child: Column( children: <Widget>[ TextFormField( decoration: InputDecoration(labelText: 'E-Mail'), keyboardType: TextInputType.emailAddress, validator: (value) { if (value.isEmpty || !value.contains('@')) { return 'Invalid email!'; } }, onSaved: (value) { _authData['email'] = value; }, ), TextFormField( decoration: InputDecoration(labelText: 'Password'), obscureText: true, controller: _passwordController, validator: (value) { if (value.isEmpty || value.length < 5) { return 'Password is too short!'; } }, onSaved: (value) { _authData['password'] = value; }, ), // if (_authMode == AuthMode.Signup) AnimatedContainer( constraints: BoxConstraints( minHeight: _authMode == AuthMode.Signup ? 60 : 0, maxHeight: _authMode == AuthMode.Signup ? 120 : 0, ), curve: Curves.easeIn, duration: Duration(milliseconds: 300), child: FadeTransition( opacity: _opacityAnimation, child: SlideTransition( position: _slideAnimation, child: TextFormField( enabled: _authMode == AuthMode.Signup, decoration: InputDecoration(labelText: 'Confirm Password'), obscureText: true, validator: _authMode == AuthMode.Signup ? (value) { if (value != _passwordController.text) { return 'Passwords do not match!'; } } : null, ), ), ), ), SizedBox( height: 20, ), if (_isLoading) CircularProgressIndicator() else RaisedButton( child: Text(_authMode == AuthMode.Login ? 'LOGIN' : 'SIGN UP'), onPressed: _submit, shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(30), ), padding: EdgeInsets.symmetric(horizontal: 30.0, vertical: 8.0), color: Theme.of(context).primaryColor, textColor: Theme.of(context).primaryTextTheme.button.color, ), FlatButton( child: Text( '${_authMode == AuthMode.Login ? 'SIGNUP' : 'LOGIN'} INSTEAD'), onPressed: _switchAuthMode, padding: EdgeInsets.symmetric(horizontal: 30.0, vertical: 4), materialTapTargetSize: MaterialTapTargetSize.shrinkWrap, textColor: Theme.of(context).primaryColor, ), ], ), ), ), ), ); } }
0
mirrored_repositories/My-Shop/lib
mirrored_repositories/My-Shop/lib/providers/products_provider.dart
import 'package:flutter/material.dart'; import './product.dart'; import 'package:http/http.dart' as http; import 'dart:convert'; import '../utils/https_exception.dart'; import '../utils/constants.dart' as Constants; /// [Dont forget to add .json after URL ] class Products with ChangeNotifier { List<Product> _items = []; String authToken; String userId; Products(this.authToken, this.userId, this._items); void update(String authToken, String userId) { authToken = authToken; userId = userId; } List<Product> get items { return [..._items]; } List<Product> get favItems { return _items.where((element) => element.isFavorite).toList(); } Future<void> addProduct(Product product) async { /// /use as sub folder to root. [don't forget to use .json] */ /// // TODO: add base api final url = '${Constants.BASE_API_REALTIMEdb}/products.json?auth=$authToken'; try { final response = await http.post( url, body: json.encode({ 'description': product.description, 'imageUrl': product.imageUrl, 'price': product.price, 'title': product.title, 'creatorId': userId, }), ); final _product = Product( id: json.decode(response.body)['name'], description: product.description, imageUrl: product.imageUrl, price: product.price, title: product.title, ); _items.add(_product); notifyListeners(); } catch (error) { print(error); throw (error); } } // this takes optional positional argument Future<void> fetchAndSetProducts([bool filterByUser = false]) async { // TODO: add base api final filterSetting = filterByUser ? 'orderBy="creatorId"&equalTo="$userId"' : ''; var url = '${Constants.BASE_API_REALTIMEdb}/products.json?auth=$authToken&$filterSetting'; // print(url); try { final response = await http.get(url); final extractData = json.decode(response.body) as Map<String, dynamic>; final List<Product> loadProducts = []; if (extractData == null) { print("Cant Load products"); return; } // TODO: add base api url = '${Constants.BASE_API_REALTIMEdb}/userFavorites/$userId.json?auth=$authToken'; final favResponse = await http.get(url); final favData = json.decode(favResponse.body); extractData.forEach((key, prodData) { loadProducts.add(Product( id: key, title: prodData['title'], description: prodData['description'], price: prodData['price'], /* favData==null?false: favData[key]?? false, ?? mean if prefkey is null */ isFavorite: favData == null ? false : favData[key] ?? false, imageUrl: prodData['imageUrl'], )); }); _items = loadProducts; notifyListeners(); } catch (error) { throw (error); } } Future<void> updateProduct(String id, Product product) async { final indexProduct = _items.indexWhere((element) => element.id == id); if (indexProduct >= 0) { // TODO: add base api final url = '${Constants.BASE_API_REALTIMEdb}/products/$id.json?auth=$authToken'; await http.patch(url, body: json.encode({ 'title': product.title, 'description': product.description, 'imageUrl': product.imageUrl, 'price': product.price })); _items[indexProduct] = product; notifyListeners(); } } Future<void> deleteProduct(String id) async { ///* status code /// 200, 201 = everything work /// 300 redirected /// 400 , 500 something went worng /// ///// TODO: add base api final url = '${Constants.BASE_API_REALTIMEdb}/products/$id.json?auth=$authToken'; final exitProductIndex = _items.indexWhere((element) => element.id == id); var exitProduct = _items[exitProductIndex]; _items.removeAt(exitProductIndex); notifyListeners(); final response = await http.delete(url); print(response.statusCode); if (response.statusCode >= 400) { _items.insert(exitProductIndex, exitProduct); notifyListeners(); throw HttpException('Couldn\'t delete product.'); } exitProduct = null; } Product findByID(String id) { return _items.firstWhere((element) => element.id == id); } }
0
mirrored_repositories/My-Shop/lib
mirrored_repositories/My-Shop/lib/providers/cart_.dart
import 'package:flutter/foundation.dart'; class CartItem { final String id; final String title; final int quantity; final double price; CartItem( {@required this.id, @required this.title, this.quantity, @required this.price}); } class Cart with ChangeNotifier { Map<String, CartItem> _items = {}; Map<String, CartItem> get items { return {..._items}; } //sumup the length not quantity, int get itemCount { return _items.length; } double get totalAmount { double temp = 0.0; _items.forEach((key, cartitem) { temp += cartitem.quantity * cartitem.price; }); return temp; } void addItem({ String productId, double price, String title, }) { if (_items.containsKey(productId)) { // if we have the item already, update the quantity _items.update( productId, (exitsitem) => CartItem( id: exitsitem.id, title: exitsitem.title, price: exitsitem.price, quantity: exitsitem.quantity + 1, )); } else { _items.putIfAbsent( productId, () => CartItem( id: DateTime.now().toString(), title: title, price: price, quantity: 1), ); } notifyListeners(); } void removeItem(String productid) { _items.remove(productid); notifyListeners(); } void removeSingleItem(String productId) { if (!_items.containsKey(productId)) { return; } if (_items[productId].quantity > 1) { _items.update( productId, (oldCart) => CartItem( id: oldCart.id, price: oldCart.price, title: oldCart.title, quantity: oldCart.quantity - 1, ), ); } else { _items.remove(productId); } notifyListeners(); } void clearCart() { _items = {}; notifyListeners(); } }
0
mirrored_repositories/My-Shop/lib
mirrored_repositories/My-Shop/lib/providers/auth.dart
import 'package:flutter/cupertino.dart'; import 'package:http/http.dart' as http; import 'dart:convert'; import '../utils/constants.dart' as Constants; import '../utils/https_exception.dart'; import 'dart:async'; import 'package:shared_preferences/shared_preferences.dart'; class Auth with ChangeNotifier { static const String KEY_USER_DATA = 'userData'; String _token; DateTime _experyDate; String _userId; Timer _authTimer; String get userId { return _userId; } bool get isAuth { return token != null; } String get token { if (_experyDate != null && _experyDate.isAfter(DateTime.now()) && _token != null) { return _token; } return null; } Future<void> _auth(String emai, String password, String urlSegment) async { // TODO: add url // https://identitytoolkit.googleapis.com/v1/accounts:signUp?key=[API_KEY] //https://identitytoolkit.googleapis.com/v1/accounts:signInWithPassword?key=[API_KEY] final url = 'https://identitytoolkit.googleapis.com/v1/accounts:$urlSegment?key=${Constants.WEB_API_KEY}'; // print(url); try { final response = await http.post( url, body: json.encode( { 'email': emai, 'password': password, 'returnSecureToken': true, }, ), ); var responseData = json.decode(response.body); print(responseData); if (responseData['error'] != null) { throw HttpException(responseData['error']['message']); } _token = responseData['idToken']; _userId = responseData['localId']; _experyDate = DateTime.now().add( Duration( seconds: int.parse( responseData['expiresIn'], ), ), ); _autoLogout(); notifyListeners(); // print(response.body); final sharePrefs = await SharedPreferences.getInstance(); final userData = json.encode({ 'token': _token, 'userId': _userId, 'expiryDate': _experyDate.toIso8601String(), }); sharePrefs.setString(KEY_USER_DATA, userData); } catch (e) { throw e; } } Future<bool> tryAutoLogin() async { final pref = await SharedPreferences.getInstance(); if (!pref.containsKey(KEY_USER_DATA)) { return false; } final extractData = json.decode(pref.getString(KEY_USER_DATA)) as Map<String, Object>; final expairyDate = DateTime.parse(extractData['expiryDate']); if (expairyDate.isBefore(DateTime.now())) { return false; } _token = extractData['token']; _userId = extractData['userId']; _experyDate = expairyDate; notifyListeners(); _autoLogout(); return true; } Future<void> logIn(String emai, String password) async { return _auth(emai, password, 'signInWithPassword'); } Future<void> signUp(String emai, String password) async { return _auth(emai, password, 'signUp'); } Future<void> logOut() async { _token = null; _userId = null; _experyDate = null; if (_authTimer != null) { _authTimer.cancel(); _authTimer = null; } notifyListeners(); final pres = await SharedPreferences.getInstance(); // here we can use clear being single data stored // pres.remove(KEY_USER_DATA); pres.clear(); } void _autoLogout() { if (_authTimer != null) { _authTimer.cancel(); } var expireTime = _experyDate.difference(DateTime.now()).inSeconds; _authTimer = Timer(Duration(seconds: expireTime), logOut); } }
0
mirrored_repositories/My-Shop/lib
mirrored_repositories/My-Shop/lib/providers/orders.dart
import 'package:flutter/cupertino.dart'; import 'package:flutter/foundation.dart'; import './cart_.dart'; import 'package:http/http.dart' as http; import 'dart:convert'; import '../utils/constants.dart' as Constants; class OrderItem { final String id; final double amount; final List<CartItem> products; final DateTime dateTime; OrderItem({ @required this.id, @required this.amount, @required this.dateTime, @required this.products, }); } class Orders with ChangeNotifier { List<OrderItem> _orders = []; String authToken; // final String userId; Orders(this.authToken, this._orders); void update( String authToken, // this.userId, ) { authToken = authToken; } List<OrderItem> get orders { return [..._orders]; } Future<void> fetchAndSetOrders() async { // TODO: add base api final url = '${Constants.BASE_API_REALTIMEdb}/orders.json?auth=$authToken'; final response = await http.get(url); // print(json.decode(response.body)); final List<OrderItem> loadedOrders = []; final extractedData = json.decode(response.body) as Map<String, dynamic>; if (extractedData == null) return; extractedData.forEach((key, value) { loadedOrders.add( OrderItem( id: key, amount: value['amount'], dateTime: DateTime.parse(value['dateTime']), products: (value['products'] as List<dynamic>) .map( (item) => CartItem( id: item['id'], price: item['price'], quantity: item['quantity'], title: item['title'], ), ) .toList(), ), ); }); _orders = loadedOrders.reversed.toList(); notifyListeners(); } Future<void> addOrder(List<CartItem> cartProducts, double total) async { // TODO: add base api // final url = '${Constants.BASE_API_REALTIMEdb}/orders.json?auth=$authToken'; final url = 'https://my-shop-2233f.firebaseio.com/orders.json?auth=$authToken'; final timeStamp = DateTime.now(); try { final response = await http.post( url, body: json.encode({ 'amount': total, 'dateTime': timeStamp.toIso8601String(), 'products': cartProducts .map((cp) => { 'id': cp.id, 'title': cp.title, 'quantity': cp.quantity, 'price': cp.price, // 'creatorId': }) .toList(), }), ); print(json.decode(response.body)); _orders.insert( 0, OrderItem( id: json.decode(response.body)['name'], amount: total, dateTime: timeStamp, products: cartProducts), ); notifyListeners(); } catch (e) { print(e.toString()); } } }
0
mirrored_repositories/My-Shop/lib
mirrored_repositories/My-Shop/lib/providers/product.dart
import 'package:flutter/foundation.dart'; import 'package:http/http.dart' as http; import 'dart:convert'; import '../utils/constants.dart' as Constants; class Product with ChangeNotifier { final String id; final String title; final String description; final double price; final String imageUrl; bool isFavorite; // this will change according to person wish Product({ @required this.id, @required this.title, @required this.description, @required this.price, @required this.imageUrl, this.isFavorite = false, }); void _revFavValue(bool fav) { isFavorite = fav; notifyListeners(); } Future<void> toggleFavoriteStatus(String token, String userId) async { final oldStatus = isFavorite; isFavorite = !isFavorite; print(isFavorite); notifyListeners(); // TODO: add base api final url = '${Constants.BASE_API_REALTIMEdb}/userFavorites/$userId/$id.json?auth=$token'; try { final response = await http.put( url, body: json.encode( isFavorite, ), ); print(response.body); /* patch, put or delete doesn't throw exception*/ if (response.statusCode >= 400) { _revFavValue(oldStatus); } } catch (e) { _revFavValue(oldStatus); } } }
0
mirrored_repositories/My-Shop
mirrored_repositories/My-Shop/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:stateManagement/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/plant_app
mirrored_repositories/plant_app/lib/theme.dart
import 'package:flutter/material.dart'; final double defaultMargin = 23.0; Color backgroundColor = Color(0XFFFBFDFF); Color lightGreenColor = Color(0XFF2DDA93); Color darkColor = Color(0XFF36455A); Color lightDarkColor = Color(0XFF495566); Color darkGreyColor = Color(0XFF6A6F7D); Color whiteColor = Color(0XFFFFFFFF); Color blueColor = Color(0XFF48A2F5); Color yellowColor = Color(0XFFFFCD00); Color linearOne = Color(0XFF61D2C4); Color linearTwo = Color(0XFF29D890);
0
mirrored_repositories/plant_app
mirrored_repositories/plant_app/lib/main.dart
import 'package:flutter/material.dart'; import 'package:plant_app/pages/boarding_page.dart'; void main() => runApp(MyApp()); class MyApp extends StatelessWidget { @override Widget build(BuildContext context) { return MaterialApp( debugShowCheckedModeBanner: false, home: BoardingPage( widthImage: 255.0, heightImage: 255.14, imageUrl: 'assets/illustration1.png', title: 'Identify Plants', subTitle: 'You can identify the plants you don\'t know\nthrough your camera', isBullOne: true, isBullTwo: false, isBullThree: false, textButton: 'NEXT', isAction: 'nextOne', ), ); } }
0
mirrored_repositories/plant_app/lib
mirrored_repositories/plant_app/lib/pages/species_page.dart
import 'package:flutter/material.dart'; import 'package:plant_app/pages/cactus_page.dart'; import 'package:plant_app/widget/alphabet_filter.dart'; import 'package:plant_app/widget/bottom_navbar.dart'; import 'package:plant_app/widget/content_title.dart'; import '../theme.dart'; class SpeciesPage extends StatelessWidget { @override Widget build(BuildContext context) { return Scaffold( backgroundColor: backgroundColor, bottomNavigationBar: BottomNavbar(), body: SafeArea( child: ListView( children: [ Stack( children: [ Container( height: 172, width: double.infinity, decoration: BoxDecoration( gradient: LinearGradient( begin: Alignment.topLeft, end: Alignment.bottomRight, colors: [ linearOne, linearTwo, ], ), ), child: Stack( children: [ Positioned( top: -90, right: -40, child: Container( height: 204, width: 204, decoration: BoxDecoration( color: whiteColor.withOpacity(0.2), borderRadius: BorderRadius.circular(102), ), ), ), Positioned( top: 60, right: -40, child: Container( height: 124, width: 124, decoration: BoxDecoration( color: whiteColor.withOpacity(0.13), borderRadius: BorderRadius.circular(102), ), ), ), Positioned( bottom: -10, right: -12, child: Text( 'Species', style: TextStyle( fontSize: 67, fontWeight: FontWeight.w900, color: whiteColor.withOpacity(0.2), ), ), ), Padding( padding: EdgeInsets.fromLTRB(23, 41, 23, 0), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Icon( Icons.chevron_left, color: whiteColor, size: 30, ), Icon( Icons.more_vert, color: whiteColor, size: 30, ), ], ), SizedBox( height: 19, ), Text( 'Species', style: TextStyle( fontWeight: FontWeight.w900, color: whiteColor, fontSize: 30, ), ), ], ), ), ], ), ), Container( width: double.infinity, color: backgroundColor, margin: EdgeInsets.only(top: 172), padding: EdgeInsets.only( top: 55, left: 23, right: 23, ), child: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ ContentTitle('C', true), SizedBox( height: 15, ), InkWell( onTap: () { Navigator.push( context, MaterialPageRoute( builder: (context) { return CactusPage(); }, ), ); }, child: ContentTitle('CACTUS', false), ), SizedBox( height: 15, ), ContentTitle('CISTUS', false), SizedBox( height: 15, ), ContentTitle('CAESALPINIA', false), SizedBox( height: 15, ), ContentTitle('CINNAMOMUM', false), SizedBox( height: 15, ), ContentTitle('CIRSIUM', false), SizedBox( height: 15, ), ContentTitle('CISSUS', false), SizedBox( height: 15, ), ContentTitle('D', true), SizedBox( height: 15, ), ContentTitle('DIERAMA', false), SizedBox( height: 15, ), ContentTitle('DIGITALIS', false), SizedBox( height: 15, ), ContentTitle('DAHLIA', false), SizedBox( height: 15, ), ContentTitle('DAPHNE', false), SizedBox( height: 15, ), ContentTitle('E', true), SizedBox( height: 15, ), ContentTitle('ECHINACEA', false), SizedBox( height: 15, ), ContentTitle('ECHINOPS', false), SizedBox( height: 15, ), ], ), Column( crossAxisAlignment: CrossAxisAlignment.center, children: [ AlphabetFilter('#'), SizedBox(height: 2), AlphabetFilter('A'), SizedBox(height: 2), AlphabetFilter('B'), SizedBox(height: 2), AlphabetFilter('C'), SizedBox(height: 2), AlphabetFilter('D'), SizedBox(height: 2), AlphabetFilter('E'), SizedBox(height: 2), AlphabetFilter('F'), SizedBox(height: 2), AlphabetFilter('G'), SizedBox(height: 2), AlphabetFilter('H'), SizedBox(height: 2), AlphabetFilter('I'), SizedBox(height: 2), AlphabetFilter('J'), SizedBox(height: 2), AlphabetFilter('K'), SizedBox(height: 2), AlphabetFilter('L'), SizedBox(height: 2), AlphabetFilter('M'), SizedBox(height: 2), AlphabetFilter('N'), SizedBox(height: 2), AlphabetFilter('O'), SizedBox(height: 2), AlphabetFilter('P'), SizedBox(height: 2), AlphabetFilter('Q'), SizedBox(height: 2), AlphabetFilter('R'), SizedBox(height: 2), AlphabetFilter('S'), SizedBox(height: 2), AlphabetFilter('T'), SizedBox(height: 2), AlphabetFilter('U'), SizedBox(height: 2), AlphabetFilter('V'), SizedBox(height: 2), AlphabetFilter('W'), SizedBox(height: 2), AlphabetFilter('X'), SizedBox(height: 2), AlphabetFilter('Y'), SizedBox(height: 2), AlphabetFilter('Z'), SizedBox(height: 2), ], ) ], ), ), Positioned( top: 148, child: Container( margin: EdgeInsets.symmetric(horizontal: 23), width: MediaQuery.of(context).size.width - (2 * 23), height: 50, decoration: BoxDecoration( color: whiteColor, borderRadius: BorderRadius.circular(25), boxShadow: [ BoxShadow( color: darkGreyColor.withOpacity(0.1), blurRadius: 1, spreadRadius: 1, offset: Offset(1, 1), ) ], ), child: Padding( padding: EdgeInsets.symmetric(horizontal: 25), child: Row( children: [ Icon( Icons.search, color: darkGreyColor.withOpacity(0.3), ), SizedBox( width: 12, ), Text( 'Search For Plants ', style: TextStyle( fontWeight: FontWeight.w400, fontSize: 14, color: darkGreyColor.withOpacity(0.3), ), ), ], ), ), ), ), ], ) ], ), ), ); } }
0
mirrored_repositories/plant_app/lib
mirrored_repositories/plant_app/lib/pages/home_page.dart
import 'dart:ui'; import 'package:flutter/material.dart'; import 'package:plant_app/pages/articles_page.dart'; import 'package:plant_app/pages/camera_identify_page.dart'; import 'package:plant_app/pages/species_page.dart'; import 'package:plant_app/theme.dart'; import 'package:plant_app/widget/bottom_navbar.dart'; import 'package:plant_app/widget/home_category_card.dart'; import 'package:plant_app/widget/photo_card.dart'; import 'package:plant_app/widget/plant_type_card.dart'; class HomePage extends StatelessWidget { @override Widget build(BuildContext context) { return Scaffold( backgroundColor: backgroundColor, bottomNavigationBar: BottomNavbar(), body: SafeArea( child: ListView( children: [ Stack( children: [ Container( height: 172, width: double.infinity, decoration: BoxDecoration( gradient: LinearGradient( begin: Alignment.topLeft, end: Alignment.bottomRight, colors: [ linearOne, linearTwo, ], ), ), child: Stack( children: [ Positioned( top: -90, right: -40, child: Container( height: 204, width: 204, decoration: BoxDecoration( color: whiteColor.withOpacity(0.2), borderRadius: BorderRadius.circular(102), ), ), ), Positioned( top: 60, right: -40, child: Container( height: 124, width: 124, decoration: BoxDecoration( color: whiteColor.withOpacity(0.13), borderRadius: BorderRadius.circular(102), ), ), ), Positioned( bottom: -10, right: -12, child: Text( 'Home', style: TextStyle( fontSize: 67, fontWeight: FontWeight.w900, color: whiteColor.withOpacity(0.2), ), ), ), Column( children: [ SizedBox( height: 70, ), Padding( padding: EdgeInsets.symmetric(horizontal: 23), child: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( 'Hello Taylor,', style: TextStyle( fontWeight: FontWeight.bold, color: whiteColor, fontSize: 21, ), ), SizedBox( height: 9, ), Text( 'Let’s Learn More About Plants', style: TextStyle( fontSize: 14, fontWeight: FontWeight.w400, color: whiteColor.withOpacity(0.5), ), ), ], ), Image.asset( 'assets/profile.png', width: 47, height: 47, ), ], ), ) ], ), ], ), ), Container( width: double.infinity, color: backgroundColor, margin: EdgeInsets.only(top: 172), padding: EdgeInsets.only(top: 60), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Padding( padding: EdgeInsets.symmetric(horizontal: 14), child: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ InkWell( onTap: () { Navigator.push( context, MaterialPageRoute( builder: (context) { return CameraIdentifyPage(); }, ), ); }, child: HomeCategoryCard( imageUrl: 'assets/identify.png', title: 'IDENTIFY', isActive: true, ), ), InkWell( onTap: () { Navigator.push( context, MaterialPageRoute( builder: (context) { return SpeciesPage(); }, ), ); }, child: HomeCategoryCard( imageUrl: 'assets/species.png', title: 'SPECIES', isActive: false, ), ), InkWell( onTap: () { Navigator.push( context, MaterialPageRoute( builder: (context) { return ArticlesPage(); }, ), ); }, child: HomeCategoryCard( imageUrl: 'assets/articels.png', title: 'ARTICLES', isActive: false, ), ), ], ), ), Padding( padding: EdgeInsets.only(left: 23), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ SizedBox( height: 24, ), Text( 'Plant Types', style: TextStyle( fontSize: 17, fontWeight: FontWeight.bold, color: darkColor, ), ), SizedBox( height: 15, ), SingleChildScrollView( scrollDirection: Axis.horizontal, child: Row( children: [ PlantTypeCard( imageUrl: 'assets/type1.png', title: 'Home Plants', countType: '68', ), SizedBox( width: 14, ), PlantTypeCard( imageUrl: 'assets/type2.png', title: 'Huge Plants', countType: '102', ), SizedBox( width: 23, ), ], ), ), SizedBox( height: 25, ), Text( 'Photography', style: TextStyle( fontSize: 17, fontWeight: FontWeight.bold, color: darkColor, ), ), SizedBox( height: 16, ), SingleChildScrollView( scrollDirection: Axis.horizontal, child: Row( children: [ PhotoCard( imageUrl: 'assets/photo1.png', tags: '#Mini', ), SizedBox( width: 17, ), PhotoCard( imageUrl: 'assets/photo2.png', tags: '#Homely', ), SizedBox( width: 17, ), PhotoCard( imageUrl: 'assets/photo3.png', tags: '#Cute', ), SizedBox( width: 23, ), ], ), ), SizedBox( height: 20, ), ], ), ), ], ), ), Positioned( top: 148, child: Container( margin: EdgeInsets.symmetric(horizontal: 23), width: MediaQuery.of(context).size.width - (2 * 23), height: 50, decoration: BoxDecoration( color: whiteColor, borderRadius: BorderRadius.circular(25), boxShadow: [ BoxShadow( color: darkGreyColor.withOpacity(0.1), blurRadius: 1, spreadRadius: 1, offset: Offset(1, 1), ) ], ), child: Padding( padding: EdgeInsets.symmetric(horizontal: 25), child: Row( children: [ Icon( Icons.search, color: darkGreyColor.withOpacity(0.3), ), SizedBox( width: 12, ), Text( 'Search For Plants ', style: TextStyle( fontWeight: FontWeight.w400, fontSize: 14, color: darkGreyColor.withOpacity(0.3), ), ), ], ), ), ), ), ], ) ], ), ), ); } }
0
mirrored_repositories/plant_app/lib
mirrored_repositories/plant_app/lib/pages/camera_identify_page.dart
import 'package:flutter/material.dart'; import 'package:plant_app/pages/detail_identify_page.dart'; import 'package:plant_app/theme.dart'; class CameraIdentifyPage extends StatelessWidget { @override Widget build(BuildContext context) { return Scaffold( body: Stack( children: [ Image.asset( 'assets/bg.png', width: double.infinity, height: double.infinity, fit: BoxFit.cover, ), Padding( padding: EdgeInsets.symmetric(horizontal: 30, vertical: 25), child: Column( children: [ Padding( padding: EdgeInsets.only(top: 37), child: Row( children: [ Icon( Icons.bolt, color: whiteColor, ), SizedBox( width: 2, ), Text( 'AUTO', style: TextStyle( fontWeight: FontWeight.w400, color: whiteColor, fontSize: 10, ), ), Spacer(), Text( '#', style: TextStyle( fontSize: 25, fontWeight: FontWeight.w200, color: whiteColor, ), ), SizedBox( width: 30, ), Icon( Icons.animation, color: whiteColor, ), SizedBox( width: 30, ), Icon( Icons.more_vert, color: whiteColor, ), ], ), ), Spacer(), Padding( padding: EdgeInsets.symmetric(horizontal: 5), child: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Image.asset( 'assets/flower.png', width: 40, height: 40, ), Column( children: [ InkWell( onTap: () { Navigator.push( context, MaterialPageRoute( builder: (context) { return DetailIdentifyPage( imageUrl: 'spinach.png', categoryOne: 'VEGETABLES', categoryTwo: 'HELATHY', title: 'Spinach', kingdomeClass: 'Plantee', familyClass: 'Amaranthaceae', rating: '4.5', description: 'Spinach is thought to have originated in ancient Persia (modern Iran and neighboring countries). It is not known by whom, or when, spinach was introduced to India, but the plant was subsequ ently introduced to ancient China, where it was known as "Persian vegetable"', ); }, ), ); }, child: Container( height: 63, width: 63, decoration: BoxDecoration( color: Colors.transparent, border: Border.all( color: whiteColor, ), borderRadius: BorderRadius.circular(32), ), ), ), ], ), Icon( Icons.loop, color: whiteColor, size: 30, ), ], ), ), SizedBox( height: 8, ), Padding( padding: EdgeInsets.only(top: 8, left: 10), child: Row( mainAxisAlignment: MainAxisAlignment.center, children: [ Column( children: [ Container( height: 5, width: 5, decoration: BoxDecoration( color: whiteColor, borderRadius: BorderRadius.circular(3), ), ), SizedBox( height: 10, ), Text( 'PHOTO', style: TextStyle( fontSize: 11, fontWeight: FontWeight.w300, color: whiteColor, ), ), ], ) ], ), ) ], ), ), ], ), ); } }
0
mirrored_repositories/plant_app/lib
mirrored_repositories/plant_app/lib/pages/detail_identify_page.dart
import 'package:flutter/material.dart'; import 'package:plant_app/theme.dart'; import 'package:plant_app/widget/bottom_navbar.dart'; import 'package:plant_app/widget/category_identify_bullet.dart'; class DetailIdentifyPage extends StatelessWidget { final String imageUrl; final String categoryOne; final String categoryTwo; final String title; final String rating; final String kingdomeClass; final String familyClass; final String description; DetailIdentifyPage({ this.imageUrl, this.categoryOne, this.categoryTwo, this.title, this.rating, this.kingdomeClass, this.familyClass, this.description, }); @override Widget build(BuildContext context) { return Scaffold( bottomNavigationBar: BottomNavbar(), body: SafeArea( child: ListView( children: [ Stack( children: [ Column( children: [ Stack( children: [ Container( height: 281, width: double.infinity, child: Stack( children: [ Image.asset( 'assets/$imageUrl', width: double.infinity, height: 281, fit: BoxFit.cover, ), Container( height: 281, width: double.infinity, decoration: BoxDecoration( gradient: LinearGradient( begin: Alignment.bottomCenter, end: Alignment.center, colors: [ Colors.black.withOpacity(0.5), Colors.transparent ], ), ), ), Padding( padding: EdgeInsets.symmetric( horizontal: 23, vertical: 30), child: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Icon( Icons.chevron_left, color: whiteColor, ), Icon( Icons.more_vert, color: whiteColor, ), ], ), ) ], ), ), Container( width: double.infinity, margin: EdgeInsets.only(top: 281), padding: EdgeInsets.symmetric( horizontal: 23, vertical: 25), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Row( children: [ CategoryIdentifyBullet(categoryOne), SizedBox( width: 10, ), CategoryIdentifyBullet(categoryTwo), ], ), SizedBox( height: 25, ), Text( title, style: TextStyle( fontWeight: FontWeight.bold, color: darkColor, fontSize: 27, ), ), SizedBox( height: 16, ), Row( children: [ Icon( Icons.star, color: Colors.orange, size: 17, ), Icon( Icons.star, color: Colors.orange, size: 17, ), Icon( Icons.star, color: Colors.orange, size: 17, ), Icon( Icons.star, color: Colors.orange, size: 17, ), Icon( Icons.star, color: Colors.grey, size: 17, ), SizedBox( width: 8, ), Text( rating, style: TextStyle( fontWeight: FontWeight.bold, fontSize: 13, color: darkColor, ), ), ], ), SizedBox( height: 30, ), Row( children: [ Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( 'Kingdom', style: TextStyle( fontWeight: FontWeight.w600, fontSize: 14, color: darkGreyColor.withOpacity(0.9), ), ), SizedBox( height: 12, ), Text( kingdomeClass, style: TextStyle( fontWeight: FontWeight.w400, fontSize: 14, color: darkGreyColor.withOpacity(0.5), ), ), ], ), SizedBox( width: 54, ), Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( 'Family', style: TextStyle( fontWeight: FontWeight.w600, fontSize: 14, color: darkGreyColor.withOpacity(0.9), ), ), SizedBox( height: 12, ), Text( familyClass, style: TextStyle( fontWeight: FontWeight.w400, fontSize: 14, color: darkGreyColor.withOpacity(0.5), ), ), ], ) ], ), SizedBox( height: 30, ), Text( 'Description', style: TextStyle( fontWeight: FontWeight.w600, color: darkGreyColor, fontSize: 14, ), ), SizedBox( height: 12, ), Text( description, style: TextStyle( fontWeight: FontWeight.w500, fontSize: 14, color: darkGreyColor.withOpacity(0.5), ), ), ], ), ), Positioned( top: 250, right: 20, child: Container( height: 57, width: 57, decoration: BoxDecoration( color: Color(0XFFFF6262), borderRadius: BorderRadius.circular(30), ), child: Center( child: Icon( Icons.favorite, color: whiteColor, size: 28, ), ), ), ) ], ), ], ) ], ), ], ), ), ); } }
0
mirrored_repositories/plant_app/lib
mirrored_repositories/plant_app/lib/pages/profile_page.dart
import 'package:flutter/material.dart'; import 'package:plant_app/theme.dart'; import 'package:plant_app/widget/bottom_navbar.dart'; import 'package:plant_app/widget/profile_menu.dart'; class ProfilePage extends StatelessWidget { @override Widget build(BuildContext context) { return Scaffold( bottomNavigationBar: BottomNavbar(), body: ListView( children: [ Stack( children: [ Container( height: 240, width: double.infinity, decoration: BoxDecoration( gradient: LinearGradient( begin: Alignment.topLeft, end: Alignment.bottomRight, colors: [ linearOne, linearTwo, ], ), ), ), Positioned( top: -100, right: -70, child: Container( height: 293, width: 293, decoration: BoxDecoration( color: whiteColor.withOpacity(0.1), borderRadius: BorderRadius.circular(150), ), ), ), Positioned( top: 140, right: -80, child: Container( height: 179, width: 178, decoration: BoxDecoration( color: whiteColor.withOpacity(0.1), borderRadius: BorderRadius.circular(150), ), ), ), Padding( padding: EdgeInsets.fromLTRB(23, 58, 23, 0), child: Column( children: [ Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, crossAxisAlignment: CrossAxisAlignment.start, children: [ Icon( Icons.chevron_left, color: whiteColor, size: 30, ), Image.asset( 'assets/profile.png', width: 79, height: 79, ), Icon( Icons.more_vert, color: whiteColor, size: 30, ), ], ), SizedBox( height: 15, ), Text( 'Taylor Swift', style: TextStyle( fontSize: 23, fontWeight: FontWeight.w900, color: whiteColor), ), SizedBox( height: 13, ), Row( mainAxisAlignment: MainAxisAlignment.center, children: [ Icon( Icons.location_on, color: whiteColor, size: 15, ), SizedBox( width: 7, ), Text( 'Los Angeles, California', style: TextStyle( fontWeight: FontWeight.w600, color: whiteColor.withOpacity(0.8), ), ), ], ) ], ), ), ], ), Padding( padding: EdgeInsets.fromLTRB(23, 20, 23, 0), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ ProfileMenu('ARTICLES', false), ProfileMenu('SPECIES', true), ProfileMenu('LIKES', false), ], ), SizedBox( height: 30, ), Text( 'Your Collected Plants', style: TextStyle( fontWeight: FontWeight.bold, fontSize: 17, color: darkColor, ), ), SizedBox( height: 20, ), Row( crossAxisAlignment: CrossAxisAlignment.start, children: [ Container( height: 13, width: 13, decoration: BoxDecoration( color: blueColor, borderRadius: BorderRadius.circular(8), ), child: Center( child: Container( height: 7, width: 7, decoration: BoxDecoration( color: whiteColor, borderRadius: BorderRadius.circular(4), ), ), ), ), SizedBox( width: 13, ), Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( 'Alagatre Plant', style: TextStyle( fontSize: 14, fontWeight: FontWeight.w600, color: darkColor, ), ), SizedBox( height: 6, ), Text( '02 . 01 . 2019', style: TextStyle( fontWeight: FontWeight.w500, fontSize: 12, color: darkGreyColor.withOpacity(0.5), ), ), ], ) ], ), SizedBox( height: 18, ), Container( width: double.infinity, height: 320, padding: EdgeInsets.all(10), decoration: BoxDecoration( color: whiteColor, boxShadow: [ BoxShadow( color: Colors.grey.withOpacity(0.1), blurRadius: 1, spreadRadius: 2, offset: Offset(1, 1), ) ], ), child: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Image.asset( 'assets/image1.png', width: ((MediaQuery.of(context).size.width - (2 * 23)) / 2) - 15, height: double.infinity, fit: BoxFit.cover, ), Container( width: ((MediaQuery.of(context).size.width - (2 * 23)) / 2) - 15, height: double.infinity, child: Column( children: [ Expanded( flex: 5, child: Container( padding: EdgeInsets.only(bottom: 5), child: Image.asset( 'assets/image2.png', width: double.infinity, height: double.infinity, fit: BoxFit.cover, ), ), ), Expanded( flex: 5, child: Container( padding: EdgeInsets.only(top: 5), child: Image.asset( 'assets/image3.png', width: double.infinity, height: double.infinity, fit: BoxFit.cover, ), ), ), ], ), ) ], ), ), SizedBox( height: 30, ), ], ), ), ], ), ); } }
0
mirrored_repositories/plant_app/lib
mirrored_repositories/plant_app/lib/pages/articles_page.dart
import 'package:flutter/material.dart'; import 'package:plant_app/pages/detail_articles_page.dart'; import 'package:plant_app/widget/bottom_navbar.dart'; import '../theme.dart'; class ArticlesPage extends StatelessWidget { @override Widget build(BuildContext context) { return Scaffold( backgroundColor: backgroundColor, bottomNavigationBar: BottomNavbar(), body: SafeArea( child: ListView( children: [ Stack( children: [ Container( height: 172, width: double.infinity, decoration: BoxDecoration( gradient: LinearGradient( begin: Alignment.topLeft, end: Alignment.bottomRight, colors: [ linearOne, linearTwo, ], ), ), child: Stack( children: [ Positioned( top: -90, right: -40, child: Container( height: 204, width: 204, decoration: BoxDecoration( color: whiteColor.withOpacity(0.2), borderRadius: BorderRadius.circular(102), ), ), ), Positioned( top: 60, right: -40, child: Container( height: 124, width: 124, decoration: BoxDecoration( color: whiteColor.withOpacity(0.13), borderRadius: BorderRadius.circular(102), ), ), ), Positioned( bottom: -10, right: -12, child: Text( 'Articles', style: TextStyle( fontSize: 67, fontWeight: FontWeight.w900, color: whiteColor.withOpacity(0.2), ), ), ), Padding( padding: EdgeInsets.fromLTRB(23, 41, 23, 0), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Icon( Icons.chevron_left, color: whiteColor, size: 30, ), Icon( Icons.more_vert, color: whiteColor, size: 30, ), ], ), SizedBox( height: 19, ), Text( 'Articles', style: TextStyle( fontWeight: FontWeight.w900, color: whiteColor, fontSize: 30, ), ), ], ), ), ], ), ), Container( width: double.infinity, color: backgroundColor, margin: EdgeInsets.only(top: 172), padding: EdgeInsets.only( top: 55, left: 23, right: 23, ), child: Column( children: [ Container( height: 265, width: double.infinity, decoration: BoxDecoration( color: whiteColor, borderRadius: BorderRadius.circular(10), boxShadow: [ BoxShadow( color: Colors.grey.withOpacity(0.1), blurRadius: 1, spreadRadius: 2, offset: Offset(1, 1), ) ], ), child: Column( children: [ ClipRRect( borderRadius: BorderRadius.vertical( top: Radius.circular(10), ), child: Image.asset( 'assets/articles1.png', width: double.infinity, height: 145, fit: BoxFit.cover, ), ), SizedBox( height: 15, ), Padding( padding: EdgeInsets.symmetric(horizontal: 15), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( 'David Austin, Who Breathed Life Into the Rose, Is Dead at 92', style: TextStyle( fontSize: 15, fontWeight: FontWeight.bold, color: darkColor, ), ), SizedBox( height: 15, ), Row( children: [ Image.asset( 'assets/profile1.png', width: 28, height: 28, ), SizedBox( width: 9, ), Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( 'Shivani Vora', style: TextStyle( fontWeight: FontWeight.w500, fontSize: 11, color: darkGreyColor, ), ), SizedBox( height: 4, ), Text( '2019 . 01 . 01', style: TextStyle( fontSize: 9, color: darkGreyColor .withOpacity(0.5), fontWeight: FontWeight.w500), ), ], ), Spacer(), Icon( Icons.bookmark_border, color: darkGreyColor.withOpacity(0.5), ), SizedBox( width: 25, ), Icon( Icons.favorite_border, color: darkGreyColor.withOpacity(0.5), ), ], ) ], ), ), ], ), ), SizedBox( height: 25, ), InkWell( onTap: () { Navigator.push( context, MaterialPageRoute( builder: (context) { return DetailArticlesPage(); }, ), ); }, child: Container( height: 265, width: double.infinity, decoration: BoxDecoration( color: whiteColor, borderRadius: BorderRadius.circular(10), boxShadow: [ BoxShadow( color: Colors.grey.withOpacity(0.1), blurRadius: 1, spreadRadius: 2, offset: Offset(1, 1), ) ], ), child: Column( children: [ ClipRRect( borderRadius: BorderRadius.vertical( top: Radius.circular(10), ), child: Image.asset( 'assets/articles2.png', width: double.infinity, height: 145, fit: BoxFit.cover, ), ), SizedBox( height: 15, ), Padding( padding: EdgeInsets.symmetric(horizontal: 15), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( 'Even on Urban Excursions, Finding Mother Nature\'s Charms', style: TextStyle( fontSize: 15, fontWeight: FontWeight.bold, color: darkColor, ), ), SizedBox( height: 15, ), Row( children: [ Image.asset( 'assets/profile1.png', width: 28, height: 28, ), SizedBox( width: 9, ), Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( 'Shivani Vora', style: TextStyle( fontWeight: FontWeight.w500, fontSize: 11, color: darkGreyColor, ), ), SizedBox( height: 4, ), Text( '2019 . 01 . 01', style: TextStyle( fontSize: 9, color: darkGreyColor .withOpacity(0.5), fontWeight: FontWeight.w500), ), ], ), Spacer(), Icon( Icons.bookmark_border, color: darkGreyColor.withOpacity(0.5), ), SizedBox( width: 25, ), Icon( Icons.favorite_border, color: darkGreyColor.withOpacity(0.5), ), ], ) ], ), ), ], ), ), ), SizedBox( height: 30, ), ], ), ), Positioned( top: 148, child: Container( margin: EdgeInsets.symmetric(horizontal: 23), width: MediaQuery.of(context).size.width - (2 * 23), height: 50, decoration: BoxDecoration( color: whiteColor, borderRadius: BorderRadius.circular(25), boxShadow: [ BoxShadow( color: darkGreyColor.withOpacity(0.1), blurRadius: 1, spreadRadius: 1, offset: Offset(1, 1), ) ], ), child: Padding( padding: EdgeInsets.symmetric(horizontal: 25), child: Row( children: [ Icon( Icons.search, color: darkGreyColor.withOpacity(0.3), ), SizedBox( width: 12, ), Text( 'Search For Plants ', style: TextStyle( fontWeight: FontWeight.w400, fontSize: 14, color: darkGreyColor.withOpacity(0.3), ), ), ], ), ), ), ), ], ) ], ), ), ); } }
0
mirrored_repositories/plant_app/lib
mirrored_repositories/plant_app/lib/pages/detail_articles_page.dart
import 'package:flutter/material.dart'; import 'package:plant_app/widget/bottom_navbar.dart'; import 'package:plant_app/widget/category_identify_bullet.dart'; import '../theme.dart'; class DetailArticlesPage extends StatelessWidget { @override Widget build(BuildContext context) { return Scaffold( bottomNavigationBar: BottomNavbar(), body: SafeArea( child: ListView( children: [ Stack( children: [ Column( children: [ Stack( children: [ Container( height: 281, width: double.infinity, child: Stack( children: [ Image.asset( 'assets/articles_detail.png', width: double.infinity, height: 281, fit: BoxFit.cover, ), Container( height: 281, width: double.infinity, decoration: BoxDecoration( gradient: LinearGradient( begin: Alignment.bottomCenter, end: Alignment.center, colors: [ Colors.black.withOpacity(0.5), Colors.transparent ], ), ), ), Padding( padding: EdgeInsets.symmetric( horizontal: 23, vertical: 30), child: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Icon( Icons.chevron_left, color: whiteColor, ), Icon( Icons.more_vert, color: whiteColor, ), ], ), ) ], ), ), Container( width: double.infinity, margin: EdgeInsets.only(top: 281), padding: EdgeInsets.symmetric( horizontal: 23, vertical: 25), child: Column( children: [ Row( children: [ CategoryIdentifyBullet('VEGETABLES'), SizedBox( width: 10, ), CategoryIdentifyBullet('GARDEN'), ], ), SizedBox( height: 25, ), Text( 'Even on Urban Excursions, Finding Mother Nature\'s Charms', style: TextStyle( fontWeight: FontWeight.bold, color: darkColor, fontSize: 20, ), ), SizedBox( height: 19, ), Row( children: [ Image.asset( 'assets/profile2.png', width: 37, height: 37, ), SizedBox( width: 9, ), Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( 'Shylla Monic', style: TextStyle( fontWeight: FontWeight.w500, color: darkGreyColor, fontSize: 14, ), ), SizedBox( height: 5, ), Text( '2019 . 01 . 01', style: TextStyle( fontWeight: FontWeight.w500, color: darkGreyColor.withOpacity(0.5), fontSize: 12, ), ), ], ), Spacer(), Container( height: 30, width: 73, padding: EdgeInsets.symmetric(horizontal: 14), decoration: BoxDecoration( color: lightGreenColor, borderRadius: BorderRadius.circular(15), ), child: Center( child: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Icon( Icons.add, color: whiteColor, size: 17, ), Text( 'Follow', style: TextStyle( fontWeight: FontWeight.w600, color: whiteColor, fontSize: 10, ), ), ], ), ), ) ], ), SizedBox( height: 26, ), Text( 'Public parks aside, getting a dose of nature can be a tricky task during an urban escape. But nature should and can fit into that city getaway, according to Kally Ellis, the founder of the London florist company McQueens and the in-house florist for the Maybourne Hotel Group. “Connecting with the natural world wherever you are is a great antidote to jet lag and travel tiredness,” she said. “Plants and flowers can refresh us, boost our energy and help us recalibrate.”', style: TextStyle( fontSize: 14, color: darkGreyColor.withOpacity(0.5), fontWeight: FontWeight.w500, ), textAlign: TextAlign.justify, ), ], ), ), Positioned( top: 250, right: 20, child: Container( height: 57, width: 57, decoration: BoxDecoration( color: Color(0XFFFF6262), borderRadius: BorderRadius.circular(30), ), child: Center( child: Icon( Icons.favorite, color: whiteColor, size: 28, ), ), ), ) ], ), ], ) ], ), ], ), ), ); } }
0
mirrored_repositories/plant_app/lib
mirrored_repositories/plant_app/lib/pages/boarding_page.dart
import 'package:flutter/material.dart'; import 'package:plant_app/pages/login_page.dart'; import 'package:plant_app/theme.dart'; import 'package:plant_app/widget/onboard_bullet.dart'; class BoardingPage extends StatelessWidget { final double widthImage; final double heightImage; final String imageUrl; final String title; final String subTitle; final bool isBullOne; final bool isBullTwo; final bool isBullThree; final String textButton; final String isAction; BoardingPage({ this.widthImage, this.heightImage, this.imageUrl, this.title, this.subTitle, this.isBullOne, this.isBullTwo, this.isBullThree, this.textButton, this.isAction, }); @override Widget build(BuildContext context) { return Scaffold( backgroundColor: backgroundColor, body: Center( child: Column( mainAxisAlignment: MainAxisAlignment.center, children: [ Image.asset( imageUrl, width: widthImage, height: heightImage, ), SizedBox( height: 63, ), Text( title, style: TextStyle( fontSize: 19, fontWeight: FontWeight.bold, color: darkColor, ), ), SizedBox( height: 23, ), Text( subTitle, style: TextStyle( fontSize: 13, fontWeight: FontWeight.w400, color: darkGreyColor, ), textAlign: TextAlign.center, ), SizedBox( height: 55, ), Row( mainAxisAlignment: MainAxisAlignment.center, children: [ OnboardBullet(isBullOne), SizedBox( width: 9, ), OnboardBullet(isBullTwo), SizedBox( width: 9, ), OnboardBullet(isBullThree), ], ), SizedBox( height: 54, ), Padding( padding: EdgeInsets.symmetric( horizontal: defaultMargin, ), child: Container( width: double.infinity, height: 50, child: FlatButton( onPressed: () { (isAction == "nextOne") ? Navigator.push( context, MaterialPageRoute( builder: (context) { return BoardingPage( widthImage: 286.0, heightImage: 277.14, imageUrl: 'assets/illustration2.png', title: 'Learn Many Plants Species', subTitle: 'Let\'s learn about the many plant species that\nexist in this world', isBullOne: false, isBullTwo: true, isBullThree: false, textButton: 'NEXT', isAction: 'nextLast', ); }, ), ) : (isAction == "nextLast") ? Navigator.push( context, MaterialPageRoute( builder: (context) { return BoardingPage( widthImage: 317.0, heightImage: 272.14, imageUrl: 'assets/illustration3.png', title: 'Read Many Articles About Plant', subTitle: 'Let\'s learn more about beautiful plants and read\nmany articles about plants and gardening', isBullOne: false, isBullTwo: false, isBullThree: true, textButton: 'LOGIN', isAction: 'signIn', ); }, ), ) : Navigator.push( context, MaterialPageRoute( builder: (context) { return LoginPage(); }, ), ); }, color: lightGreenColor, child: Text( textButton, style: TextStyle( fontSize: 15, color: whiteColor, fontWeight: FontWeight.bold, ), ), shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(3), ), ), ), ), ], ), ), ); } }
0
mirrored_repositories/plant_app/lib
mirrored_repositories/plant_app/lib/pages/cactus_page.dart
import 'package:flutter/material.dart'; import 'package:plant_app/widget/bottom_navbar.dart'; import 'package:plant_app/widget/cactus_card.dart'; import '../theme.dart'; import 'detail_identify_page.dart'; class CactusPage extends StatelessWidget { @override Widget build(BuildContext context) { return Scaffold( backgroundColor: backgroundColor, bottomNavigationBar: BottomNavbar(), body: SafeArea( child: ListView( children: [ Stack( children: [ Container( height: 172, width: double.infinity, decoration: BoxDecoration( gradient: LinearGradient( begin: Alignment.topLeft, end: Alignment.bottomRight, colors: [ linearOne, linearTwo, ], ), ), child: Stack( children: [ Positioned( top: -90, right: -40, child: Container( height: 204, width: 204, decoration: BoxDecoration( color: whiteColor.withOpacity(0.2), borderRadius: BorderRadius.circular(102), ), ), ), Positioned( top: 60, right: -40, child: Container( height: 124, width: 124, decoration: BoxDecoration( color: whiteColor.withOpacity(0.13), borderRadius: BorderRadius.circular(102), ), ), ), Positioned( bottom: -10, right: -12, child: Text( 'Cactus', style: TextStyle( fontSize: 67, fontWeight: FontWeight.w900, color: whiteColor.withOpacity(0.2), ), ), ), Padding( padding: EdgeInsets.fromLTRB(23, 41, 23, 0), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Icon( Icons.chevron_left, color: whiteColor, size: 30, ), Icon( Icons.more_vert, color: whiteColor, size: 30, ), ], ), SizedBox( height: 19, ), Text( 'Cactus', style: TextStyle( fontWeight: FontWeight.w900, color: whiteColor, fontSize: 30, ), ), ], ), ), ], ), ), Container( width: double.infinity, color: backgroundColor, margin: EdgeInsets.only(top: 172), padding: EdgeInsets.only( top: 55, left: 23, right: 23, ), child: Column( children: [ CactusCard('cactus1.png', 'Red Cactus'), SizedBox( height: 35, ), CactusCard('cactus2.png', 'Fat Cactus'), SizedBox( height: 35, ), InkWell( onTap: () { Navigator.push( context, MaterialPageRoute( builder: (context) { return DetailIdentifyPage( imageUrl: 'circle_cactus.png', categoryOne: 'DANGER', categoryTwo: 'DECORATION', title: 'Circle Cactus', kingdomeClass: 'Plantee', familyClass: 'Cactaceae', rating: '4.1', description: 'The word "cactus" derives, through Latin, from the Ancient Greek κάκτος, kaktos, a name orig inally used by Theophrastus for a spiny plant whose identity is not certain. Cacti occur in a wide range of shapes and sizes. Most cacti live in habitats subject to at least some drought. ', ); }, ), ); }, child: CactusCard('cactus3.png', 'Circle Cactus'), ), SizedBox( height: 35, ), ], ), ), Positioned( top: 148, child: Container( margin: EdgeInsets.symmetric(horizontal: 23), width: MediaQuery.of(context).size.width - (2 * 23), height: 50, decoration: BoxDecoration( color: whiteColor, borderRadius: BorderRadius.circular(25), boxShadow: [ BoxShadow( color: darkGreyColor.withOpacity(0.1), blurRadius: 1, spreadRadius: 1, offset: Offset(1, 1), ) ], ), child: Padding( padding: EdgeInsets.symmetric(horizontal: 25), child: Row( children: [ Icon( Icons.search, color: darkGreyColor.withOpacity(0.3), ), SizedBox( width: 12, ), Text( 'Search For Plants ', style: TextStyle( fontWeight: FontWeight.w400, fontSize: 14, color: darkGreyColor.withOpacity(0.3), ), ), ], ), ), ), ), ], ) ], ), ), ); } }
0
mirrored_repositories/plant_app/lib
mirrored_repositories/plant_app/lib/pages/login_page.dart
import 'package:flutter/material.dart'; import 'package:plant_app/pages/home_page.dart'; import 'package:plant_app/theme.dart'; class LoginPage extends StatelessWidget { @override Widget build(BuildContext context) { return Scaffold( backgroundColor: backgroundColor, body: Padding( padding: EdgeInsets.only( top: 61, left: defaultMargin, right: defaultMargin, ), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Row( mainAxisAlignment: MainAxisAlignment.start, children: [ Icon( Icons.chevron_left, color: darkGreyColor.withOpacity(0.4), ), ], ), SizedBox( height: 25, ), Padding( padding: EdgeInsets.only(left: 7), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( 'Hello', style: TextStyle( fontSize: 30, fontWeight: FontWeight.bold, color: darkColor, ), ), SizedBox( height: 10, ), Text( 'Let’s Learn More About Plants', style: TextStyle( fontSize: 16, color: darkGreyColor, fontWeight: FontWeight.w400, ), ), SizedBox( height: 25, ), Text( 'Username', style: TextStyle( fontSize: 12, fontWeight: FontWeight.w500, color: darkGreyColor.withOpacity(0.5), ), ), SizedBox( height: 14, ), Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Text( 'Taylor Swift ', style: TextStyle( fontSize: 17, color: darkColor, fontWeight: FontWeight.w500, ), ), Icon( Icons.done, color: lightGreenColor, ), ], ), SizedBox( height: 3, ), Divider( color: lightGreenColor, ), SizedBox( height: 30, ), Text( 'Password', style: TextStyle( fontSize: 12, fontWeight: FontWeight.w500, color: darkGreyColor.withOpacity(0.5), ), ), SizedBox( height: 11, ), Divider( color: darkGreyColor.withOpacity(0.7), ), SizedBox( height: 29, ), Row( children: [ Container( height: 13, width: 13, decoration: BoxDecoration( border: Border.all( color: darkGreyColor.withOpacity(0.5), ), ), ), SizedBox( width: 7, ), Text( 'Remember me', style: TextStyle( fontSize: 11, color: darkGreyColor.withOpacity(0.7), fontWeight: FontWeight.w400, ), ), Spacer(), Text( 'Forgot Password?', style: TextStyle( fontSize: 11, color: darkGreyColor.withOpacity(0.7), fontWeight: FontWeight.w400, ), ), ], ), SizedBox( height: 39, ), Container( width: double.infinity, height: 50, child: FlatButton( onPressed: () { Navigator.push( context, MaterialPageRoute( builder: (context) { return HomePage(); }, ), ); }, color: lightGreenColor, child: Text( 'LOGIN', style: TextStyle( fontSize: 15, fontWeight: FontWeight.bold, color: whiteColor, ), ), shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(3), ), ), ), SizedBox( height: 20, ), Row( mainAxisAlignment: MainAxisAlignment.center, children: [ Text.rich( TextSpan( text: 'Don’t Have Account?\t', style: TextStyle( fontSize: 12, fontWeight: FontWeight.w400, color: darkGreyColor.withOpacity(0.6), ), children: [ TextSpan( text: 'Sign Up', style: TextStyle( fontSize: 12, fontWeight: FontWeight.bold, color: lightGreenColor, ), ) ], ), ), ], ) ], ), ), ], ), ), ); } }
0
mirrored_repositories/plant_app/lib
mirrored_repositories/plant_app/lib/widget/alphabet_filter.dart
import 'package:flutter/material.dart'; import '../theme.dart'; class AlphabetFilter extends StatelessWidget { final String title; AlphabetFilter(this.title); @override Widget build(BuildContext context) { return Text( title, style: TextStyle( fontSize: 14, color: darkGreyColor, fontWeight: FontWeight.w600, ), ); } }
0
mirrored_repositories/plant_app/lib
mirrored_repositories/plant_app/lib/widget/photo_card.dart
import 'package:flutter/material.dart'; import '../theme.dart'; class PhotoCard extends StatelessWidget { final String imageUrl; final String tags; PhotoCard({ this.imageUrl, this.tags, }); @override Widget build(BuildContext context) { return Container( height: 144, width: 126, decoration: BoxDecoration( borderRadius: BorderRadius.circular(3), ), child: Stack( children: [ ClipRRect( borderRadius: BorderRadius.circular(3), child: Image.asset( imageUrl, width: double.infinity, height: double.infinity, ), ), Padding( padding: EdgeInsets.only(top: 110), child: Row( mainAxisAlignment: MainAxisAlignment.start, children: [ Container( height: 20, width: 50, color: whiteColor.withOpacity(0.6), child: Center( child: Text( tags, style: TextStyle( fontSize: 10, fontWeight: FontWeight.w500, ), ), ), ) ], ), ) ], ), ); } }
0
mirrored_repositories/plant_app/lib
mirrored_repositories/plant_app/lib/widget/bottom_navbar.dart
import 'package:curved_navigation_bar/curved_navigation_bar.dart'; import 'package:flutter/material.dart'; import 'package:plant_app/pages/profile_page.dart'; import 'package:plant_app/theme.dart'; class BottomNavbar extends StatelessWidget { @override Widget build(BuildContext context) { return Container( width: double.infinity, height: 85, child: CurvedNavigationBar( backgroundColor: lightGreenColor, animationDuration: Duration(milliseconds: 75), items: <Widget>[ Icon( Icons.home, size: 22, color: lightGreenColor, ), Icon( Icons.add, size: 22, color: lightGreenColor, ), InkWell( onTap: () { Navigator.push( context, MaterialPageRoute( builder: (context) { return ProfilePage(); }, ), ); }, child: Icon( Icons.person_outlined, size: 22, color: lightGreenColor, ), ), ], onTap: (index) { //Handle button tap }, ), ); } }
0
mirrored_repositories/plant_app/lib
mirrored_repositories/plant_app/lib/widget/category_identify_bullet.dart
import 'package:flutter/material.dart'; class CategoryIdentifyBullet extends StatelessWidget { final String title; CategoryIdentifyBullet(this.title); @override Widget build(BuildContext context) { return Container( padding: EdgeInsets.symmetric(horizontal: 13, vertical: 5), decoration: BoxDecoration( color: Color(0XFF2F91EB).withOpacity(0.1), borderRadius: BorderRadius.circular(4), ), child: Center( child: Text( title, style: TextStyle( fontWeight: FontWeight.bold, fontSize: 12, color: Color(0XFF2F91EB), ), ), ), ); } }
0
mirrored_repositories/plant_app/lib
mirrored_repositories/plant_app/lib/widget/content_title.dart
import 'package:flutter/material.dart'; import '../theme.dart'; class ContentTitle extends StatelessWidget { final String title; final bool isTitle; ContentTitle(this.title, this.isTitle); @override Widget build(BuildContext context) { return Text( title, style: TextStyle( fontWeight: isTitle ? FontWeight.w600 : FontWeight.w500, color: isTitle ? lightGreenColor : darkGreyColor, fontSize: isTitle ? 17 : 14, ), textAlign: TextAlign.left, ); } }
0
mirrored_repositories/plant_app/lib
mirrored_repositories/plant_app/lib/widget/home_category_card.dart
import 'package:flutter/material.dart'; import '../theme.dart'; class HomeCategoryCard extends StatelessWidget { final String imageUrl; final String title; final isActive; HomeCategoryCard({ this.imageUrl, this.title, this.isActive, }); @override Widget build(BuildContext context) { return Container( height: 76, width: ((MediaQuery.of(context).size.width - (2 * defaultMargin)) / 3) - 11, decoration: BoxDecoration( color: isActive ? lightGreenColor : backgroundColor, borderRadius: BorderRadius.circular(3), boxShadow: [ BoxShadow( color: isActive ? lightGreenColor.withOpacity(0.4) : darkGreyColor.withOpacity(0.1), blurRadius: 5, spreadRadius: 3, ) ], ), child: Center( child: Column( mainAxisAlignment: MainAxisAlignment.center, children: [ Image.asset( imageUrl, width: 21, height: 21, color: isActive ? whiteColor : lightGreenColor, ), SizedBox( height: 9, ), Text( title, style: TextStyle( fontSize: 10, fontWeight: FontWeight.w600, color: isActive ? whiteColor : darkColor.withOpacity(0.8), ), ), ], ), ), ); } }
0
mirrored_repositories/plant_app/lib
mirrored_repositories/plant_app/lib/widget/plant_type_card.dart
import 'package:flutter/material.dart'; import '../theme.dart'; class PlantTypeCard extends StatelessWidget { final String imageUrl; final String title; final String countType; PlantTypeCard({ this.imageUrl, this.title, this.countType, }); @override Widget build(BuildContext context) { return Container( width: 299, height: 160, decoration: BoxDecoration( borderRadius: BorderRadius.circular(3), ), child: Stack( children: [ ClipRRect( borderRadius: BorderRadius.circular(3), child: Image.asset( imageUrl, width: double.infinity, height: double.infinity, fit: BoxFit.cover, ), ), Container( width: double.infinity, height: double.infinity, color: Color(0XFF3D3D3D).withOpacity(0.32), ), Padding( padding: EdgeInsets.only( left: 13, bottom: 16, ), child: Column( mainAxisAlignment: MainAxisAlignment.end, crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( title, style: TextStyle( fontSize: 18, fontWeight: FontWeight.bold, color: whiteColor.withOpacity(0.8), ), ), SizedBox( height: 3, ), Text( countType, style: TextStyle( fontSize: 12, color: whiteColor.withOpacity(0.5), fontWeight: FontWeight.w400, ), ) ], ), ) ], ), ); } }
0
mirrored_repositories/plant_app/lib
mirrored_repositories/plant_app/lib/widget/onboard_bullet.dart
import 'package:flutter/material.dart'; import '../theme.dart'; class OnboardBullet extends StatelessWidget { final bool isActive; OnboardBullet(this.isActive); @override Widget build(BuildContext context) { return Container( height: 7, width: 7, decoration: BoxDecoration( color: isActive ? lightGreenColor : darkGreyColor.withOpacity(0.2), borderRadius: BorderRadius.circular(3.5), ), ); } }
0
mirrored_repositories/plant_app/lib
mirrored_repositories/plant_app/lib/widget/profile_menu.dart
import 'package:flutter/material.dart'; import '../theme.dart'; class ProfileMenu extends StatelessWidget { final String title; final bool isActive; ProfileMenu( this.title, this.isActive, ); @override Widget build(BuildContext context) { return Container( padding: EdgeInsets.symmetric(horizontal: 26, vertical: 9), decoration: BoxDecoration( color: isActive ? blueColor : Colors.transparent, borderRadius: BorderRadius.circular(20), ), child: Text( title, style: TextStyle( fontSize: 12, fontWeight: FontWeight.bold, color: isActive ? whiteColor : darkGreyColor.withOpacity(0.3), ), ), ); } }
0
mirrored_repositories/plant_app/lib
mirrored_repositories/plant_app/lib/widget/cactus_card.dart
import 'package:flutter/material.dart'; import '../theme.dart'; class CactusCard extends StatelessWidget { final String imageUrl; final String title; CactusCard( this.imageUrl, this.title, ); @override Widget build(BuildContext context) { return Row( children: [ Container( height: 139, width: 139, padding: EdgeInsets.all(7), decoration: BoxDecoration( color: whiteColor, borderRadius: BorderRadius.circular(3), boxShadow: [ BoxShadow( color: Colors.grey.withOpacity(0.1), blurRadius: 1, spreadRadius: 2, offset: Offset(1, 1), ) ], ), child: Image.asset( 'assets/$imageUrl', width: double.infinity, height: double.infinity, ), ), SizedBox( width: 20, ), Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( title, style: TextStyle( fontWeight: FontWeight.bold, color: darkColor, fontSize: 17, ), ), SizedBox( height: 10, ), Row( children: [ Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( 'KINGDOM', style: TextStyle( fontWeight: FontWeight.w500, color: darkGreyColor.withOpacity(0.5), fontSize: 12, ), ), SizedBox( height: 5, ), Text( 'Plantee', style: TextStyle( fontWeight: FontWeight.w500, color: darkGreyColor, fontSize: 12, ), ), ], ), SizedBox( width: 21, ), Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( 'FAMILY', style: TextStyle( fontWeight: FontWeight.w500, color: darkGreyColor.withOpacity(0.5), fontSize: 12, ), ), SizedBox( height: 5, ), Text( 'Cactaceae', style: TextStyle( fontWeight: FontWeight.w500, color: darkGreyColor, fontSize: 12, ), ), ], ), ], ), SizedBox( height: 10, ), Text( 'DESCRIPTION', style: TextStyle( fontWeight: FontWeight.w500, color: darkGreyColor.withOpacity(0.5), fontSize: 12, ), ), SizedBox( height: 5, ), Text( 'Cactus spines are produced\nfrom specialized structures...', style: TextStyle( fontWeight: FontWeight.w500, color: darkGreyColor, fontSize: 12, ), ), ], ) ], ); } }
0
mirrored_repositories/plant_app
mirrored_repositories/plant_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_test/flutter_test.dart'; import 'package:plant_app/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/rakshak
mirrored_repositories/rakshak/lib/main.dart
import 'package:flutter/material.dart'; import 'package:rakshak/screens/sos_screen.dart'; import 'package:rakshak/screens/newContactScreen.dart'; void main() { runApp(MyApp()); } class MyApp extends StatelessWidget { @override Widget build(BuildContext context) { return MaterialApp( initialRoute: SOSScreen.id, routes: { SOSScreen.id: (context) => SOSScreen(), newContact.id: (context) => newContact(), }, ); } }
0
mirrored_repositories/rakshak/lib
mirrored_repositories/rakshak/lib/screens/newContactScreen.dart
import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; class newContact extends StatefulWidget { static const String id = 'newContact'; @override _newContactState createState() => _newContactState(); } class _newContactState extends State<newContact> { List<String> people = []; TextEditingController _controllerPeople = new TextEditingController(); TextEditingController _controllermsg = new TextEditingController(); String msg = null; Widget _phoneTile(String name) { return Padding( padding: const EdgeInsets.all(3.0), child: Container( decoration: BoxDecoration( border: Border( bottom: BorderSide(color: Colors.grey[300]), top: BorderSide(color: Colors.grey[300]), left: BorderSide(color: Colors.grey[300]), right: BorderSide(color: Colors.grey[300]), )), child: Padding( padding: EdgeInsets.all(4.0), child: Column( mainAxisAlignment: MainAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.center, mainAxisSize: MainAxisSize.min, children: <Widget>[ IconButton( icon: Icon(Icons.close), onPressed: () => setState(() => people.remove(name)), ), Padding( padding: const EdgeInsets.all(0.0), child: Text( name, textScaleFactor: 1.0, style: TextStyle(fontSize: 12.0), ), ) ], ), )), ); } @override Widget build(BuildContext context) { return MaterialApp( home: Scaffold( appBar: AppBar( title: const Text('Add Contacts and Message'), backgroundColor: Color(0xFF8F4FA0), ), body: ListView( children: <Widget>[ people == null || people.isEmpty ? Container( height: 0.0, ) : Container( height: 90.0, child: Padding( padding: const EdgeInsets.all(3.0), child: ListView( scrollDirection: Axis.horizontal, children: List<Widget>.generate(people.length, (int index) { return _phoneTile(people[index]); }), ), ), ), ListTile( leading: Icon(Icons.people), title: TextField( controller: _controllerPeople, decoration: InputDecoration(labelText: "Add Phone Number"), keyboardType: TextInputType.number, onChanged: (String value) => setState(() {}), ), trailing: IconButton( icon: Icon(Icons.add), onPressed: _controllerPeople.text.isEmpty ? null : () => setState(() { people.add(_controllerPeople.text.toString()); _controllerPeople.clear(); print(people); }), ), ), Divider(), ListTile( leading: Icon(Icons.message), title: TextField( decoration: InputDecoration(labelText: " Add Message"), controller: _controllermsg, onChanged: (String value) => setState(() { msg = _controllermsg.text; print(msg); }), ), ), Divider(), Padding( padding: EdgeInsets.fromLTRB(15, 8, 15, 8), child: FlatButton( textColor: Colors.white, padding: EdgeInsets.all(12), onPressed: () { Navigator.of(context).pop(); }, child: Text( 'Save ', style: TextStyle(fontWeight: FontWeight.bold, fontSize: 20), ), color: Colors.teal, ), ) ], ), ), ); } }
0
mirrored_repositories/rakshak/lib
mirrored_repositories/rakshak/lib/screens/sos_screen.dart
import 'package:flutter/material.dart'; import 'package:shake/shake.dart'; import 'package:sendsms/sendsms.dart'; import 'package:geolocator/geolocator.dart'; import 'newContactScreen.dart'; class SOSScreen extends StatefulWidget { static const String id = 'SOSScreen'; @override _SOSScreenState createState() => _SOSScreenState(); } class _SOSScreenState extends State<SOSScreen> { Position position; @override void initState() { lat_long(); ShakeDetector.autoStart(onPhoneShake: () { sseenndd(); }); super.initState(); } void lat_long() async { try { position = await getCurrentPosition(desiredAccuracy: LocationAccuracy.high); print(position); } catch (e) { print(e); } } void sseenndd() async { String phoneNumber = "+918340792564"; String message = "$position"; await Sendsms.onGetPermission(); setState(() async { if (await Sendsms.hasPermission()) { await Sendsms.onSendSMS(phoneNumber, message); } }); } @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( title: Text( 'RAKSHAK', style: TextStyle(fontWeight: FontWeight.w900, fontSize: 26), ), backgroundColor: Colors.black45, ), backgroundColor: Color(0xFF610000), body: SafeArea( child: Column( mainAxisAlignment: MainAxisAlignment.spaceAround, crossAxisAlignment: CrossAxisAlignment.center, children: [ Text( 'Shake To Send Text', style: TextStyle( fontFamily: 'Lemonada', color: Colors.white, fontSize: 26.0, fontWeight: FontWeight.bold, ), ), Container( height: 250.0, decoration: BoxDecoration( color: Color(0xFF910000), shape: BoxShape.circle, border: Border.all( color: Color(0xFF910000), width: 20.0, ), ), child: Center( child: Container( height: 180.0, width: 180.0, decoration: BoxDecoration( color: Color(0xFFDDDCDC), shape: BoxShape.circle, ), child: FlatButton( shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(100.0)), onPressed: () { setState(() { lat_long(); sseenndd(); }); }, child: Center( child: Text( 'Press', style: TextStyle( color: Color(0xFF777777), fontSize: 40.0, fontWeight: FontWeight.bold, ), ), ), ), ), ), ), Container( height: 80.0, width: 170.0, decoration: BoxDecoration( color: Color(0xFFDDDCDC), borderRadius: BorderRadius.circular(50.0), border: Border.all( color: Color(0xFFE71626), width: 10.0, ), ), child: Row( mainAxisAlignment: MainAxisAlignment.spaceAround, crossAxisAlignment: CrossAxisAlignment.center, children: [ IconButton( icon: Icon( Icons.person_add, size: 35.0, color: Color(0xFF777777), ), onPressed: () { Navigator.push( context, MaterialPageRoute( builder: (context) => newContact(), ), ); }, ), IconButton( icon: Icon( Icons.settings, size: 35.0, color: Color(0xFF777777), ), onPressed: () { print('Setting'); }, ), ], ), ), ], ), ), ); ; } }
0
mirrored_repositories/rakshak
mirrored_repositories/rakshak/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:rakshak/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/Chicken-Nugget-Clicker-App
mirrored_repositories/Chicken-Nugget-Clicker-App/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: 'AIzaSyDyI0LcDLro4w0td1teQHJ6T5jslMi1Xtk', appId: '1:650298688266:web:9ef949601cd910286ab0f3', messagingSenderId: '650298688266', projectId: 'chicken-nugget-clicker-acff2', authDomain: 'chicken-nugget-clicker-acff2.firebaseapp.com', storageBucket: 'chicken-nugget-clicker-acff2.appspot.com', ); static const FirebaseOptions android = FirebaseOptions( apiKey: 'AIzaSyC4W80Wv0UAe-5qYG4USc4R5MR3P9jMBiw', appId: '1:650298688266:android:a55b3248d6cd50d66ab0f3', messagingSenderId: '650298688266', projectId: 'chicken-nugget-clicker-acff2', storageBucket: 'chicken-nugget-clicker-acff2.appspot.com', ); static const FirebaseOptions ios = FirebaseOptions( apiKey: 'AIzaSyAQ3mQ47FBIKn1TuA5XRUFtugz3BJYy08I', appId: '1:650298688266:ios:051b584d86eb94d86ab0f3', messagingSenderId: '650298688266', projectId: 'chicken-nugget-clicker-acff2', storageBucket: 'chicken-nugget-clicker-acff2.appspot.com', iosBundleId: 'com.example.app', ); static const FirebaseOptions macos = FirebaseOptions( apiKey: 'AIzaSyAQ3mQ47FBIKn1TuA5XRUFtugz3BJYy08I', appId: '1:650298688266:ios:051b584d86eb94d86ab0f3', messagingSenderId: '650298688266', projectId: 'chicken-nugget-clicker-acff2', storageBucket: 'chicken-nugget-clicker-acff2.appspot.com', iosBundleId: 'com.example.app', ); }
0
mirrored_repositories/Chicken-Nugget-Clicker-App
mirrored_repositories/Chicken-Nugget-Clicker-App/lib/main.dart
import 'package:flutter/material.dart'; import 'package:firebase_core/firebase_core.dart'; import 'package:firebase_auth/firebase_auth.dart'; import 'settings_page.dart'; import 'package:cloud_firestore/cloud_firestore.dart'; import 'package:font_awesome_flutter/font_awesome_flutter.dart'; import 'package:google_sign_in/google_sign_in.dart'; import 'package:shared_preferences/shared_preferences.dart'; import 'package:flutter/foundation.dart'; import 'package:flutter/services.dart'; import 'dart:async'; void main() async { WidgetsFlutterBinding.ensureInitialized(); await Firebase.initializeApp(); SharedPreferences prefs = await SharedPreferences.getInstance(); bool isLoggedIn = prefs.getBool('isLoggedIn') ?? false; runApp(MaterialApp(home: isLoggedIn ? const ChickenNuggetClickerApp() : const SignIn(), )); } class ChickenNuggetClickerApp extends StatefulWidget { const ChickenNuggetClickerApp({Key? key}) : super(key: key); @override _ChickenNuggetClickerAppState createState() => _ChickenNuggetClickerAppState(); } class _ChickenNuggetClickerAppState extends State<ChickenNuggetClickerApp> { int counter = 0; bool isPopped = false; bool isSettingsPageActive = false; late User? _user; @override void initState() { super.initState(); _initAuth(); } Future<void> _initAuth() async { FirebaseAuth.instance.authStateChanges().listen((User? user) async { setState(() { _user = user; }); if (_user != null) { // Load user's clicks from Firestore final docSnapshot = await FirebaseFirestore.instance .collection('users') .doc(_user!.uid) .collection('clicks') .get(); setState(() { counter = docSnapshot.docs.length; }); } }); } void _handleButtonClick() { setState(() { counter++; isPopped = true; }); Future.delayed(const Duration(milliseconds: 30), () { setState(() { isPopped = false; }); }); if (_user != null) { // Log click to Firestore FirebaseFirestore.instance.collection('users').doc(_user!.uid).collection('clicks').add({ 'timestamp': DateTime.now(), }); } } @override Widget build(BuildContext context) { return MaterialApp( home: Scaffold( appBar: AppBar( backgroundColor: Colors.brown, title: const Text('Click!'), leadingWidth: 90, toolbarHeight: 60, leading: Container( margin: const EdgeInsets.only(left: 2), child: IconButton( icon: const Icon(Icons.ios_share_outlined, color: Colors.black, size: 40,), onPressed: () {}, ), ), actions: [ IconButton( icon: const Icon(Icons.login_outlined, color: Colors.black, size: 30,), onPressed: () { Navigator.push( context, MaterialPageRoute(builder: (_) => const SignIn()), ); } ), ], ), backgroundColor: const Color.fromRGBO(199, 144, 83, 1), body: Builder( builder: (BuildContext context) { return Column( children: [ Align( child: Padding( padding: const EdgeInsets.only(top: 160.0), child: Column( mainAxisAlignment: MainAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.center, children: [ GestureDetector( onTap: _handleButtonClick, child: AnimatedContainer( duration: const Duration(milliseconds: 30), width: isPopped ? 280 : 300, height: isPopped ? 280 : 300, child: Padding( padding: const EdgeInsets.only(bottom: 40), child: Image.asset( 'assets/nugget.png', fit: BoxFit.cover, ), ), ), ), const SizedBox(height: 2), Text( isPopped ? 'Nuggets: $counter' : 'Nuggets: $counter', style: const TextStyle( fontSize: 20, fontWeight: FontWeight.bold, color: Colors.white, ), ), ], ), ), ), Expanded( child: Align( alignment: Alignment.bottomCenter, child: Container( color: Colors.brown, padding: const EdgeInsets.all(10), child: Row( mainAxisAlignment: MainAxisAlignment.spaceEvenly, children: [ Expanded( child: Container( decoration: BoxDecoration( borderRadius: BorderRadius.circular(50), ), height: 60, child: TextButton( style: ButtonStyle( shape: MaterialStateProperty.all<CircleBorder>( const CircleBorder(), ), ), onPressed: () {}, child: const Icon( Icons.ads_click_outlined, size: 40, color: Colors.black, ), ), ), ), Expanded( child: Container( color: Colors.brown, height: 60, child: TextButton( onPressed: () {}, style: ButtonStyle( shape: MaterialStateProperty.all<CircleBorder>( const CircleBorder(), ), ), child: const Icon( Icons.leaderboard_outlined, size: 40, color: Colors.black, ), ), ), ), Expanded( child: Container( color: Colors.brown, height: 60, child: TextButton( onPressed: () { setState(() { isSettingsPageActive = true; }); Navigator.pushReplacement( context, MaterialPageRoute( builder: (_) => const SettingsPage(), ), ); }, style: ButtonStyle( shape: MaterialStateProperty.all<CircleBorder>( const CircleBorder(), ), ), child: Icon( Icons.settings_outlined, size: 40, color: isSettingsPageActive ? Colors.white : Colors.black, ), ), ), ), ], ), ), ), ), ], ); }, ), ), ); } } class SignIn extends StatefulWidget { const SignIn({Key? key}) : super(key: key); @override _SignInState createState() => _SignInState(); } class _SignInState extends State<SignIn> { final _formKey = GlobalKey<FormState>(); final FirebaseAuth _auth = FirebaseAuth.instance; late String _email; late String _password; @override void initState() { super.initState(); _email = ''; _password = ''; } void _signInWithEmailAndPassword() async { if (_formKey.currentState!.validate()) { _formKey.currentState!.save(); try { await _auth.signInWithEmailAndPassword( email: _email, password: _password, ); SharedPreferences prefs = await SharedPreferences.getInstance(); await prefs.setBool('isLoggedIn', true); Navigator.pushReplacement( context, MaterialPageRoute(builder: (_) => const ChickenNuggetClickerApp()), ); } catch (e) { showDialog( context: context, builder: (BuildContext context) { return AlertDialog( title: const Text('Sign-in Error'), content: Text(e.toString()), actions: [ TextButton( onPressed: () => Navigator.of(context).pop(), child: const Text('OK'), ), ], ); }, ); } } } void _goToSignUp() { Navigator.pushReplacement( context, MaterialPageRoute(builder: (_) => const SignUp()), ); } @override Widget build(BuildContext context) { return Scaffold( backgroundColor: Colors.yellow, appBar: AppBar( backgroundColor: Colors.brown, title: const Text('Sign In'), ), body: SingleChildScrollView( child: Padding( padding: const EdgeInsets.all(16.0), child: Form( key: _formKey, child: Column( mainAxisAlignment: MainAxisAlignment.center, children: [ Image.asset('assets/nugget.png'), const SizedBox(height: 20), const Text( "Welcome back!", style: TextStyle(fontSize: 30), ), const SizedBox(height: 30), TextFormField( keyboardType: TextInputType.emailAddress, onChanged: (value) => _email = value.trim(), validator: (value) { if (value == null || value.isEmpty) { return 'Please enter your email'; } return null; }, style: const TextStyle(color: Colors.black), decoration: InputDecoration( hintText: 'Enter your email', filled: true, fillColor: Colors.white, border: OutlineInputBorder( borderSide: BorderSide.none, borderRadius: BorderRadius.circular(8.0), ), ), ), const SizedBox(height: 16.0), TextFormField( obscureText: true, onChanged: (value) => _password = value, validator: (value) { if (value == null || value.isEmpty) { return 'Please enter your password'; } return null; }, style: const TextStyle(color: Colors.black), decoration: InputDecoration( hintText: 'Enter your password', filled: true, fillColor: Colors.white, border: OutlineInputBorder( borderSide: BorderSide.none, borderRadius: BorderRadius.circular(8.0), ), ), ), const SizedBox(height: 16.0), ElevatedButton( onPressed: _signInWithEmailAndPassword, child: const Row( children: [ SizedBox(width: 160), Text('Sign in'), ], ), ), const SizedBox(height: 80), const Text( 'Don\'t have an account?', style: TextStyle(fontSize: 16), ), const SizedBox(height: 14), Row( mainAxisAlignment: MainAxisAlignment.center, children: [ TextButton( onPressed: _goToSignUp, child: const Text('Sign up'), ), ], ), ], ), ), ), ), ); } } // SIGN UP PAGE BELOW class SignUp extends StatefulWidget { const SignUp({Key? key}) : super(key: key); @override _SignUpState createState() => _SignUpState(); } class _SignUpState extends State<SignUp> { final _formKey = GlobalKey<FormState>(); late String _email; late String _password; final FirebaseAuth _auth = FirebaseAuth.instance; bool isEmailVerified = false; late Timer _timer; @override void initState() { super.initState(); // Start the timer when the widget is initialized _timer = Timer.periodic(const Duration(seconds: 3), (timer) { checkEmailVerificationStatus(); }); } @override void dispose() { // Cancel the timer when the widget is disposed _timer.cancel(); super.dispose(); } void checkEmailVerificationStatus() async { final User? currentUser = _auth.currentUser; await currentUser?.reload(); if (currentUser != null && currentUser.emailVerified) { setState(() { isEmailVerified = true; }); _timer.cancel(); // Navigate to success page or perform any other actions Navigator.pushReplacement( context, MaterialPageRoute(builder: (_) => const SuccessPage()), ); } } Future<void> _signUpWithEmailAndPassword() async { if (_formKey.currentState!.validate()) { _formKey.currentState!.save(); try { final UserCredential userCredential = await _auth.createUserWithEmailAndPassword( email: _email, password: _password, ); await userCredential.user!.sendEmailVerification(); showDialog( context: context, barrierDismissible: false, builder: (BuildContext context) { return const AlertDialog( title: Text('Email Verification'), content: Text( 'A verification email has been sent to your email address. ' 'Please click the verification link to proceed.', ), ); }, ); } catch (e) { showDialog( context: context, builder: (BuildContext context) { return AlertDialog( title: const Text('Sign-up Error'), content: Text(e.toString()), actions: [ TextButton( onPressed: () => Navigator.of(context).pop(), child: const Text('OK'), ), ], ); }, ); } } } @override Widget build(BuildContext context) { return Scaffold( backgroundColor: Colors.yellow, appBar: AppBar( backgroundColor: Colors.brown, title: const Text('Sign Up'), ), body: SingleChildScrollView( child: Padding( padding: const EdgeInsets.all(16.0), child: Form( key: _formKey, child: Column( mainAxisAlignment: MainAxisAlignment.center, children: [ Image.asset('assets/nugget.png'), const SizedBox(height: 20), const Text( "Welcome!", style: TextStyle(fontSize: 30), ), const SizedBox(height: 30), TextFormField( keyboardType: TextInputType.emailAddress, onChanged: (value) => _email = value.trim(), validator: (value) { if (value == null || value.isEmpty) { return 'Please enter your email'; } return null; }, style: const TextStyle(color: Colors.black), decoration: InputDecoration( hintText: 'Enter your email', filled: true, fillColor: Colors.white, border: OutlineInputBorder( borderSide: BorderSide.none, borderRadius: BorderRadius.circular(8.0), ), ), ), const SizedBox(height: 16.0), TextFormField( obscureText: true, onChanged: (value) => _password = value, validator: (value) { if (value == null || value.isEmpty) { return 'Please enter your password'; } return null; }, style: const TextStyle(color: Colors.black), decoration: InputDecoration( hintText: 'Enter your password', filled: true, fillColor: Colors.white, border: OutlineInputBorder( borderSide: BorderSide.none, borderRadius: BorderRadius.circular(8.0), ), ), ), const SizedBox(height: 16.0), ElevatedButton( onPressed: _signUpWithEmailAndPassword, child: const Row( children: [ SizedBox(width: 160), Text('Sign up'), ], ), ), const SizedBox(height: 80), const Text( 'Or Continue with...', style: TextStyle(fontSize: 16), ), const SizedBox(height: 14), Row( mainAxisAlignment: MainAxisAlignment.spaceEvenly, children: [ TextButton( style: ButtonStyle( backgroundColor: MaterialStateProperty.all(Colors.black), ), child: const Row( children: [ SizedBox( height: 70, width: 20, ), Icon( Icons.apple, color: Colors.white, size: 40, ), SizedBox( width: 20, ), ], ), onPressed: () {}, ), TextButton( style: ButtonStyle( backgroundColor: MaterialStateProperty.all(Colors.white), ), child: const Row( children: [ SizedBox( height: 70, width: 20, ), Icon( FontAwesomeIcons.google, color: Colors.black, size: 40, ), SizedBox(width: 20) ], ), onPressed: () {}, ), TextButton( style: ButtonStyle( backgroundColor: MaterialStateProperty.all(Colors.blue), ), child: const Row( children: [ SizedBox( height: 70, width: 20, ), Icon( Icons.facebook, color: Colors.white, size: 40, ), SizedBox( width: 20, ), ], ), onPressed: () {}, ), ], ), Row( children: [ const SizedBox(width: 100), const Text("Already have an account?"), TextButton( onPressed: () { Navigator.pushReplacement( context, MaterialPageRoute( builder: (_) => const SignIn(), ), ); }, child: const Text('Sign in'), ), ], ), ], ), ), ), ), ); } } class SuccessPage extends StatelessWidget { const SuccessPage({Key? key}) : super(key: key); @override Widget build(BuildContext context) { final User? currentUser = FirebaseAuth.instance.currentUser; return Scaffold(backgroundColor: Colors.yellow, appBar: AppBar( backgroundColor: Colors.brown, title: const Text('Success!'), ), body: Center( child: Column( mainAxisAlignment: MainAxisAlignment.center, children: [ currentUser!.emailVerified ? const Text( 'Sign up successful!', style: TextStyle(fontSize: 24), ) : const Text( 'Sign up successful!\n' 'Please verify your email to proceed.', textAlign: TextAlign.center, style: TextStyle(fontSize: 24), ), const SizedBox(height: 20), ElevatedButton( onPressed: () { Navigator.pushReplacement( context, MaterialPageRoute( builder: (_) => const SignIn(), ), ); }, child: const Text('Go to Sign In'), ), ], ), ), ); } }
0
mirrored_repositories/Chicken-Nugget-Clicker-App
mirrored_repositories/Chicken-Nugget-Clicker-App/lib/settings_page.dart
import 'package:flutter/material.dart'; import 'main.dart'; class SettingsPage extends StatelessWidget { const SettingsPage({Key? key}) : super(key: key); Widget buildStyledRow(String text, IconData icon) { return Container( decoration: const BoxDecoration( border: Border( bottom: BorderSide( color: Colors.brown, width: 2, ), ), ), padding: const EdgeInsets.symmetric(vertical: 10.0), child: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Padding( padding: const EdgeInsets.all(10.0), child: Text( text, style: const TextStyle(fontSize: 20.0), ), ), Padding( padding: const EdgeInsets.all(10.0), child: Icon(icon), ), ], ), ); } @override Widget build(BuildContext context) { return Scaffold( backgroundColor: const Color.fromRGBO(199, 144, 83, 1), appBar: AppBar( backgroundColor: Colors.brown, title: const Text('Settings'), automaticallyImplyLeading: false, leading: Container( margin: const EdgeInsets.only(left: 2), child: IconButton( icon: const Icon(Icons.ios_share_outlined, color: Colors.black, size: 40,), onPressed: () { // Implement your share button logic here }, ), ), toolbarHeight: 60, leadingWidth: 90, ), body: Column( children: [ const SizedBox(height: 20), Column( children: const [ CircleAvatar( radius: 50, backgroundImage: AssetImage('path_to_profile_picture'), ), SizedBox(height: 10), Text( 'John Doe', style: TextStyle(fontSize: 20, fontWeight: FontWeight.bold), ), ], ), const SizedBox(height: 20), Expanded( child: Align( alignment: Alignment.topCenter, child: Column( children: [ buildStyledRow('Theme', Icons.brush_outlined), buildStyledRow('Version', Icons.view_week_rounded), buildStyledRow('Row 3', Icons.brush_outlined), ], ), ), ), Align( alignment: Alignment.bottomCenter, child: Container( color: Colors.brown, padding: const EdgeInsets.all(10), child: Row( children: [ Expanded( child: Container( decoration: BoxDecoration( borderRadius: BorderRadius.circular(50), ), height: 60, child: TextButton( style: ButtonStyle( shape: MaterialStateProperty.all<CircleBorder>( const CircleBorder(), ), ), onPressed: () { Navigator.pushReplacement( context, PageRouteBuilder( pageBuilder: (_, __, ___) => const ChickenNuggetClickerApp(), transitionDuration: Duration.zero, ), ); }, child: const Icon( Icons.ads_click_outlined, size: 40, color: Colors.black, ), ), ), ), Expanded( child: Container( color: Colors.brown, height: 60, child: TextButton( onPressed: () {}, style: ButtonStyle( shape: MaterialStateProperty.all<CircleBorder>( const CircleBorder(), ), ), child: const Icon( Icons.leaderboard_outlined, size: 40, color: Colors.black, ), ), ), ), Expanded( child: Container( color: Colors.brown, height: 60, child: TextButton( onPressed: () {}, style: ButtonStyle( shape: MaterialStateProperty.all<CircleBorder>( const CircleBorder(), ), ), child: const Icon( Icons.settings_outlined, size: 40, color: Colors.white, ), ), ), ), ], ), ), ), ], ), ); } }
0
mirrored_repositories/flutter_recipe_app_bloc_pattern
mirrored_repositories/flutter_recipe_app_bloc_pattern/lib/main.dart
import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:flutterrecipeapp/bloc/recipe/recipe_bloc.dart'; import 'package:flutterrecipeapp/repository/recipe_repository.dart'; import 'package:flutterrecipeapp/screen/home_page.dart'; void main() { runApp(MyApp()); } class MyApp extends StatelessWidget { @override Widget build(BuildContext context) { return MaterialApp( title: 'BLoC Pattern', theme: ThemeData( primarySwatch: Colors.orange, visualDensity: VisualDensity.adaptivePlatformDensity, ), home: BlocProvider( // Creating Bloc provider here and adding first event as AppStarted create: (context) => RecipeBloc(repository: RecipeRepository())..add(AppStated()), child: HomePage()), ); } }
0
mirrored_repositories/flutter_recipe_app_bloc_pattern/lib
mirrored_repositories/flutter_recipe_app_bloc_pattern/lib/repository/base_recipe_repository.dart
import 'package:flutterrecipeapp/model/recipe_model.dart'; abstract class BaseRecipeRepository { Future<List<Result>> getRecipeList({String query, int page}); void dispose(); }
0
mirrored_repositories/flutter_recipe_app_bloc_pattern/lib
mirrored_repositories/flutter_recipe_app_bloc_pattern/lib/repository/recipe_repository.dart
import 'package:flutter/foundation.dart'; import 'package:flutterrecipeapp/constant/app_constant.dart'; import 'package:flutterrecipeapp/model/recipe_model.dart'; import 'package:flutterrecipeapp/repository/base_recipe_repository.dart'; import 'package:http/http.dart' as http; class RecipeRepository extends BaseRecipeRepository { // If you're making multiple requests to the same server, // you can keep open a persistent connection by using a Client rather than making one-off requests. // If you do this, make sure to close the client when you're done: final http.Client _httpClient; RecipeRepository({http.Client httpClient}) : _httpClient = httpClient ?? http.Client(); // if no parameter is passed in then instantiate new http client @override Future<List<Result>> getRecipeList({@required String query,@required int page}) async { final url = '$baseUrl?q=$query&p=$page'; print(url); final response = await _httpClient.get(url); if (response.statusCode == 200) { print('success ' + response.statusCode.toString()); return recipeModelFromJson(response.body).results; } else { print('got error code ' + response.statusCode.toString()); } } @override void dispose() { _httpClient.close(); } }
0
mirrored_repositories/flutter_recipe_app_bloc_pattern/lib/bloc
mirrored_repositories/flutter_recipe_app_bloc_pattern/lib/bloc/recipe/recipe_bloc.dart
import 'dart:async'; import 'package:bloc/bloc.dart'; import 'package:equatable/equatable.dart'; import 'package:flutterrecipeapp/model/recipe_model.dart'; import 'package:flutterrecipeapp/repository/recipe_repository.dart'; import 'package:meta/meta.dart'; part 'recipe_event.dart'; part 'recipe_state.dart'; class RecipeBloc extends Bloc<RecipeEvent, RecipeState> { // add dependency to perform your business logic (we need repository here) final RecipeRepository _repository; String query; int pageNumber = 1; RecipeBloc({@required RecipeRepository repository}) : assert(repository != null), _repository = repository; @override RecipeState get initialState => InitialState(); @override Stream<RecipeState> mapEventToState(RecipeEvent event) async* { if (event is SearchEvent) { yield* _mapToSearchEvent(event); }else if (event is RefreshEvent) { yield* _getRecipes(query); }else if (event is LoadMoreEvent) { yield* _getRecipes(query, page: pageNumber); } } Stream<RecipeState> _mapToSearchEvent(SearchEvent event) async* { pageNumber = 1; query = event.query; yield InitialState(); // clearing previous list yield LoadingState(); // showing loading indicator yield* _getRecipes(event.query); // get recipes } Stream<RecipeState> _getRecipes(String query, {int page = 1}) async* { var currentState = state; try{ List<Result> recipeList = await _repository.getRecipeList(query: query, page: page); if (currentState is LoadedState) { recipeList = currentState.recipe + recipeList; } pageNumber++; yield LoadedState(recipe: recipeList, hasReachToEnd: recipeList.isEmpty ? true : false); }catch (ex) { if (page == 1) yield ErrorState(); else yield LoadedState(recipe: currentState is LoadedState ? currentState.recipe : [], hasReachToEnd: true); } } }
0
mirrored_repositories/flutter_recipe_app_bloc_pattern/lib/bloc
mirrored_repositories/flutter_recipe_app_bloc_pattern/lib/bloc/recipe/recipe_state.dart
part of 'recipe_bloc.dart'; @immutable abstract class RecipeState extends Equatable { @override List<Object> get props => []; } class InitialState extends RecipeState {} class LoadingState extends RecipeState {} class LoadedState extends RecipeState { final List<Result> recipe; final bool hasReachToEnd; LoadedState({@required this.recipe,@required this.hasReachToEnd}); @override List<Object> get props => [recipe, hasReachToEnd]; } class ErrorState extends RecipeState {}
0
mirrored_repositories/flutter_recipe_app_bloc_pattern/lib/bloc
mirrored_repositories/flutter_recipe_app_bloc_pattern/lib/bloc/recipe/recipe_event.dart
part of 'recipe_bloc.dart'; @immutable abstract class RecipeEvent extends Equatable { // Event is user interaction to your screen @override List<Object> get props => []; } class AppStated extends RefreshEvent {} class SearchEvent extends RecipeEvent { final String query; SearchEvent(this.query); @override List<Object> get props => [query]; } class RefreshEvent extends RecipeEvent {} class LoadMoreEvent extends RecipeEvent {}
0
mirrored_repositories/flutter_recipe_app_bloc_pattern/lib
mirrored_repositories/flutter_recipe_app_bloc_pattern/lib/model/recipe_model.dart
// To parse this JSON data, do // // final recipeModel = recipeModelFromJson(jsonString); import 'dart:convert'; RecipeModel recipeModelFromJson(String str) => RecipeModel.fromJson(json.decode(str)); String recipeModelToJson(RecipeModel data) => json.encode(data.toJson()); class RecipeModel { String title; double version; String href; List<Result> results; RecipeModel({ this.title, this.version, this.href, this.results, }); factory RecipeModel.fromJson(Map<String, dynamic> json) => RecipeModel( title: json["title"], version: json["version"].toDouble(), href: json["href"], results: List<Result>.from(json["results"].map((x) => Result.fromJson(x))), ); Map<String, dynamic> toJson() => { "title": title, "version": version, "href": href, "results": List<dynamic>.from(results.map((x) => x.toJson())), }; } class Result { String title; String href; String ingredients; String thumbnail; Result({ this.title, this.href, this.ingredients, this.thumbnail, }); factory Result.fromJson(Map<String, dynamic> json) => Result( title: json["title"], href: json["href"], ingredients: json["ingredients"], thumbnail: json["thumbnail"], ); Map<String, dynamic> toJson() => { "title": title, "href": href, "ingredients": ingredients, "thumbnail": thumbnail, }; }
0
mirrored_repositories/flutter_recipe_app_bloc_pattern/lib
mirrored_repositories/flutter_recipe_app_bloc_pattern/lib/screen/home_page.dart
import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:flutterrecipeapp/bloc/recipe/recipe_bloc.dart'; import 'package:flutterrecipeapp/screen/widget/recipe_state_builder.dart'; import 'widget/search_bar.dart'; class HomePage extends StatefulWidget { @override _HomePageState createState() => _HomePageState(); } class _HomePageState extends State<HomePage> { @override Widget build(BuildContext context) { return Scaffold( backgroundColor: Color(0xfffffcee), body: BlocBuilder<RecipeBloc, RecipeState>(builder: (context, state) { // Map your state and return the widget return Column( children: <Widget>[ SearchBar(), Expanded( child: RecipeStateBuilder(), ) ], ); }), ); } }
0
mirrored_repositories/flutter_recipe_app_bloc_pattern/lib/screen
mirrored_repositories/flutter_recipe_app_bloc_pattern/lib/screen/widget/recipe_single_item.dart
import 'package:flutter/material.dart'; import 'package:flutterrecipeapp/constant/app_constant.dart'; import 'package:flutterrecipeapp/model/recipe_model.dart'; class BuildRecipeSingleItem extends StatelessWidget { final Result _result; BuildRecipeSingleItem(this._result); @override Widget build(BuildContext context) { return ListTile( title: Text(_result.title), subtitle: Text(_result.ingredients), leading: Image.network( _result.thumbnail.isEmpty ? noImageUrl : _result.thumbnail, height: 80, width: 80, fit: BoxFit.fitHeight, ), contentPadding: EdgeInsets.only(top: 16, left: 16, right: 16), onTap: () => FocusScope.of(context).requestFocus(new FocusNode()), ); } }
0
mirrored_repositories/flutter_recipe_app_bloc_pattern/lib/screen
mirrored_repositories/flutter_recipe_app_bloc_pattern/lib/screen/widget/recipe_state_builder.dart
import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:flutterrecipeapp/bloc/recipe/recipe_bloc.dart'; import 'package:flutterrecipeapp/screen/widget/recipe_list.dart'; class RecipeStateBuilder extends StatelessWidget { @override Widget build(BuildContext context) { var currentState = BlocProvider.of<RecipeBloc>(context).state; if (currentState is InitialState) { return Center( child: Text('What recipe do you want to cook today'), ); } else if (currentState is LoadingState) { return Center( child: CircularProgressIndicator(), ); } else if (currentState is LoadedState) { if (currentState.recipe.isEmpty) { return Center( child: Text('No recipe found. Try different recipe'), ); } return RecipeListBuilder(currentState); }else if (currentState is ErrorState) { return Center( child: Text('Something went wrong. Please check internet connection'), ); } } }
0
mirrored_repositories/flutter_recipe_app_bloc_pattern/lib/screen
mirrored_repositories/flutter_recipe_app_bloc_pattern/lib/screen/widget/recipe_list.dart
import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:flutterrecipeapp/bloc/recipe/recipe_bloc.dart'; import 'bottom_loader.dart'; import 'recipe_single_item.dart'; class RecipeListBuilder extends StatelessWidget { final LoadedState currentState; final _scrollController = ScrollController(); RecipeListBuilder(this.currentState); @override Widget build(BuildContext context) { return MediaQuery.removePadding( removeTop: true, context: context, child: NotificationListener( onNotification: (notificaton) => _handleScrolling(notificaton, currentState, context), child: ListView.builder( itemBuilder: (context, position) { return position >= currentState.recipe.length ? BottomLoadingIndicator() : BuildRecipeSingleItem(currentState.recipe[position]); }, itemCount: currentState.hasReachToEnd ? currentState.recipe.length : currentState.recipe.length + 1, // for showing bottom progress bar controller: _scrollController, ), ), ); } bool _handleScrolling(notificaton, LoadedState currentState, BuildContext context) { if (notificaton is ScrollEndNotification && _scrollController.position.extentAfter == 0) { print('has reached to end of list '+currentState.hasReachToEnd.toString()); if (!currentState.hasReachToEnd) { print('calling load more'); BlocProvider.of<RecipeBloc>(context).add(LoadMoreEvent()); } } return false; } }
0
mirrored_repositories/flutter_recipe_app_bloc_pattern/lib/screen
mirrored_repositories/flutter_recipe_app_bloc_pattern/lib/screen/widget/bottom_loader.dart
import 'package:flutter/material.dart'; class BottomLoadingIndicator extends StatelessWidget { @override Widget build(BuildContext context) { return Container( alignment: Alignment.center, child: Center( child: SizedBox( width: 33, height: 33, child: CircularProgressIndicator( strokeWidth: 1.5, ), ), ), ); } }
0
mirrored_repositories/flutter_recipe_app_bloc_pattern/lib/screen
mirrored_repositories/flutter_recipe_app_bloc_pattern/lib/screen/widget/search_bar.dart
import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:flutterrecipeapp/bloc/recipe/recipe_bloc.dart'; class SearchBar extends StatelessWidget { final _recipeQuery = TextEditingController(); @override Widget build(BuildContext context) { // ignore: close_sinks var _bloc = context.bloc<RecipeBloc>(); return Container( padding: EdgeInsets.only(left: 16,right: 16,top: 40,bottom: 16), decoration: BoxDecoration( borderRadius: BorderRadius.only(bottomLeft: Radius.circular(30),bottomRight: Radius.circular(30)), color: Colors.orange[300]), child: Row( mainAxisAlignment: MainAxisAlignment.center, children: <Widget>[ Expanded( child: TextFormField( decoration: InputDecoration( hintText: 'What you want to eat today...',hintStyle: TextStyle(color: Colors.black), labelText: 'Search Recipe',labelStyle: TextStyle(color: Colors.black), icon: Icon(Icons.fastfood, color: Colors.black,)), validator: (value) { if (value.isEmpty) { return 'Please enter recipe'; } return null; }, controller: _recipeQuery, ), ), IconButton( icon: Icon( Icons.search, size: 25, color: Colors.black, ), onPressed: () { FocusScope.of(context).requestFocus(new FocusNode()); print('user enter:'+ _recipeQuery.text.trim()); _bloc.add(SearchEvent(_recipeQuery.text.trim())); }, ) ], ), ); } }
0
mirrored_repositories/flutter_recipe_app_bloc_pattern/lib
mirrored_repositories/flutter_recipe_app_bloc_pattern/lib/constant/app_constant.dart
const String baseUrl = "http://www.recipepuppy.com/api"; const String noImageUrl = 'https://thumbs.dreamstime.com/z/no-image-available-icon-photo-camera-flat-vector-illustration-132483097.jpg';
0
mirrored_repositories/flutter_recipe_app_bloc_pattern
mirrored_repositories/flutter_recipe_app_bloc_pattern/test/recipe_bloc_test.dart
import 'dart:async'; import 'package:flutter_test/flutter_test.dart'; import 'package:flutterrecipeapp/bloc/recipe/recipe_bloc.dart'; import 'package:flutterrecipeapp/model/recipe_model.dart'; import 'package:mockito/mockito.dart'; import 'package:flutterrecipeapp/repository/recipe_repository.dart'; class MockRecipeRepository extends Mock implements RecipeRepository {} void main() { const QUERY = 'banana'; const PAGE_NUMBER = 1; Result recipe = Result(title: 'banana', href: '', ingredients: '', thumbnail: ''); RecipeRepository repository; RecipeBloc bloc; setUp(() { repository = MockRecipeRepository(); bloc = RecipeBloc(repository: repository); }); tearDown(() { bloc.close(); }); group('RecipeBloc testing', () { test('throw AssertionError if RecipeRepository is null', () { expect(() => RecipeBloc(repository: null), throwsA(isAssertionError)); }); test('initial state is correct', () { emits([InitialState(), bloc.state]); }); // Test cases for SearchEvent test( 'emit [InitialState, LoadingState, ErrorState] when getRecipeList throw exc on SearchEvent', () { when(repository.getRecipeList(query: QUERY, page: PAGE_NUMBER)) .thenThrow(throwsException); expectLater( bloc, emitsInOrder([InitialState(), LoadingState(), ErrorState()])); bloc.add(SearchEvent(QUERY)); }); test( 'emit [InitialState, LoadingState, LoadedState] when getRecipeList success on SearchEvent', () { when(repository.getRecipeList(query: QUERY, page: PAGE_NUMBER)) .thenAnswer((realInvocation) => Future.value([recipe])); expectLater( bloc, emitsInOrder([ InitialState(), LoadingState(), LoadedState(recipe: [recipe], hasReachToEnd: false) ])); bloc.add(SearchEvent(QUERY)); }); test( 'emit [InitialState, LoadingState, LoadedState] when getRecipeList success but empty list on SearchEvent', () { when(repository.getRecipeList(query: QUERY, page: PAGE_NUMBER)) .thenAnswer((realInvocation) => Future.value([])); expectLater( bloc, emitsInOrder([ InitialState(), LoadingState(), LoadedState(recipe: [], hasReachToEnd: true) ])); bloc.add(SearchEvent(QUERY)); }); // LoadMoreEvent test cases test( 'emit [InitialState, LoadedState] on getRecipeList Success on LoadMoreEvent', () { bloc.query = QUERY; when(repository.getRecipeList(query: QUERY, page: 1)) .thenAnswer((_) => Future.value([recipe])); expectLater( bloc, emitsInOrder([ InitialState(), LoadedState(recipe: [recipe], hasReachToEnd: false) ])); bloc.add(LoadMoreEvent()); }); test( 'emit [InitialState, LoadedState] on getRecipeList Success but empty list on LoadMoreEvent', () { bloc.query = QUERY; when(repository.getRecipeList(query: QUERY, page: 1)) .thenAnswer((_) => Future.value([])); expectLater( bloc, emitsInOrder( [InitialState(), LoadedState(recipe: [], hasReachToEnd: true)])); bloc.add(LoadMoreEvent()); }); test( 'emit [InitialState, ErrorState] on getRecipeList throw error LoadMoreEvent', () { bloc.query = QUERY; when(repository.getRecipeList(query: QUERY, page: 1)) .thenThrow(throwsException); expectLater(bloc, emitsInOrder([InitialState(), ErrorState()])); bloc.add(LoadMoreEvent()); }); // RefreshEvent test cases test( 'emit [InitialState,ErrorState] when no query string is present for RefreshEvent', () async { when(repository.getRecipeList(query: QUERY, page: PAGE_NUMBER)) .thenThrow(throwsException); expectLater(bloc, emitsInOrder([InitialState(), ErrorState()])); bloc.add(RefreshEvent()); }); test('emit [LoadedState] when get success response from getRecipeList', () async { when(repository.getRecipeList(query: QUERY, page: PAGE_NUMBER)) .thenAnswer((_) => Future.value([recipe])); bloc.query = 'banana'; expectLater( bloc, emitsInOrder([ InitialState(), LoadedState(recipe: [recipe], hasReachToEnd: false) ])); bloc.add(RefreshEvent()); }); // calling SearchEvent AND LoadMoreEvent test( 'emit [InitialState, LoadingState, LoadedState, LoadedState] on getting success for SearchEvent and LoadMoreEvent', () { when(repository.getRecipeList(query: QUERY, page: PAGE_NUMBER)) .thenAnswer((realInvocation) => Future.value([recipe])); when(repository.getRecipeList(query: QUERY, page: 2)) .thenAnswer((realInvocation) => Future.value([recipe])); expectLater( bloc, emitsInOrder([ InitialState(), LoadingState(), LoadedState(recipe: [recipe], hasReachToEnd: false), LoadedState(recipe: [recipe, recipe], hasReachToEnd: false) ])); bloc.add(SearchEvent(QUERY)); bloc.add(LoadMoreEvent()); }); }); }
0
mirrored_repositories/streamify
mirrored_repositories/streamify/lib/main.dart
import 'package:flutter/material.dart'; import 'package:streamify/screens/main_page.dart'; void main() { runApp(const MyApp()); } class MyApp extends StatelessWidget { const MyApp({super.key}); @override Widget build(BuildContext context) { return const MaterialApp( title: 'Streamify', home: MainPage(), ); } }
0
mirrored_repositories/streamify/lib
mirrored_repositories/streamify/lib/models/album.dart
import 'dart:convert'; class Album { String name; String id; Album({ required this.name, required this.id, }); Album copyWith({ String? name, String? id, }) { return Album( name: name ?? this.name, id: id ?? this.id, ); } Map<String, dynamic> toMap() { return <String, dynamic>{ 'name': name, 'id': id, }; } factory Album.fromMap(Map<String, dynamic> map) { return Album( name: map['name'] as String, id: map['id'] as String, ); } String toJson() => json.encode(toMap()); factory Album.fromJson(String source) => Album.fromMap(json.decode(source) as Map<String, dynamic>); @override String toString() => 'Album(name: $name, id: $id)'; @override bool operator ==(covariant Album other) { if (identical(this, other)) return true; return other.name == name && other.id == id; } @override int get hashCode => name.hashCode ^ id.hashCode; }
0
mirrored_repositories/streamify/lib
mirrored_repositories/streamify/lib/models/thumbnail.dart
import 'dart:convert'; class Thumbnail { String url; int? width; int? height; Thumbnail({ required this.url, this.width, this.height, }); Thumbnail copyWith({ String? url, int? width, int? height, }) { return Thumbnail( url: url ?? this.url, width: width ?? this.width, height: height ?? this.height, ); } Map<String, dynamic> toMap() { return <String, dynamic>{ 'url': url, 'width': width, 'height': height, }; } factory Thumbnail.fromMap(Map<String, dynamic> map) { return Thumbnail( url: map['url'] as String, width: map['width'] != null ? map['width'] as int : null, height: map['height'] != null ? map['height'] as int : null, ); } String toJson() => json.encode(toMap()); factory Thumbnail.fromJson(String source) => Thumbnail.fromMap(json.decode(source) as Map<String, dynamic>); @override String toString() => 'Thumbnail(url: $url, width: $width, height: $height)'; @override bool operator ==(covariant Thumbnail other) { if (identical(this, other)) return true; return other.url == url && other.width == width && other.height == height; } @override int get hashCode => url.hashCode ^ width.hashCode ^ height.hashCode; }
0
mirrored_repositories/streamify/lib
mirrored_repositories/streamify/lib/models/home_model.dart
import 'dart:convert'; import 'package:flutter/foundation.dart'; class HomeModel { String title; List playlists; HomeModel({ required this.title, required this.playlists, }); String get getTitle => title; List get getPlaylist => playlists; set setTitle(String title) => this.title = title; set setPlaylist(List playlists) => this.playlists = playlists; HomeModel copyWith({ String? title, List? playlists, }) { return HomeModel( title: title ?? this.title, playlists: playlists ?? this.playlists, ); } Map<String, dynamic> toMap() { return <String, dynamic>{ 'title': title, 'playlist': playlists, }; } factory HomeModel.fromMap(Map<String, dynamic> map) { return HomeModel( title: map['title'] as String, playlists: List.from( (map['playlist'] as List), ), ); } String toJson() => json.encode(toMap()); factory HomeModel.fromJson(String source) => HomeModel.fromMap(json.decode(source) as Map<String, dynamic>); @override String toString() => 'HomeModel(title: $title, playlist: $playlists)'; @override bool operator ==(covariant HomeModel other) { if (identical(this, other)) return true; return other.title == title && listEquals(other.playlists, playlists); } @override int get hashCode => title.hashCode ^ playlists.hashCode; }
0
mirrored_repositories/streamify/lib
mirrored_repositories/streamify/lib/models/artist.dart
import 'dart:convert'; class Artist { String name; String? id; Artist({ required this.name, this.id, }); Artist copyWith({ String? name, String? id, }) { return Artist( name: name ?? this.name, id: id ?? this.id, ); } Map<String, dynamic> toMap() { return <String, dynamic>{ 'name': name, 'id': id, }; } factory Artist.fromMap(Map<String, dynamic> map) { return Artist( name: map['name'] as String, id: map['id'] != null ? map['id'] as String : null, ); } String toJson() => json.encode(toMap()); factory Artist.fromJson(String source) => Artist.fromMap(json.decode(source) as Map<String, dynamic>); @override String toString() => 'Artist(name: $name, id: $id)'; @override bool operator ==(covariant Artist other) { if (identical(this, other)) return true; return other.name == name && other.id == id; } @override int get hashCode => name.hashCode ^ id.hashCode; }
0
mirrored_repositories/streamify/lib
mirrored_repositories/streamify/lib/models/track.dart
import 'dart:convert'; import 'package:flutter/animation.dart'; import 'package:flutter/foundation.dart'; import 'package:streamify/models/album.dart'; import 'package:streamify/models/artist.dart'; import 'package:streamify/models/thumbnail.dart'; class Track { String title; String videoId; List<Thumbnail> thumbnails; List<Artist> artists; Album? albums; String? path; String? art; ColorPalette? colorPalette; Track({ required this.title, required this.videoId, required this.thumbnails, required this.artists, this.albums, this.path, this.art, this.colorPalette, }); Track copyWith({ String? title, String? videoId, List<Thumbnail>? thumbnails, List<Artist>? artists, Album? albums, String? path, String? art, ColorPalette? colorPalette, }) { return Track( title: title ?? this.title, videoId: videoId ?? this.videoId, thumbnails: thumbnails ?? this.thumbnails, artists: artists ?? this.artists, albums: albums ?? this.albums, path: path ?? this.path, art: art ?? this.art, colorPalette: colorPalette ?? this.colorPalette, ); } Map<String, dynamic> toMap() { return <String, dynamic>{ 'title': title, 'videoId': videoId, 'thumbnails': thumbnails.map((x) => x.toMap()).toList(), 'artists': artists.map((x) => x.toMap()).toList(), 'albums': albums?.toMap(), 'path': path, 'art': art, 'colorPalette': colorPalette?.toMap(), }; } factory Track.fromMap(Map<String, dynamic> map) { return Track( title: map['title'] as String, videoId: map['videoId'] as String, thumbnails: List<Thumbnail>.from( (map['thumbnails'] as List).map<Thumbnail>( (x) => Thumbnail.fromMap(x as Map<String, dynamic>), ), ), artists: List<Artist>.from( (map['artists'] as List).map<Artist>( (x) => Artist.fromMap(x as Map<String, dynamic>), ), ), albums: map['albums'] != null ? Album.fromMap(map['albums'] as Map<String, dynamic>) : null, colorPalette: ColorPalette.fromMap(map['colorPalette'] ?? {}), path: map['path'] != null ? map['path'] as String : null, art: map['art'] != null ? map['art'] as String : null, ); } String toJson() => json.encode(toMap()); factory Track.fromJson(String source) => Track.fromMap(json.decode(source) as Map<String, dynamic>); @override String toString() { return 'Track(title: $title, videoId: $videoId, thumbnails: $thumbnails, artists: $artists, albums: $albums, path: $path, art: $art, colorPalette: $colorPalette)'; } @override bool operator ==(covariant Track other) { if (identical(this, other)) return true; return other.title == title && other.videoId == videoId && listEquals(other.thumbnails, thumbnails) && listEquals(other.artists, artists) && other.albums == albums && other.path == path && other.art == art && other.colorPalette == colorPalette; } @override int get hashCode { return title.hashCode ^ videoId.hashCode ^ thumbnails.hashCode ^ artists.hashCode ^ albums.hashCode ^ path.hashCode ^ art.hashCode ^ colorPalette.hashCode; } } class ColorPalette { Color? darkMutedColor; Color? lightMutedColor; ColorPalette({ this.darkMutedColor, this.lightMutedColor, }); ColorPalette copyWith({ Color? darkMutedColor, Color? lightMutedColor, }) { return ColorPalette( darkMutedColor: darkMutedColor ?? this.darkMutedColor, lightMutedColor: lightMutedColor ?? this.lightMutedColor, ); } Map<String, dynamic> toMap() { return <String, dynamic>{ 'darkMutedColor': darkMutedColor?.value, 'lightMutedColor': lightMutedColor?.value, }; } factory ColorPalette.fromMap(Map<String, dynamic> map) { return ColorPalette( darkMutedColor: map['darkMutedColor'] != null ? Color(map['darkMutedColor'] as int) : null, lightMutedColor: map['lightMutedColor'] != null ? Color(map['lightMutedColor'] as int) : null, ); } String toJson() => json.encode(toMap()); factory ColorPalette.fromJson(String source) => ColorPalette.fromMap(json.decode(source) as Map<String, dynamic>); @override String toString() => 'ColorPalette(darkMutedColor: $darkMutedColor, lightMutedColor: $lightMutedColor)'; @override bool operator ==(covariant ColorPalette other) { if (identical(this, other)) return true; return other.darkMutedColor == darkMutedColor && other.lightMutedColor == lightMutedColor; } @override int get hashCode => darkMutedColor.hashCode ^ lightMutedColor.hashCode; }
0
mirrored_repositories/streamify/lib/data
mirrored_repositories/streamify/lib/data/services/yt_util.dart
getItemText(item, index, {run_index: 0, none_if_absent: false}) { dynamic column = getFlexColumnItem(item, index); if (column == null) { return null; } if (none_if_absent && column['text']['runs'].length < run_index + 1) { return null; } return column['text']['runs'][run_index]['text']; } getFlexColumnItem(item, index) { if (item['flexColumns'].length <= index || !item['flexColumns'][index]['musicResponsiveListItemFlexColumnRenderer'] .containsKey('text') || !item['flexColumns'][index]['musicResponsiveListItemFlexColumnRenderer'] ['text'] .containsKey('runs')) { return null; } return item['flexColumns'][index] ['musicResponsiveListItemFlexColumnRenderer']; }
0
mirrored_repositories/streamify/lib/data
mirrored_repositories/streamify/lib/data/services/yt_music.dart
import 'package:streamify/data/services/endpoints/recommended.dart'; import 'package:streamify/data/services/endpoints/yt_playlist.dart'; import 'package:streamify/data/services/endpoints/yt_search.dart'; class YTMusic { static search(query, {String? filter, String? scope, ignoreSpelling = false}) => Search().search(query, filter: filter, scope: scope, ignoreSpelling: ignoreSpelling); static Future suggestions(query) => Recommendations().getSearchSuggestions(query: query); static Future getPlaylistDetails(playlistId) => Playlist().getPlaylistDetails(playlistId); }
0
mirrored_repositories/streamify/lib/data
mirrored_repositories/streamify/lib/data/services/yt_api_service.dart
import 'dart:convert'; import 'dart:developer'; import 'package:http/http.dart'; class YoutubeService { static const ytmDomain = 'music.youtube.com'; static const httpsYtmDomain = 'https://music.youtube.com'; static const baseApiEndpoint = '/youtubei/v1/'; static const ytmParams = { 'alt': 'json', 'key': 'AIzaSyC9XL3ZjWddXya6X74dJoCTL-WEYFDNX30' }; static const userAgent = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:88.0) Gecko/20100101 Firefox/88.0'; Map<String, String> endpoints = { 'search': 'search', 'browse': 'browse', 'get_song': 'player', 'get_playlist': 'playlist', 'get_album': 'album', 'get_artist': 'artist', 'get_video': 'video', 'get_channel': 'channel', 'get_lyrics': 'lyrics', 'search_suggestions': 'music/get_search_suggestions', }; static const filters = [ 'albums', 'artists', 'playlists', 'community_playlists', 'featured_playlists', 'songs', 'videos' ]; List scopes = ['library', 'uploads']; Map<String, String>? headers; Map<String, dynamic>? context; YoutubeService(); Map<String, String> initializeHeaders() { return { 'user-agent': userAgent, 'accept': '*/*', 'accept-encoding': 'gzip, deflate', 'content-type': 'application/json', 'content-encoding': 'gzip', 'origin': httpsYtmDomain, 'cookie': 'CONSENT=YES+1' }; } Future<Response> sendGetRequest( String url, Map<String, String>? headers, ) async { final Uri uri = Uri.https(url); final Response response = await get(uri, headers: headers); return response; } Future<String?> getVisitorId(Map<String, String>? headers) async { final response = await sendGetRequest(ytmDomain, headers); final reg = RegExp(r'ytcfg\.set\s*\(\s*({.+?})\s*\)\s*;'); final matches = reg.firstMatch(response.body); String? visitorId; if (matches != null) { final ytcfg = json.decode(matches.group(1).toString()); visitorId = ytcfg['VISITOR_DATA']?.toString(); } return visitorId; } Map<String, dynamic> initializeContext() { final DateTime now = DateTime.now(); final String year = now.year.toString(); final String month = now.month.toString().padLeft(2, '0'); final String day = now.day.toString().padLeft(2, '0'); final String date = year + month + day; return { 'context': { 'client': {'clientName': 'WEB_REMIX', 'clientVersion': '1.$date.01.00'}, 'user': {} } }; } Future<Map> sendRequest( String endpoint, Map body, Map<String, String>? headers, ) async { final Uri uri = Uri.https(ytmDomain, baseApiEndpoint + endpoint, ytmParams); final response = await post(uri, headers: headers, body: jsonEncode(body)); if (response.statusCode == 200) { return json.decode(response.body) as Map; } else { log('YtMusic returned ${response.statusCode}${response.body}'); return {}; } } dynamic nav(dynamic root, List items) { try { dynamic res = root; for (final item in items) { res = res[item]; } return res; } catch (e) { return null; } } Future<void> init() async { headers = initializeHeaders(); if (!headers!.containsKey('X-Goog-Visitor-Id')) { headers!['X-Goog-Visitor-Id'] = await getVisitorId(headers) ?? ''; } context = initializeContext(); } }
0
mirrored_repositories/streamify/lib/data/services
mirrored_repositories/streamify/lib/data/services/endpoints/yt_playlist.dart
import 'dart:developer'; import 'package:streamify/data/services/yt_api_service.dart'; class Playlist extends YoutubeService { Future<Map> getPlaylistDetails(String playlistId) async { if (headers == null) { await init(); } try { final browseId = playlistId.startsWith('VL') ? playlistId : 'VL$playlistId'; final body = Map.from(context!); body['browseId'] = browseId; final Map response = await sendRequest(endpoints['browse']!, body, headers); final Map finalResults = nav(response, [ 'contents', 'singleColumnBrowseResultsRenderer', 'tabs', 0, 'tabRenderer', 'content', 'sectionListRenderer', 'contents', 0, 'musicPlaylistShelfRenderer' ]) as Map? ?? {}; Map playlist = { 'playlistId': finalResults['playlistId'], }; dynamic header = response['header']['musicDetailHeaderRenderer']; playlist['privacy'] = 'PUBLIC'; playlist['title'] = nav(header, ['title', 'runs', 0, 'text']); playlist['thumbnails'] = nav(header, [ 'thumbnail', 'croppedSquareThumbnailRenderer', 'thumbnail', 'thumbnails' ]); playlist["description"] = nav(header, ['description', 'runs', 0, 'text']); int runCount = header['subtitle']['runs'].length; if (runCount > 1) { playlist['author'] = { 'name': nav(header, ['subtitle', 'runs', 2, 'text']), 'browseId': nav(header, [ 'subtitle', 'runs', 2, 'navigationEndpoint', 'browseEndpoint', 'browseId' ]) }; if (runCount == 5) { playlist['year'] = nav(header, ['subtitle', 'runs', 4, 'text']); } } playlist['trackCount'] = int.parse(header['secondSubtitle']['runs'][0] ['text'] .split(' ')[0] .replaceAll(',', '')); if (header['secondSubtitle']['runs'].length > 1) { playlist['duration'] = header['secondSubtitle']['runs'][2]['text']; } // playlist['data'] = finalResults['contents']; playlist['tracks'] = []; for (Map result in finalResults['contents']) { if (result['musicResponsiveListItemRenderer'] == null) { continue; } Map data = result['musicResponsiveListItemRenderer']; String? videoId = nav(data, ['playlistItemData', 'videoId']); if (videoId == null) { continue; } List artists = []; String title = nav(data, [ 'flexColumns', 0, 'musicResponsiveListItemFlexColumnRenderer', 'text', 'runs', 0, 'text' ]); if (title == 'Song deleted') { continue; } final List thumbnails = nav(data, ['thumbnail', 'musicThumbnailRenderer', 'thumbnail', 'thumbnails']); final List subtitleList = nav(data, [ 'flexColumns', 1, 'musicResponsiveListItemFlexColumnRenderer', 'text', 'runs' ]) as List; for (final element in subtitleList) { if (element['navigationEndpoint']?['browseEndpoint'] ?['browseEndpointContextSupportedConfigs'] ['browseEndpointContextMusicConfig']['pageType'] .toString() .trim() == 'MUSIC_PAGE_TYPE_USER_CHANNEL') { artists.add({ 'name': element['text'], 'browseId': element['navigationEndpoint']?['browseEndpoint'] ?['browseId'] }); } } Map results = { 'videoId': videoId, 'title': title, 'thumbnails': thumbnails, 'artists': artists, }; playlist['tracks'].add(results); } return playlist; } catch (e) { log('Error in ytmusic getPlaylistDetails $e'); return {}; } } }
0
mirrored_repositories/streamify/lib/data/services
mirrored_repositories/streamify/lib/data/services/endpoints/recommended.dart
import 'dart:developer'; import 'package:streamify/data/services/yt_api_service.dart'; class Recommendations extends YoutubeService { Future<List<String>> getSearchSuggestions({ required String query, }) async { if (headers == null) { await init(); } try { final body = Map.from(context!); body['input'] = query; final Map response = await sendRequest(endpoints['search_suggestions']!, body, headers); final List finalResult = nav(response, [ 'contents', 0, 'searchSuggestionsSectionRenderer', 'contents' ]) as List? ?? []; final List<String> results = []; for (final item in finalResult) { results.add( nav(item, [ 'searchSuggestionRenderer', 'navigationEndpoint', 'searchEndpoint', 'query' ]).toString(), ); } return results; } catch (e) { log('Error in yt search suggestions $e'); return List.empty(); } } }
0
mirrored_repositories/streamify/lib/data/services
mirrored_repositories/streamify/lib/data/services/endpoints/yt_search.dart
import 'package:hive_flutter/hive_flutter.dart'; import 'package:streamify/data/services/yt_api_service.dart'; Box box = Hive.box('settings'); class Search extends YoutubeService { String? getParam2(String filter) { final filterParams = { 'songs': 'I', 'videos': 'Q', 'albums': 'Y', 'artists': 'g', 'playlists': 'o' }; return filterParams[filter]; } String? getSearchParams({ String? filter, String? scope, bool ignoreSpelling = false, }) { String? params; String? param1; String? param2; String? param3; if (!ignoreSpelling && filter == null && scope == null) { return params; } if (scope == 'uploads') { params = 'agIYAw%3D%3D'; } if (scope == 'library') { if (filter != null) { param1 = 'EgWKAQI'; param2 = getParam2(filter); param3 = 'AWoKEAUQCRADEAoYBA%3D%3D'; } else { params = 'agIYBA%3D%3D'; } } if (scope == null && filter != null) { if (filter == 'playlist') { params = 'Eg-KAQwIABAAGAAgACgB'; if (!ignoreSpelling) { params += 'MABqChAEEAMQCRAFEAo%3D'; } else { params += 'MABCAggBagoQBBADEAkQBRAK'; } } else { if (filter.contains('playlist')) { param1 = 'EgeKAQQoA'; if (filter == 'featured_playlist') { param2 = 'Dg'; } else { param2 = 'EA'; } if (!ignoreSpelling) { param3 = 'BagwQDhAKEAMQBBAJEAU%3D'; } else { param3 = 'BQgIIAWoMEA4QChADEAQQCRAF'; } } else { param1 = 'EgWKAQI'; param2 = getParam2(filter); if (!ignoreSpelling) { param3 = 'AWoMEA4QChADEAQQCRAF'; } else { param3 = 'AUICCAFqDBAOEAoQAxAEEAkQBQ%3D%3D'; } } } } if (scope == null && filter == null && ignoreSpelling) { params = 'EhGKAQ4IARABGAEgASgAOAFAAUICCAE%3D'; } if (params != null) { return params; } else { return '$param1$param2$param3'; } } Future<List<Map>> search( String query, { String? scope, bool ignoreSpelling = false, String? filter, }) async { if (headers == null) { await init(); } String lang = box.get('language_code', defaultValue: 'en'); String country = box.get(' countryCode', defaultValue: 'IN'); context!['context']['client']['hl'] = lang; context!['context']['client']['gl'] = country; final body = Map.from(context!); body['query'] = query; final params = getSearchParams( filter: filter, scope: scope, ignoreSpelling: ignoreSpelling, ); if (params != null) { body['params'] = params; } if (filter?.trim() == "") { filter = null; } final List<Map> searchResults = []; final res = await sendRequest(endpoints['search']!, body, headers); if (!res.containsKey('contents')) { return List.empty(); } List contents = []; if ((res['contents'] as Map).containsKey('tabbedSearchResultsRenderer')) { final tabIndex = (scope == null || filter != null) ? 0 : scopes.indexOf(scope) + 1; contents = nav(res, [ 'contents', 'tabbedSearchResultsRenderer', 'tabs', tabIndex, 'tabRenderer', 'content', 'sectionListRenderer', 'contents', ]); } else { contents = res['contents']; } if (contents[0]?['messageRenderer'] != null) return []; for (var e in contents) { if (e['itemSectionRenderer'] != null) { continue; } Map ctx = e['musicShelfRenderer']; ctx['contents'].forEach((a) { a = a['musicResponsiveListItemRenderer']; String type = ""; if (filter != null) { type = filter; } else { type = ctx['title']['runs'][0]['text'].toLowerCase(); } type = type.substring(0, type.length - 1); if (type == 'top resul') { type = a['flexColumns']?[1] ['musicResponsiveListItemFlexColumnRenderer']['text'] ['runs'][0]['text'] .toLowerCase(); } if (!['artist', 'playlist', 'song', 'video', 'station'] .contains(type)) { type = 'album'; } List data = a['flexColumns'][1] ['musicResponsiveListItemFlexColumnRenderer']['text']['runs']; Map res = { 'type': type, 'artists': [], 'album': {}, }; if (type != 'artist') { res['title'] = a['flexColumns'][0] ['musicResponsiveListItemFlexColumnRenderer']['text']['runs'] [0]['text']; } if (type == 'artist') { res['artist'] = a['flexColumns'][0] ['musicResponsiveListItemFlexColumnRenderer']['text']['runs'] [0]['text']; res['subscribers'] = data.last['text']; } else if (type == 'album') { res['type'] = a['flexColumns'][1] ['musicResponsiveListItemFlexColumnRenderer']['text']['runs'] [0]['text']; } else if (type == 'playlist') { res['itemCount'] = data.last['text']; } else if (type == 'song' || type == 'video') { res['artists'] = []; res['album'] = {}; } if (['song', 'video'].contains(type)) { res['videoId'] = nav(a, [ 'overlay', 'musicItemThumbnailOverlayRenderer', 'content', 'musicPlayButtonRenderer', 'playNavigationEndpoint', 'watchEndpoint', 'videoId' ]); res['videoType'] = nav(a, [ 'overlay', 'musicItemThumbnailOverlayRenderer', 'content', 'musicPlayButtonRenderer', 'playNavigationEndpoint', 'watchEndpoint', 'watchEndpointMusicSupportedConfigs', 'watchEndpointMusicConfig', 'musicVideoType' ]); res['duration'] = data.last['text']; res['radioId'] = 'RDAMVM${res['videoId']}'; } res['thumbnails'] = a['thumbnail']['musicThumbnailRenderer']['thumbnail']['thumbnails']; for (Map run in data) { if (['song', 'video', 'album'].contains(type)) { if (run['navigationEndpoint']?['browseEndpoint'] ?['browseEndpointContextSupportedConfigs'] ?['browseEndpointContextMusicConfig']?['pageType'] == 'MUSIC_PAGE_TYPE_ARTIST') { res['artists'].add({ 'name': run['text'], 'browseId': run['navigationEndpoint']?['browseEndpoint'] ?['browseId'], }); } if (run['navigationEndpoint']?['browseEndpoint'] ?['browseEndpointContextSupportedConfigs'] ?['browseEndpointContextMusicConfig']?['pageType'] == 'MUSIC_PAGE_TYPE_ALBUM') { res['album'] = { 'name': run['text'], 'browseId': run['navigationEndpoint']?['browseEndpoint'] ?['browseId'], }; } } if (['artist', 'album', 'playlist'].contains(type)) { if (res['browseId'] == null && a['navigationEndpoint']['browseEndpoint']['browseId'] != null) { res['browseId'] = a['navigationEndpoint']['browseEndpoint']['browseId']; } } } if ((res['type'] == 'album' || res['type'] == 'song' || res['type'] == 'video') && res['artists'].isEmpty) { } else { searchResults.add(res); } }); } return searchResults; } }
0
mirrored_repositories/streamify/lib
mirrored_repositories/streamify/lib/screens/main_page.dart
import 'package:flutter/material.dart'; class MainPage extends StatefulWidget { const MainPage({Key? key}) : super(key: key); @override State<MainPage> createState() => _MainPageState(); } class _MainPageState extends State<MainPage> { @override Widget build(BuildContext context) { return Scaffold( body: Column( children: [ ], ), ); } }
0
mirrored_repositories/streamify
mirrored_repositories/streamify/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:streamify/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/Fluttter-School-App
mirrored_repositories/Fluttter-School-App/lib/result.dart
import 'package:flutter/material.dart'; import 'package:flutter_webview_plugin/flutter_webview_plugin.dart'; class ResultView extends StatefulWidget { ResultView(this.url); final String url; @override _ResultViewState createState() => _ResultViewState(); } class _ResultViewState extends State<ResultView> { String path = 'https://example.com/frame.php?path='; double progress = 0; @override void initState() { super.initState(); path += widget.url; print(path); } @override void dispose() { super.dispose(); } @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( title: const Text('Result'), ), body: Container( child: Column( children: <Widget>[ (progress != 1.0) ? LinearProgressIndicator(value: progress) : null, Expanded( child: Container( margin: const EdgeInsets.all(0.0), decoration: BoxDecoration( border: Border.all(color: Colors.blueAccent)), child: WebviewScaffold( appBar: AppBar( title: Text("BPS PLAY SCHOOL"), ), url: path, scrollBar: true, withZoom: true, withLocalStorage: true, hidden: true, allowFileURLs: true, withJavascript: true, initialChild: Container( color: Colors.white, child: const Center( child: Text( 'Wait .....\n Checking Internet Connection', style: TextStyle( fontWeight: FontWeight.bold, fontSize: 20.0), ), ), ), )), ), ] ) ) ); } }
0
mirrored_repositories/Fluttter-School-App
mirrored_repositories/Fluttter-School-App/lib/gallery.dart
import 'package:flutter/material.dart'; class GalleryPage extends StatelessWidget { @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( title: Text('Gallery'), elevation: 2.0, backgroundColor: Color.fromARGB(255, 255, 105, 180), ), body: Container( color: Colors.white30, child: new GridView.count( crossAxisCount: 2, childAspectRatio: 1.0, padding: const EdgeInsets.all(4.0), mainAxisSpacing: 4.0, crossAxisSpacing: 4.0, children: <String>[ 'assets/1.jpg', 'assets/2.jpg', 'assets/3.JPG', 'assets/4.JPG', 'assets/5.jpg', 'assets/6.jpg', 'assets/7.jpg', 'assets/8.jpg', 'assets/9.jpg', 'assets/10.jpg' ].map((String url) { return ClipRRect( borderRadius: BorderRadius.only( topLeft: Radius.circular(15.0), topRight: Radius.circular(15.0), bottomRight: Radius.circular(15.0), bottomLeft: Radius.circular(15.0) ), child: GridTile( child: new Image.asset(url, fit: BoxFit.cover), ), ); }).toList()), ), ); } }
0
mirrored_repositories/Fluttter-School-App
mirrored_repositories/Fluttter-School-App/lib/updates.dart
import 'dart:convert'; import 'package:flutter/material.dart'; import 'package:http/http.dart' as http; import 'package:flutter/animation.dart'; class Updates extends StatefulWidget { @override _UpdatesState createState() => _UpdatesState(); } class _UpdatesState extends State<Updates> with SingleTickerProviderStateMixin { ScrollController scrollCtrl = new ScrollController(); AnimationController animateCtrl; List notices; //Future Notice Start// @override void initState() { double offset = 0.0; super.initState(); this.getNotice(); animateCtrl = new AnimationController(vsync: this, duration: Duration(seconds: 6)) ..addListener(() { if (animateCtrl.isCompleted) animateCtrl.repeat(); offset += 1.0; if (offset - 1 > scrollCtrl.offset) { offset = 0.0; } setState(() { scrollCtrl.jumpTo(offset); }); }); animateCtrl.forward(); } Future getNotice() async { var response = await http.get( Uri.encodeFull( 'http://result.bpsplayschool.com/updates.php', ), headers: {'accepts': 'application/json'}); var data = json.decode(response.body); //print(data['result'][0]['date']); print(data['result']); if (!mounted) return; setState(() { notices = data['result']; }); } @override void dispose() { animateCtrl.dispose(); super.dispose(); } //Future Notice End// @override Widget build(BuildContext context) { return Scaffold( backgroundColor: Colors.white, appBar: AppBar( leading: Image.asset('assets/bps.png'), title: Text('BPS Play School'), elevation: 2.0, backgroundColor: Color.fromARGB(255, 255, 0, 0), ), body: Column( mainAxisSize: MainAxisSize.min, children: <Widget>[ Padding( padding: EdgeInsets.all(2.0), ), ClipRRect( borderRadius: BorderRadius.only( topLeft: Radius.circular(15.0), topRight: Radius.circular(15.0), bottomRight: Radius.circular(15.0), bottomLeft: Radius.circular(15.0)), child: Container( height: 50.0, width: MediaQuery.of(context).size.width / 1.029, color: Colors.amber, child: Center( child: Text( 'Update Board', style: TextStyle(fontSize: 18.0, color: Colors.white), )), ), ), Expanded( child: notices == null ? Center(child: Text('0 Updates Available')) : ListView.builder( controller: scrollCtrl, shrinkWrap: true, physics: ScrollPhysics(), itemCount: notices == null ? 0 : notices.length, itemBuilder: (BuildContext context, int index) { return Card( clipBehavior: Clip.hardEdge, child: ListTile( leading: Icon(Icons.av_timer), title: Text( notices[index]['updates'], style: TextStyle(fontStyle: FontStyle.italic), ), subtitle: Text('Posted On: ' + notices[index]['date']), ), ); }, ), ), ], ), ); } }
0
mirrored_repositories/Fluttter-School-App
mirrored_repositories/Fluttter-School-App/lib/main.dart
import 'package:flutter/material.dart'; import 'package:bottom_navy_bar/bottom_navy_bar.dart'; import 'package:school/gallery.dart'; import 'package:school/home.dart'; import 'package:school/student.dart'; void main() => runApp(MaterialApp( title: 'School', home: MyHomePage(), // theme: ThemeData( // brightness: Brightness.light, // primaryColor: Colors.lightBlue[800], // accentColor: Colors.cyan[600], // ), )); class MyHomePage extends StatefulWidget { @override _MyHomePageState createState() => _MyHomePageState(); } class _MyHomePageState extends State<MyHomePage> { @override void initState(){ super.initState(); } int currentIndex = 0; final _widgetOptions = [ Home(), GalleryPage(), Student(), ]; @override Widget build(BuildContext context) { return Scaffold( body: Container( child: _widgetOptions.elementAt(currentIndex), decoration: new BoxDecoration(color: Colors.white), ), bottomNavigationBar: BottomNavyBar( onItemSelected: (index) => setState(() { currentIndex = index; }), items: [ BottomNavyBarItem( icon: Icon(Icons.apps), title: Text('Home'), activeColor: Colors.red, ), BottomNavyBarItem( icon: Icon(Icons.image), title: Text('Gallery'), activeColor: Colors.purpleAccent, ), BottomNavyBarItem( icon: Icon(Icons.people), title: Text('Student'), activeColor: Colors.blue, ) ], ), ); } }
0
mirrored_repositories/Fluttter-School-App
mirrored_repositories/Fluttter-School-App/lib/home.dart
import 'dart:convert'; import 'package:flutter/material.dart'; import 'package:carousel_slider/carousel_slider.dart'; import 'package:flutter_webview_plugin/flutter_webview_plugin.dart'; import 'package:school/school/about.dart'; import 'package:school/school/admission.dart'; import 'package:school/school/contact.dart'; import 'package:http/http.dart' as http; import 'package:flutter/animation.dart'; import 'package:url_launcher/url_launcher.dart'; var green = Color(0xFF4caf6a); var greenLight = Color(0xFFd8ebde); var red = Color(0xFFf36169); var redLight = Color(0xFFf2dcdf); var blue = Color(0xFF398bcf); var blueLight = Color(0xFFc1dbee); final List<String> imgList = [ 'assets/8.jpg', 'assets/6.jpg', 'assets/4.JPG', 'assets/5.jpg', 'assets/9.jpg' ]; final List child = map<Widget>( imgList, (index, i) { return Container( margin: EdgeInsets.all(5.0), child: ClipRRect( borderRadius: BorderRadius.all(Radius.circular(5.0)), child: Stack(children: <Widget>[ Image.asset(i, fit: BoxFit.cover, width: 1000.0), Positioned( bottom: 0.0, left: 0.0, right: 0.0, child: Container( decoration: BoxDecoration( gradient: LinearGradient( colors: [ Color.fromARGB(200, 0, 0, 0), Color.fromARGB(0, 0, 0, 0) ], begin: Alignment.bottomCenter, end: Alignment.topCenter, ), ), padding: EdgeInsets.symmetric(vertical: 10.0, horizontal: 20.0), child: Text( 'BPS PLAY SCHOOL', style: TextStyle( color: Colors.white, fontSize: 20.0, fontWeight: FontWeight.bold, ), ), ), ), ]), ), ); }, ).toList(); List<T> map<T>(List list, Function handler) { List<T> result = []; for (var i = 0; i < list.length; i++) { result.add(handler(i, list[i])); } return result; } class Home extends StatefulWidget { @override _HomeState createState() => _HomeState(); } class _HomeState extends State<Home> with SingleTickerProviderStateMixin { ScrollController scrollCtrl = new ScrollController(); AnimationController animateCtrl; Choice _selectedChoice = choices[0]; int _current = 0; //Demo notice //Local Json Data String demoNotice = '{"tags": [{"name": "School closed", "date": "16/05/2021"}, {"name": "Lockdown", "date": "25/03/2020"}, {"name": "Result Published", "date": "8/02/2020"}]}'; List notices; final flutterWebviewPlugin = FlutterWebviewPlugin(); //Future Notice Start// @override void initState() { this.getNotice(); double offset = 0.0; animateCtrl = new AnimationController(vsync: this, duration: Duration(seconds: 6)) ..addListener(() { if (scrollCtrl.hasClients) { if (animateCtrl.isCompleted) animateCtrl.repeat(); offset += 1.0; if (offset - 1 > scrollCtrl.offset) { offset = 0.0; } setState(() { scrollCtrl.jumpTo(offset); }); } }); animateCtrl.forward(); super.initState(); flutterWebviewPlugin.close(); flutterWebviewPlugin.onUrlChanged.listen((String url) {}); } Future getNotice() async { var data = json.decode(demoNotice); //print(data['result'][0]['date']); if (!mounted) return; setState(() { notices = data['tags']; }); //do your stuff here req and decode the response } @override void dispose() { animateCtrl.dispose(); super.dispose(); flutterWebviewPlugin.dispose(); } //Future Notice End// void _select(Choice choice) { // Causes the app to rebuild with the new _selectedChoice. _launchURL(); } canLaunch(String url) { if (url.length > 0) return true; else return false; } _launchURL() async { const url = 'https://example.com/privacy_policy.php'; if (await canLaunch(url)) { await launch(url); } else { throw 'Could not launch $url'; } } @override Widget build(BuildContext context) { return Scaffold( backgroundColor: Colors.white, appBar: AppBar( leading: Image.asset('assets/bps.png'), title: Text('BPS Play School'), actions: <Widget>[ // action button // overflow menu PopupMenuButton<Choice>( onSelected: _select, itemBuilder: (BuildContext context) { return choices.map((Choice choice) { return PopupMenuItem<Choice>( value: choice, child: Text(choice.title), ); }).toList(); }, ), ], elevation: 2.0, backgroundColor: Color.fromARGB(255, 255, 0, 0), ), body: Column( mainAxisSize: MainAxisSize.min, children: <Widget>[ Stack(children: [ CarouselSlider( items: child, options: CarouselOptions( aspectRatio: 2.0, autoPlay: true, onPageChanged: (index, reason) { setState(() { _current = index; }); }, ), ), Positioned( top: 150.0, left: 0.0, right: 0.0, child: Row( mainAxisAlignment: MainAxisAlignment.center, children: map<Widget>(imgList, (index, url) { return Container( width: 8.0, height: 8.0, margin: EdgeInsets.symmetric(vertical: 10.0, horizontal: 2.0), decoration: BoxDecoration( shape: BoxShape.circle, color: _current == index ? Color.fromRGBO(0, 0, 0, 0.9) : Color.fromRGBO(0, 0, 0, 0.4)), ); }), )) ]), Padding( padding: const EdgeInsets.symmetric(horizontal: 8.0), child: Wrap( spacing: 8.0, runSpacing: 8.0, direction: Axis.horizontal, children: <Widget>[ ClipRRect( borderRadius: BorderRadius.only( topLeft: Radius.circular(15.0), topRight: Radius.circular(15.0), bottomRight: Radius.circular(15.0), ), child: Container( height: 92.0, width: 104.0, color: greenLight, child: InkWell( onTap: () { Navigator.push( context, MaterialPageRoute( builder: (context) => Admission())); }, child: Column( mainAxisAlignment: MainAxisAlignment.center, children: <Widget>[ Icon( Icons.person, color: green, ), SizedBox( height: 4.0, ), Text( 'Admission', style: TextStyle( color: green, fontWeight: FontWeight.w500), ) ], ), ), ), ), ClipRRect( borderRadius: BorderRadius.only( topLeft: Radius.circular(15.0), topRight: Radius.circular(15.0), bottomRight: Radius.circular(15.0), ), child: Container( height: 92.0, width: 104.0, color: redLight, child: InkWell( onTap: () { Navigator.push(context, MaterialPageRoute(builder: (context) => About())); }, child: Column( mainAxisAlignment: MainAxisAlignment.center, children: <Widget>[ Icon( Icons.school, color: red, ), SizedBox( height: 4.0, ), Text( 'About', style: TextStyle( color: red, fontWeight: FontWeight.w500), ) ], ), ), ), ), ClipRRect( borderRadius: BorderRadius.only( topLeft: Radius.circular(15.0), topRight: Radius.circular(15.0), bottomRight: Radius.circular(15.0), ), child: Container( height: 92.0, width: 104.0, color: blueLight, child: InkWell( onTap: () { Navigator.push(context, MaterialPageRoute(builder: (context) => Contact())); }, child: Column( mainAxisAlignment: MainAxisAlignment.center, children: <Widget>[ Icon( Icons.contact_phone, color: blue, ), SizedBox( height: 4.0, ), Text( 'Contact', style: TextStyle( color: blue, fontWeight: FontWeight.w500), ) ], ), ), ), ), ], ), ), Padding( padding: EdgeInsets.all(2.0), ), ClipRRect( borderRadius: BorderRadius.only( topLeft: Radius.circular(15.0), topRight: Radius.circular(15.0), bottomRight: Radius.circular(15.0), bottomLeft: Radius.circular(15.0)), child: Container( height: 50.0, width: MediaQuery.of(context).size.width / 1.029, color: Colors.amber, child: Center( child: Text( 'Notice Board', style: TextStyle(fontSize: 18.0, color: Colors.white), )), ), ), Expanded( child: notices == null ? Center(child: Text('0 Notice Available')) : ListView.builder( itemCount: notices == null ? 0 : notices.length, //itemCount: 3, itemBuilder: (BuildContext context, int index) { return Card( clipBehavior: Clip.hardEdge, child: ListTile( leading: Icon(Icons.av_timer), title: Text( notices[index]['name'], style: TextStyle(fontStyle: FontStyle.italic), ), subtitle: Text('Posted On: ' + notices[index]['date']), ), ); }, ), ), ], ), ); } } class Choice { const Choice({this.title, this.icon}); final String title; final IconData icon; } const List<Choice> choices = const <Choice>[ const Choice(title: 'Privacy Policy', icon: Icons.security), ];
0
mirrored_repositories/Fluttter-School-App
mirrored_repositories/Fluttter-School-App/lib/student.dart
import 'package:flutter/material.dart'; import 'package:flutter_webview_plugin/flutter_webview_plugin.dart'; import 'package:school/home.dart' ; import 'package:flutter_inappbrowser/flutter_inappbrowser.dart'; import 'package:school/updates.dart'; var green = Color(0xFF4caf6a); var greenLight = Color(0xFFd8ebde); var red = Color(0xFFf36169); var redLight = Color(0xFFf2dcdf); var blue = Color(0xFF398bcf); var blueLight = Color(0xFFc1dbee); class Student extends StatefulWidget { @override _StudentState createState() => _StudentState(); } class _StudentState extends State<Student> { final flutterWebviewPlugin = new FlutterWebviewPlugin(); @override void initState() { super.initState(); flutterWebviewPlugin.close(); flutterWebviewPlugin.onUrlChanged.listen((String url) { }); } @override void dispose() { super.dispose(); flutterWebviewPlugin.dispose(); } @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( title: Text('Student'), elevation: 2.0, backgroundColor: Color.fromARGB(255, 0, 191, 255), ), body: Column( children: <Widget>[ Image.asset( 'assets/1.jpg', width: MediaQuery.of(context).size.width, ), Padding( padding: EdgeInsets.fromLTRB(0.0, 10.0, 0.0, 0.0), ), Padding( padding: const EdgeInsets.symmetric(horizontal: 8.0), child: Wrap( spacing: 8.0, runSpacing: 8.0, direction: Axis.horizontal, children: <Widget>[ ClipRRect( borderRadius: BorderRadius.only( topLeft: Radius.circular(15.0), topRight: Radius.circular(15.0), bottomRight: Radius.circular(15.0), ), child: Container( height: 92.0, width: 104.0, color: greenLight, child: InkWell( onTap: () { Navigator.push( context, MaterialPageRoute( builder: (context) => InAppWebView( initialUrl: 'http://result.bpsplayschool.com/find-result.php', initialOptions: { "javaScriptEnabled":true, "transparentBackground":true, "useWideViewPort":true, "displayZoomControls":true, }, ))); }, child: Column( mainAxisAlignment: MainAxisAlignment.center, children: <Widget>[ Icon( Icons.person, color: green, ), SizedBox( height: 4.0, ), Text( 'Result', style: TextStyle( color: green, fontWeight: FontWeight.w500), ) ], ), ), ), ), ClipRRect( borderRadius: BorderRadius.only( topLeft: Radius.circular(15.0), topRight: Radius.circular(15.0), bottomRight: Radius.circular(15.0), ), child: Container( height: 92.0, width: 104.0, color: redLight, child: InkWell( onTap: () { Navigator.push(context, MaterialPageRoute(builder: (context) => Home())); }, child: Column( mainAxisAlignment: MainAxisAlignment.center, children: <Widget>[ Icon( Icons.timelapse, color: red, ), SizedBox( height: 4.0, ), Text( 'Notice', style: TextStyle( color: red, fontWeight: FontWeight.w500), ) ], ), ), ), ), ClipRRect( borderRadius: BorderRadius.only( topLeft: Radius.circular(15.0), topRight: Radius.circular(15.0), bottomRight: Radius.circular(15.0), ), child: Container( height: 92.0, width: 104.0, color: greenLight, child: InkWell( onTap: () { Navigator.push(context, MaterialPageRoute(builder: (context) => Updates())); }, child: Column( mainAxisAlignment: MainAxisAlignment.center, children: <Widget>[ Icon( Icons.update, color: green, ), SizedBox( height: 4.0, ), Text( 'Update', style: TextStyle( color: green, fontWeight: FontWeight.w500), ) ], ), ), ), ), ClipRRect( borderRadius: BorderRadius.only( topLeft: Radius.circular(15.0), topRight: Radius.circular(15.0), bottomRight: Radius.circular(15.0), ), child: Container( height: 92.0, width: 104.0, color: greenLight, child: InkWell( onTap: () { Navigator.push( context, MaterialPageRoute( builder: (context) => InAppWebView( initialUrl: 'http://result.bpsplayschool.com/find-syllabus.php', initialOptions: { "javaScriptEnabled":true, "transparentBackground":true, "useWideViewPort":true, "displayZoomControls":true, }, ))); }, child: Column( mainAxisAlignment: MainAxisAlignment.center, children: <Widget>[ Icon( Icons.library_books, color: green, ), SizedBox( height: 4.0, ), Text( 'Syllabus', style: TextStyle( color: green, fontWeight: FontWeight.w500), ) ], ), ), ), ), ClipRRect( borderRadius: BorderRadius.only( topLeft: Radius.circular(15.0), topRight: Radius.circular(15.0), bottomRight: Radius.circular(15.0), ), child: Container( height: 92.0, width: 104.0, color: redLight, child: InkWell( onTap: () { Navigator.push( context, MaterialPageRoute( builder: (context) => InAppWebView( initialUrl: 'http://result.bpsplayschool.com/find-routine.php', initialOptions: { "javaScriptEnabled":true, "transparentBackground":true, "useWideViewPort":true, "displayZoomControls":true, }, ))); }, child: Column( mainAxisAlignment: MainAxisAlignment.center, children: <Widget>[ Icon( Icons.book, color: red, ), SizedBox( height: 4.0, ), Text( 'Routine', style: TextStyle( color: red, fontWeight: FontWeight.w500), ) ], ), ), ), ), ClipRRect( borderRadius: BorderRadius.only( topLeft: Radius.circular(15.0), topRight: Radius.circular(15.0), bottomRight: Radius.circular(15.0), ), child: Container( height: 92.0, width: 104.0, color: greenLight, child: InkWell( onTap: () { Navigator.push(context, MaterialPageRoute(builder: (context) => Home())); }, child: Column( mainAxisAlignment: MainAxisAlignment.center, children: <Widget>[ Icon( Icons.person, color: green, ), SizedBox( height: 4.0, ), Text( 'Bus Track', style: TextStyle( color: green, fontWeight: FontWeight.w500), ) ], ), ), ), ), // ClipRRect( // borderRadius: BorderRadius.only( // topLeft: Radius.circular(15.0), // topRight: Radius.circular(15.0), // bottomRight: Radius.circular(15.0), // ), // child: Container( // height: 92.0, // width: 104.0, // color: blueLight, // child: InkWell( // onTap: () { // Scaffold.of(context).showSnackBar(SnackBar( // content: Text('Not Available'), // )); // }, // child: Column( // mainAxisAlignment: MainAxisAlignment.center, // children: <Widget>[ // Icon( // Icons.check_circle, // color: blue, // ), // SizedBox( // height: 4.0, // ), // Text( // 'Attendance', // style: TextStyle( // color: blue, fontWeight: FontWeight.w500), // ) // ], // ), // ), // ), // ), ], ), ), ], )); } }
0
mirrored_repositories/Fluttter-School-App/lib
mirrored_repositories/Fluttter-School-App/lib/school/about.dart
import 'package:flutter/material.dart'; class About extends StatelessWidget { @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( title: Text('About'), elevation: 2.0, ), body: SingleChildScrollView( child: Column( children: <Widget>[ Padding( padding: EdgeInsets.all(3.0), ), Padding( padding: EdgeInsets.all(3.0), ), ClipRRect( borderRadius: BorderRadius.only( topLeft: Radius.circular(15.0), topRight: Radius.circular(15.0), bottomRight: Radius.circular(15.0), bottomLeft: Radius.circular(15.0)), child: Container( child: Image.asset('assets/1.jpg', width: MediaQuery.of(context).size.width / 1.023), ), ), Center( child: Container( margin: EdgeInsets.fromLTRB(10.0, 3.0, 10.0, 13.0), padding: EdgeInsets.all(3.0), child: Card( child: ListTile( title: Text( 'BPS PLAY SCHOOL is a well known school in Tatisilwai area.\nIt is established in month of feb. 2018.And now it is going to spread his education throughouot.The aim of the School is to literate all the children those who belong to remote village area. It is known fact that children do their most important learning before the age five. Up to this age, for kids each morning is the dawn of another amazing adventure. Considering this fact, our focus is only on developing academic skills, but also intellectual, emotional, linguistic, physical, social and moral skills that will ensure all-round development of children. We believe that children are active learners, who learn best from interacting with nature, other children and adults in child-centered activities. BPS PLAY SCHOOL provides caring and trusting environment in which children can flourish as individual. Our child-centered philosophy allows children to learn through play by exploring their environment. In order to stimulate a child\'s learning, we provide opportunities for the child to grow and develop while reading, listening and playing. Love and affection are the hallmarks of all these pursuits. The colorful and cheerful environment, child-friendly equipments, enticing toys and games at BPS PLAY SCHOOL help a child to listen and discover, imagine and create. Overall, BPS PLAY SCHOOL is not merely a school; it is a concept in education. Its a new dimension for an all round development for 2 to 6 years old children. ', style: TextStyle(fontSize: 18.0, fontFamily: "Roboto"), ), ), )), ), ], ), ), ); } }
0
mirrored_repositories/Fluttter-School-App/lib
mirrored_repositories/Fluttter-School-App/lib/school/contact.dart
import 'package:flutter/material.dart'; import 'package:flutter_webview_plugin/flutter_webview_plugin.dart'; class Contact extends StatelessWidget { @override Widget build(BuildContext context) { return Scaffold( body:WebviewScaffold( appBar: AppBar( title: Text('Contact'), elevation: 2.0, ), url: 'https://example.com/contact.php', withJavascript: true, ) , ); } }
0
mirrored_repositories/Fluttter-School-App/lib
mirrored_repositories/Fluttter-School-App/lib/school/admission.dart
import 'package:flutter/material.dart'; import 'package:flutter_webview_plugin/flutter_webview_plugin.dart'; class Admission extends StatefulWidget { @override _AdmissionState createState() => _AdmissionState(); } class _AdmissionState extends State<Admission> { final flutterWebviewPlugin = new FlutterWebviewPlugin(); @override void initState() { super.initState(); flutterWebviewPlugin.close(); } @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( title: Text('Admission'), elevation: 2.0, ), body: Container( padding: EdgeInsets.all(3.0), margin: EdgeInsets.all(5.0), child: Stack( // mainAxisAlignment: MainAxisAlignment.center, // crossAxisAlignment: CrossAxisAlignment.center, children: <Widget>[ ClipRRect( borderRadius: BorderRadius.only( topLeft: Radius.circular(15.0), topRight: Radius.circular(15.0), bottomRight: Radius.circular(15.0), bottomLeft: Radius.circular(15.0)), child: Container( height: 250.0, width: MediaQuery.of(context).size.width / 1.029, color: Colors.amber, child:Image.asset('assets/10.jpg',fit: BoxFit.cover,width: MediaQuery.of(context).size.width,), ), ), // Padding( // padding: EdgeInsets.fromLTRB(0.0, 0.0, 0.0, 0.0), // ), Container( margin: EdgeInsets.fromLTRB(30.0, 120.0, 0.0, 0.0), padding: EdgeInsets.all(5.0), width: MediaQuery.of(context).size.width/1.2, color: Colors.white, child: ListView( children: <Widget>[ Card(child: ListTile( title: Text('You can Registered Online from our official website.(bpsplayschool.com)',style: TextStyle(fontSize: 16.0,fontFamily: "Roboto")), ),), Card(child: ListTile( title: Text('Since the seats are limited you should hurry up! to get admission.'), ),), Card(child: ListTile( title: Text('Registered users must come with their registered slip and application form which you can get from our site ->Admission ->Application Form.'), ),), Card(child: ListTile( title: Text('For direct admission parents can contact to our administration office.'), ),), Card(child: ListTile( title: Text('Application form is available on our office.'), ),), Card(child: ListTile( title: Text('For any queries about admission you can contact us from our email and through our mobile contact number which is given below.'), ),), Padding( padding: EdgeInsets.fromLTRB(0.0, 0.0, 0.0, 5.0), ), ClipRRect( borderRadius: BorderRadius.only( topLeft: Radius.circular(15.0), topRight: Radius.circular(15.0), bottomRight: Radius.circular(15.0), bottomLeft: Radius.circular(15.0)), child: Container( height: 50.0, width: MediaQuery.of(context).size.width / 1.029, color: Colors.amber, child: Center( child: Text( 'Documents Required', style: TextStyle(fontSize: 20.0, color: Colors.white), )), ), ), Padding( padding: EdgeInsets.fromLTRB(0.0, 8.0, 0.0, 0.0), ), Card(child: ListTile( title: Text('For Online registered user they should bring the application form and registration slip.'), ),), Card(child: ListTile( title: Text('For direct admission from will be available on office'), ),), Card(child: ListTile( title: Text('Parents must bring their AADHAAR CARD.'), ),), Card(child: ListTile( title: Text('Two Passport size of children is required.'), ),), Card(child: ListTile( title: Text('Parents must come with their children and parents also.'), ),), Card(child: ListTile( title: Text('ADMISSSION FEE will collected during form submission.'), ),), Card(child: ListTile( title: Text('You can get fee detail from our office.'), ),), Card(child: ListTile( title: Text('All the mandetory documents like TC and character certificate is required for admission above the nursery.'), ),), Center( child: RaisedButton( onPressed: () { Navigator.push( context, MaterialPageRoute( builder: (context) => WebviewScaffold( appBar: AppBar( title: Text("BPS PLAY SCHOOL"), ), url: 'https://example.com/applicationform.php', scrollBar: true, withZoom: true, withLocalStorage: true, hidden: true, initialChild: Container( color: Colors.white, child: const Center( child: Text('Loading..',style: TextStyle(fontFamily: "Roboto",fontWeight: FontWeight.bold),), ), ), ))); }, child: Text( 'Apply Now', style: TextStyle(fontSize: 20.0,color: Colors.white,fontFamily: "Roboto"), ), color: Colors.red, clipBehavior: Clip.antiAlias, ), ) ], ), ) ], ), ), ); } }
0
mirrored_repositories/Super-Store-Ecommerce-App-using-REST-Api-in-Flutter
mirrored_repositories/Super-Store-Ecommerce-App-using-REST-Api-in-Flutter/lib/imports.dart
export 'dart:convert'; export 'view/init_screen/splash.dart'; export 'package:flutter/material.dart'; export 'package:provider/provider.dart'; export 'package:flutter/foundation.dart'; export 'package:super_store_e_commerce_flutter/view/cart/cart.dart'; export 'package:super_store_e_commerce_flutter/view/init_screen/login.dart'; export 'package:super_store_e_commerce_flutter/view/init_screen/register.dart'; export 'package:super_store_e_commerce_flutter/widgets/app_name_widget.dart'; export 'package:super_store_e_commerce_flutter/view/home/home.dart'; export 'package:url_launcher/url_launcher.dart'; export 'package:super_store_e_commerce_flutter/view/drawer/drawer_menu.dart'; export 'package:google_fonts/google_fonts.dart'; export 'package:super_store_e_commerce_flutter/const/raw_string.dart'; export 'package:super_store_e_commerce_flutter/model/cart_model.dart'; export 'package:super_store_e_commerce_flutter/widgets/text/text_builder.dart'; export 'package:super_store_e_commerce_flutter/widgets/text_filed/custom_text_field.dart'; export 'package:super_store_e_commerce_flutter/widgets/card/product_card.dart'; export 'package:super_store_e_commerce_flutter/widgets/card/cart_card.dart'; export 'package:super_store_e_commerce_flutter/const/app_colors.dart'; export 'package:super_store_e_commerce_flutter/utils/url_launch.dart'; export 'package:icons_plus/icons_plus.dart'; export 'package:super_store_e_commerce_flutter/model/product_model.dart'; export 'package:super_store_e_commerce_flutter/controller/cart_provider.dart';
0
mirrored_repositories/Super-Store-Ecommerce-App-using-REST-Api-in-Flutter
mirrored_repositories/Super-Store-Ecommerce-App-using-REST-Api-in-Flutter/lib/main.dart
import 'package:super_store_e_commerce_flutter/imports.dart'; Future<void> main() async { WidgetsFlutterBinding.ensureInitialized(); runApp(const MyApp()); } class MyApp extends StatelessWidget { const MyApp({super.key}); @override Widget build(BuildContext context) { return MultiProvider( providers: [ ChangeNotifierProvider<CartProvider>(create: (context) => CartProvider()), ], child: MaterialApp( title: RawString.appName, debugShowCheckedModeBanner: false, theme: ThemeData( scaffoldBackgroundColor: Colors.white, useMaterial3: true, ), home: const Splash(), ), ); } }
0
mirrored_repositories/Super-Store-Ecommerce-App-using-REST-Api-in-Flutter/lib/view
mirrored_repositories/Super-Store-Ecommerce-App-using-REST-Api-in-Flutter/lib/view/cart/cart.dart
import 'package:super_store_e_commerce_flutter/imports.dart'; class Cart extends StatefulWidget { const Cart({super.key}); @override // ignore: library_private_types_in_public_api _CartState createState() => _CartState(); } class _CartState extends State<Cart> { @override Widget build(BuildContext context) { final cart = Provider.of<CartProvider>(context); Size size = MediaQuery.sizeOf(context); return Scaffold( appBar: AppBar( centerTitle: true, backgroundColor: Colors.white, title: const AppNameWidget(), actions: [ Padding( padding: const EdgeInsets.only(right: 20), child: Container( height: 25, width: 25, alignment: Alignment.center, decoration: const BoxDecoration(shape: BoxShape.circle, color: Colors.black), child: TextBuilder( text: cart.itemCount.toString(), color: Colors.white, fontWeight: FontWeight.w500, fontSize: 10, ), ), ), ], ), body: SafeArea( child: ListView.separated( padding: const EdgeInsets.all(15), itemCount: cart.items.length, shrinkWrap: true, physics: const ScrollPhysics(), itemBuilder: (BuildContext context, int i) { return CartCard(cart: cart.items[i]); }, separatorBuilder: (BuildContext context, int index) { return const SizedBox(height: 10.0); }, ), ), bottomNavigationBar: Padding( padding: const EdgeInsets.all(8.0), child: MaterialButton( height: 60, color: Colors.black, minWidth: size.width, shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(12)), onPressed: () { final ScaffoldMessengerState buyNow = ScaffoldMessenger.of(context); buyNow.showSnackBar( SnackBar( shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(20)), backgroundColor: Colors.black, behavior: SnackBarBehavior.floating, content: const TextBuilder(text: 'Thank you for shopping with us'), ), ); }, child: Row( mainAxisAlignment: MainAxisAlignment.center, children: [ TextBuilder(text: '₹ ${cart.totalPrice()}', color: Colors.white, fontWeight: FontWeight.w600, fontSize: 20), const SizedBox(width: 10.0), const TextBuilder( text: 'Pay Now', color: Colors.white, fontSize: 18, fontWeight: FontWeight.normal, ), ], ), ), ), ); } }
0
mirrored_repositories/Super-Store-Ecommerce-App-using-REST-Api-in-Flutter/lib/view
mirrored_repositories/Super-Store-Ecommerce-App-using-REST-Api-in-Flutter/lib/view/drawer/drawer_menu.dart
import 'package:super_store_e_commerce_flutter/imports.dart'; class DrawerMenu extends StatefulWidget { const DrawerMenu({Key? key}) : super(key: key); @override // ignore: library_private_types_in_public_api _DrawerMenuState createState() => _DrawerMenuState(); } class _DrawerMenuState extends State<DrawerMenu> { @override Widget build(BuildContext context) { return SafeArea( child: Drawer( child: Column( children: [ Expanded( child: Column( children: [ SizedBox( height: 170.0, child: Row( mainAxisAlignment: MainAxisAlignment.center, children: [ CircleAvatar( radius: 35, backgroundColor: Colors.white, backgroundImage: NetworkImage(RawString.appLogoURL), ), const SizedBox(width: 10), Column( crossAxisAlignment: CrossAxisAlignment.start, mainAxisAlignment: MainAxisAlignment.center, children: [ TextBuilder(text: RawString.appName, fontSize: 30.0, fontWeight: FontWeight.bold), TextBuilder(text: RawString.dummyEmail, fontSize: 15.0, fontWeight: FontWeight.normal), ], ), ], ), ), const SizedBox(height: 10.0), Expanded( child: ListView( children: [ ListTile( onTap: () { Navigator.push(context, MaterialPageRoute(builder: (_) => const Home())); }, leading: const Icon( Icons.home, color: Colors.black, size: 20, ), title: const TextBuilder(text: "Home", fontSize: 20.0, fontWeight: FontWeight.w600, color: Colors.black), ), ListTile( onTap: () { Navigator.push(context, MaterialPageRoute(builder: (_) => const Cart())); }, leading: const Icon( Icons.shopping_bag, color: Colors.black, size: 20, ), title: const TextBuilder(text: "Cart", fontSize: 20.0, fontWeight: FontWeight.w600, color: Colors.black), ), ListTile( onTap: () { UrlLaunch.launchInBrowser(urlString: RawString.gitHubRepo); }, leading: const Icon(Icons.source, color: Colors.black, size: 20), title: const TextBuilder(text: "Source code", fontSize: 20.0, fontWeight: FontWeight.w600, color: Colors.black), ), ListTile( onTap: () { UrlLaunch.makeEmail(email: RawString.gitHubRepo, body: 'Hello,', subject: 'Can we Talk?'); }, leading: const Icon( Icons.email, color: Colors.black, size: 20, ), title: const TextBuilder(text: "Contact", fontSize: 20.0, fontWeight: FontWeight.w600, color: Colors.black), ), InkWell( onTap: () { Navigator.pop(context); showAboutDialog( applicationName: RawString.appName, context: context, applicationVersion: '1.0.0+1', ); }, child: const ListTile( leading: Icon( Icons.info, color: Colors.black, size: 20, ), title: TextBuilder(text: "About App", fontSize: 20.0, fontWeight: FontWeight.w600, color: Colors.black), ), ), ], ), ), ], ), ), Container( alignment: Alignment.center, height: 100, child: Column( children: [ const AppNameWidget(), TextBuilder( text: RawString.appDescription, fontSize: 12, ), ], ), ), ], ), ), ); } }
0
mirrored_repositories/Super-Store-Ecommerce-App-using-REST-Api-in-Flutter/lib/view
mirrored_repositories/Super-Store-Ecommerce-App-using-REST-Api-in-Flutter/lib/view/init_screen/register.dart
import 'package:super_store_e_commerce_flutter/imports.dart'; class Register extends StatefulWidget { const Register({super.key}); @override // ignore: library_private_types_in_public_api _RegisterState createState() => _RegisterState(); } class _RegisterState extends State<Register> { @override Widget build(BuildContext context) { // total height and width of screen Size size = MediaQuery.sizeOf(context); return Scaffold( body: SafeArea( child: SingleChildScrollView( padding: const EdgeInsets.all(20.0), child: Column( crossAxisAlignment: CrossAxisAlignment.start, mainAxisAlignment: MainAxisAlignment.center, children: [ const AppNameWidget(), const SizedBox(height: 100), const CustomTextField(labelText: 'Full Name', hintText: 'John Doe', prefixIcon: Icons.person), const SizedBox(height: 20.0), const CustomTextField(labelText: 'Email', hintText: '[email protected]', prefixIcon: Icons.email), const SizedBox(height: 20.0), const CustomTextField(labelText: 'Password', hintText: 'Password', prefixIcon: Icons.lock), const SizedBox(height: 20.0), const CustomTextField(labelText: 'Confirm Password', hintText: 'Confirm Password', prefixIcon: Icons.lock), const SizedBox(height: 30.0), Center( child: MaterialButton( height: 60, color: Colors.black, minWidth: size.width * 0.8, shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(12)), onPressed: () { Navigator.pushAndRemoveUntil(context, MaterialPageRoute(builder: (_) => const Login()), (route) => false); }, child: const TextBuilder( text: 'Sign Up', color: Colors.white, fontSize: 20.0, fontWeight: FontWeight.normal, ), ), ), const SizedBox(height: 20), Row( mainAxisAlignment: MainAxisAlignment.center, children: [ const TextBuilder( text: "Have have an account? ", color: Colors.black, ), InkWell( onTap: () { Navigator.push(context, MaterialPageRoute(builder: (_) => const Login())); }, child: const TextBuilder( text: 'Login', color: Colors.black, fontWeight: FontWeight.bold, ), ) ], ), ], ), ), ), ); } }
0
mirrored_repositories/Super-Store-Ecommerce-App-using-REST-Api-in-Flutter/lib/view
mirrored_repositories/Super-Store-Ecommerce-App-using-REST-Api-in-Flutter/lib/view/init_screen/splash.dart
import 'package:super_store_e_commerce_flutter/imports.dart'; class Splash extends StatefulWidget { const Splash({super.key}); @override SplashState createState() => SplashState(); } class SplashState extends State<Splash> { @override void initState() { super.initState(); Future.delayed(const Duration(seconds: 2)).then((value) => getData()); } getData() { Navigator.pushAndRemoveUntil(context, MaterialPageRoute(builder: (_) => const Login()), (route) => false); } @override Widget build(BuildContext context) { return const Scaffold( body: SafeArea( child: Center(child: AppNameWidget()), ), ); } }
0
mirrored_repositories/Super-Store-Ecommerce-App-using-REST-Api-in-Flutter/lib/view
mirrored_repositories/Super-Store-Ecommerce-App-using-REST-Api-in-Flutter/lib/view/init_screen/login.dart
import 'package:super_store_e_commerce_flutter/imports.dart'; class Login extends StatefulWidget { const Login({super.key}); @override // ignore: library_private_types_in_public_api _LoginState createState() => _LoginState(); } class _LoginState extends State<Login> { final TextEditingController _emailController = TextEditingController(); final TextEditingController _passwordController = TextEditingController(); @override void initState() { super.initState(); } @override Widget build(BuildContext context) { // total height and width of screen Size size = MediaQuery.sizeOf(context); return Scaffold( body: SafeArea( child: SingleChildScrollView( padding: const EdgeInsets.all(20.0), child: Column( crossAxisAlignment: CrossAxisAlignment.start, mainAxisAlignment: MainAxisAlignment.center, children: [ const AppNameWidget(), const SizedBox(height: 100), const CustomTextField(labelText: 'Email', hintText: '[email protected]', prefixIcon: Icons.email), const SizedBox(height: 20.0), const CustomTextField(labelText: 'Password', hintText: 'Password', prefixIcon: Icons.lock), Align( alignment: Alignment.centerRight, child: InkWell( onTap: () {}, child: const TextBuilder( text: 'Forgot Password', fontSize: 16, color: Colors.blue, ), ), ), const SizedBox(height: 30.0), Center( child: MaterialButton( height: 60, color: Colors.black, minWidth: size.width * 0.8, shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(12)), onPressed: () { Navigator.pushAndRemoveUntil(context, MaterialPageRoute(builder: (_) => const Home()), (route) => false); }, child: const TextBuilder( text: 'Login', color: Colors.white, fontSize: 20.0, fontWeight: FontWeight.normal, ), ), ), const SizedBox(height: 20), Row( mainAxisAlignment: MainAxisAlignment.center, children: [ const TextBuilder( text: "Don't have an account? ", color: Colors.black, ), InkWell( onTap: () { Navigator.push(context, MaterialPageRoute(builder: (_) => const Register())); }, child: const TextBuilder( text: 'Sign Up', color: Colors.black, fontWeight: FontWeight.bold, ), ) ], ), ], ), ), ), ); } @override void dispose() { _emailController.dispose(); _passwordController.dispose(); super.dispose(); } }
0
mirrored_repositories/Super-Store-Ecommerce-App-using-REST-Api-in-Flutter/lib/view
mirrored_repositories/Super-Store-Ecommerce-App-using-REST-Api-in-Flutter/lib/view/home/home.dart
import 'package:http/http.dart' as http; import 'package:super_store_e_commerce_flutter/imports.dart'; class Home extends StatefulWidget { const Home({Key? key}) : super(key: key); @override // ignore: library_private_types_in_public_api _HomeState createState() => _HomeState(); } class _HomeState extends State<Home> { final GlobalKey<ScaffoldState> _scaffoldKey = GlobalKey<ScaffoldState>(); Future<List<ProductModel>>? futureProduct; Future<List<ProductModel>> fetchProducts() async { List<ProductModel> products = []; const baseUrl = 'https://fakestoreapi.com/products'; var request = http.Request('GET', Uri.parse(baseUrl)); http.StreamedResponse response = await request.send(); var responseBody = await response.stream.bytesToString(); // Store the response body if (response.statusCode == 200) { if (kDebugMode) { print(responseBody); } final jsonData = jsonDecode(responseBody); products = jsonData.map<ProductModel>((e) => ProductModel.fromJson(e)).toList(); setState(() {}); // Assuming this is within a Stateful widget return products; } else { if (kDebugMode) { print(response.reasonPhrase); } return []; } } @override void initState() { super.initState(); futureProduct = fetchProducts(); WidgetsBinding.instance.addPostFrameCallback((_) {}); } @override Widget build(BuildContext context) { final cart = Provider.of<CartProvider>(context); return Scaffold( key: _scaffoldKey, drawer: const DrawerMenu(), appBar: AppBar( title: const AppNameWidget(), actions: [ IconButton( onPressed: () { Navigator.push(context, MaterialPageRoute(builder: (_) => const Cart())); }, icon: Stack( children: [ Padding( padding: EdgeInsets.only(top: cart.itemCount != 0 ? 8 : 0, right: cart.itemCount != 0 ? 8 : 0), child: const Icon( Icons.shopping_cart, color: Colors.black, size: 30, ), ), if (cart.itemCount != 0) Positioned( top: 0, right: 0, child: Container( height: 20, width: 20, alignment: Alignment.center, decoration: const BoxDecoration(shape: BoxShape.circle, color: Colors.black), child: TextBuilder( text: cart.itemCount.toString(), color: Colors.white, fontWeight: FontWeight.w400, fontSize: 10, ), ), ) ], ), ) ], ), body: SafeArea( child: FutureBuilder<List<ProductModel>>( future: futureProduct, builder: (context, data) { if (data.hasData) { return GridView.builder( padding: const EdgeInsets.all(15), gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount( crossAxisCount: 2, childAspectRatio: 2.5 / 4, mainAxisSpacing: 15, crossAxisSpacing: 15, ), itemCount: data.data!.length, shrinkWrap: true, physics: const ScrollPhysics(), itemBuilder: (BuildContext context, int i) { return ProductCard(product: data.data![i]); }, ); } else if (data.hasError) { return Text("${data.error}"); } return const Center(child: CircularProgressIndicator()); }, ), ), ); } }
0
mirrored_repositories/Super-Store-Ecommerce-App-using-REST-Api-in-Flutter/lib
mirrored_repositories/Super-Store-Ecommerce-App-using-REST-Api-in-Flutter/lib/widgets/app_name_widget.dart
import 'package:super_store_e_commerce_flutter/imports.dart'; class AppNameWidget extends StatelessWidget { const AppNameWidget({Key? key}) : super(key: key); @override Widget build(BuildContext context) { return const Row( mainAxisAlignment: MainAxisAlignment.center, children: [ TextBuilder(text: 'SUPER ', color: AppColors.kBlue, fontSize: 30, fontWeight: FontWeight.w700), TextBuilder(text: 'STORE', color: AppColors.kGreen, fontSize: 30), ], ); } }
0
mirrored_repositories/Super-Store-Ecommerce-App-using-REST-Api-in-Flutter/lib/widgets
mirrored_repositories/Super-Store-Ecommerce-App-using-REST-Api-in-Flutter/lib/widgets/card/product_card.dart
import 'package:super_store_e_commerce_flutter/imports.dart'; class ProductCard extends StatelessWidget { final ProductModel product; const ProductCard({Key? key, required this.product}) : super(key: key); @override Widget build(BuildContext context) { Size size = MediaQuery.sizeOf(context); final cart = Provider.of<CartProvider>(context); return Container( padding: const EdgeInsets.all(2), decoration: BoxDecoration( color: Colors.white, border: Border.all(color: Colors.blue, width: 0.5), borderRadius: BorderRadius.circular(8), ), child: InkWell( onTap: () => openImage(context, size), child: Column( crossAxisAlignment: CrossAxisAlignment.start, mainAxisAlignment: MainAxisAlignment.spaceAround, children: [ Expanded( child: ClipRRect( borderRadius: BorderRadius.circular(20), clipBehavior: Clip.antiAlias, child: Image.network( product.image!, height: size.height, width: double.infinity, fit: BoxFit.contain, colorBlendMode: BlendMode.overlay, ), ), ), const SizedBox(height: 5.0), Padding( padding: const EdgeInsets.all(5.0), child: Column( children: [ Align( alignment: Alignment.topLeft, child: TextBuilder( text: product.title!, color: Colors.black, fontWeight: FontWeight.w400, fontSize: 16, maxLines: 3, textOverflow: TextOverflow.ellipsis, ), ), const SizedBox(height: 5), Align( alignment: Alignment.topLeft, child: Container( padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 4), decoration: BoxDecoration( color: Colors.blue, borderRadius: BorderRadius.circular(5), ), child: TextBuilder( text: product.category, fontSize: 12, color: Colors.white, )), ), const SizedBox(height: 5), Padding( padding: const EdgeInsets.only(left: 2, right: 2), child: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Row( children: [ const TextBuilder( text: '₹ ', fontWeight: FontWeight.bold, color: Colors.blue, ), TextBuilder( text: product.price!.round().toString(), fontWeight: FontWeight.bold, color: Colors.blue, ), ], ), IconButton( splashColor: Colors.blue, tooltip: 'Add to cart', onPressed: () { final ScaffoldMessengerState addToCartMsg = ScaffoldMessenger.of(context); addToCartMsg.showSnackBar( SnackBar( shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(20)), backgroundColor: Colors.black, action: SnackBarAction( label: 'Go to Cart', onPressed: () { Navigator.push(context, MaterialPageRoute(builder: (_) => const Cart())); }), behavior: SnackBarBehavior.floating, content: const TextBuilder(text: 'Product added to cart'), ), ); CartModel cartModel = CartModel( id: product.id!, title: product.title!, price: product.price!, image: product.image!, category: product.category!, quantity: 1, totalPrice: product.price!); cart.addItem(cartModel); // cart.addItem(product.id.toString(), product.title!, product.price, product.image!, product.category!); }, icon: const Icon(Icons.add_shopping_cart_rounded), color: Colors.blue, ), ], ), ), ], ), ), ], ), ), ); } openImage(BuildContext context, Size size) { showDialog( context: context, useSafeArea: true, barrierDismissible: true, builder: (context) { return AlertDialog( actionsPadding: EdgeInsets.zero, buttonPadding: EdgeInsets.zero, contentPadding: const EdgeInsets.all(8), iconPadding: EdgeInsets.zero, elevation: 0, title: SizedBox( width: size.width, child: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ const TextBuilder(text: 'Image'), IconButton( onPressed: () { Navigator.pop(context); }, icon: const Icon( Icons.close, size: 30, color: Colors.black, )) ], ), ), content: InteractiveViewer( minScale: 0.1, maxScale: 1.9, child: Image.network( product.image!, height: size.height * 0.5, width: size.width, ), ), ); }, ); } }
0
mirrored_repositories/Super-Store-Ecommerce-App-using-REST-Api-in-Flutter/lib/widgets
mirrored_repositories/Super-Store-Ecommerce-App-using-REST-Api-in-Flutter/lib/widgets/card/cart_card.dart
import 'package:super_store_e_commerce_flutter/imports.dart'; class CartCard extends StatelessWidget { final CartModel cart; const CartCard({ Key? key, required this.cart, }) : super(key: key); @override Widget build(BuildContext context) { // Size size = MediaQuery.of(context).size; // final totalPrice = (cart.price! * cart.quantity!); final provider = Provider.of<CartProvider>(context); return Container( padding: const EdgeInsets.all(5), decoration: BoxDecoration( color: Colors.white, border: Border.all(color: Colors.blue, width: 0.5), borderRadius: BorderRadius.circular(8), ), child: Row( children: [ Image.network( cart.image!, height: 80, width: 80, fit: BoxFit.contain, ), const SizedBox(width: 10.0), Expanded( child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Row( crossAxisAlignment: CrossAxisAlignment.start, children: [ Expanded( child: TextBuilder( text: '${cart.title} X ${cart.quantity}', color: Colors.black, fontWeight: FontWeight.w400, fontSize: 16, maxLines: 3, textOverflow: TextOverflow.ellipsis, ), ), const SizedBox(width: 5), InkWell( onTap: () { provider.removeItem(cart.id!); }, child: Container( height: 25, width: 25, decoration: const BoxDecoration(shape: BoxShape.circle, color: Colors.black), child: const Icon( Icons.close, color: Colors.white, size: 15, ), ), ) ], ), const SizedBox(height: 10.0), Container( padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 4), decoration: BoxDecoration( color: Colors.blue, borderRadius: BorderRadius.circular(5), ), child: TextBuilder( text: cart.category, fontSize: 12, color: Colors.white, )), const SizedBox(height: 5), Row( children: [ Row( children: [ IconButton( padding: EdgeInsets.zero, onPressed: () { provider.decreaseQuantity(cart.id!); }, icon: const Icon( Icons.remove_circle_outline, color: Colors.black, )), TextBuilder( text: cart.quantity.toString(), color: Colors.black, fontSize: 20, fontWeight: FontWeight.w500, ), IconButton( onPressed: () { provider.increaseQuantity(cart.id!); }, icon: const Icon( Icons.add_circle_outline, color: Colors.black, )) ], ), Expanded( child: Row( crossAxisAlignment: CrossAxisAlignment.start, mainAxisAlignment: MainAxisAlignment.end, children: [ const TextBuilder( text: 'Total: ', fontWeight: FontWeight.bold, fontSize: 18, color: Colors.blue, ), TextBuilder( text: " ₹${cart.price!.round()}", fontWeight: FontWeight.w600, color: Colors.blue, fontSize: 18, ), ], ), ) ], ), ], ), ) ], ), ); } }
0
mirrored_repositories/Super-Store-Ecommerce-App-using-REST-Api-in-Flutter/lib/widgets
mirrored_repositories/Super-Store-Ecommerce-App-using-REST-Api-in-Flutter/lib/widgets/text/text_builder.dart
import 'package:super_store_e_commerce_flutter/imports.dart'; class TextBuilder extends StatelessWidget { final String? text; final double? fontSize; final Color? color; final FontWeight? fontWeight; final double? latterSpacing; final TextOverflow? textOverflow; final int? maxLines; final TextAlign? textAlign; final double? height; final double? wordSpacing; final TextDecoration? textDecoration; final FontStyle? fontStyle; const TextBuilder({ Key? key, this.text, this.fontSize, this.color, this.textOverflow, this.fontWeight, this.latterSpacing, this.maxLines, this.textAlign, this.height, this.wordSpacing, this.textDecoration, this.fontStyle, }) : super(key: key); @override Widget build(BuildContext context) { return Text( text!, style: GoogleFonts.poppins( fontSize: fontSize, color: color, fontWeight: fontWeight, letterSpacing: latterSpacing, height: height, wordSpacing: wordSpacing, decoration: textDecoration, fontStyle: fontStyle, ), maxLines: maxLines, overflow: textOverflow, textAlign: textAlign, ); } }
0
mirrored_repositories/Super-Store-Ecommerce-App-using-REST-Api-in-Flutter/lib/widgets
mirrored_repositories/Super-Store-Ecommerce-App-using-REST-Api-in-Flutter/lib/widgets/text_filed/custom_text_field.dart
import 'package:super_store_e_commerce_flutter/imports.dart'; class CustomTextField extends StatelessWidget { final String labelText; final String? hintText; final IconData? prefixIcon; final TextEditingController? controller; const CustomTextField({Key? key, required this.labelText, this.hintText, this.controller, this.prefixIcon}) : super(key: key); @override Widget build(BuildContext context) { return TextFormField( controller: controller, keyboardType: TextInputType.emailAddress, style: GoogleFonts.poppins(color: Colors.black), decoration: InputDecoration( prefixIcon: Icon( prefixIcon, size: 20, color: Colors.black, ), labelText: labelText, hintText: hintText, border: _border(), ), ); } InputBorder _border() { return OutlineInputBorder( borderRadius: BorderRadius.circular(12), borderSide: const BorderSide(color: Colors.black), ); } }
0
mirrored_repositories/Super-Store-Ecommerce-App-using-REST-Api-in-Flutter/lib
mirrored_repositories/Super-Store-Ecommerce-App-using-REST-Api-in-Flutter/lib/model/product_model.dart
import 'dart:convert'; List<ProductModel> productModelFromJson(String str) => List<ProductModel>.from(json.decode(str).map((x) => ProductModel.fromJson(x))); String productModelToJson(List<ProductModel> data) => json.encode(List<dynamic>.from(data.map((x) => x.toJson()))); class ProductModel { int? id; String? title; double? price; String? description; String? category; String? image; Rating? rating; ProductModel({ this.id, this.title, this.price, this.description, this.category, this.image, this.rating, }); factory ProductModel.fromJson(Map<String, dynamic> json) => ProductModel( id: json["id"], title: json["title"], price: json["price"]?.toDouble(), description: json["description"], category: json["category"]!, image: json["image"], rating: json["rating"] == null ? null : Rating.fromJson(json["rating"]), ); Map<String, dynamic> toJson() => { "id": id, "title": title, "price": price, "description": description, "category": category, "image": image, "rating": rating?.toJson(), }; } class Rating { double? rate; int? count; Rating({ this.rate, this.count, }); factory Rating.fromJson(Map<String, dynamic> json) => Rating( rate: json["rate"]?.toDouble(), count: json["count"], ); Map<String, dynamic> toJson() => { "rate": rate, "count": count, }; }
0