repo_id
stringlengths
21
168
file_path
stringlengths
36
210
content
stringlengths
1
9.98M
__index_level_0__
int64
0
0
mirrored_repositories/flutter_amazon_clone/lib
mirrored_repositories/flutter_amazon_clone/lib/widgets/custom_main_button.dart
import 'package:flutter/material.dart'; class CustomMainButton extends StatelessWidget { final Widget child; final Color color; final bool isLoading; final VoidCallback onPressed; const CustomMainButton( {super.key, required this.child, required this.color, required this.isLoading, required this.onPressed}); @override Widget build(BuildContext context) { Size screenSize = MediaQuery.of(context).size; return ElevatedButton( style: ElevatedButton.styleFrom( backgroundColor: color, fixedSize: Size(screenSize.width * 0.5, 40)), onPressed: onPressed, child: !isLoading ? child : const Padding( padding: EdgeInsets.symmetric(vertical: 5), child: AspectRatio( aspectRatio: 1 / 1, child: CircularProgressIndicator( color: Colors.white, ), ), ), ); } }
0
mirrored_repositories/flutter_amazon_clone/lib
mirrored_repositories/flutter_amazon_clone/lib/widgets/custom_simple_round_button.dart
import 'package:flutter/material.dart'; class CustomSimpleRoundButton extends StatelessWidget { final VoidCallback onPressed; final String text; const CustomSimpleRoundButton( {super.key, required this.onPressed, required this.text}); @override Widget build(BuildContext context) { return GestureDetector( onTap: onPressed, child: Container( padding: const EdgeInsets.all(8), decoration: BoxDecoration( color: Colors.white, borderRadius: BorderRadius.circular(5), border: Border.all(color: Colors.grey, width: 1)), child: Text(text), ), ); } }
0
mirrored_repositories/flutter_amazon_clone/lib
mirrored_repositories/flutter_amazon_clone/lib/widgets/cost_widget.dart
import 'dart:ui'; import 'package:flutter/material.dart'; class CostWidget extends StatelessWidget { final Color color; final double cost; const CostWidget({super.key, required this.color, required this.cost}); @override Widget build(BuildContext context) { return Row( mainAxisSize: MainAxisSize.min, children: [ Text( "₹", style: TextStyle( color: color, fontSize: 10, fontFeatures: const [FontFeature.superscripts()]), ), Text( cost.toInt().toString(), style: TextStyle( fontSize: 25, color: color, fontWeight: FontWeight.w800), ), Text( (cost - cost.truncate()).toString(), style: TextStyle( fontSize: 10, color: color, fontFeatures: const [FontFeature.superscripts()]), ) ], ); } }
0
mirrored_repositories/flutter_amazon_clone/lib
mirrored_repositories/flutter_amazon_clone/lib/widgets/accont_screen_app_bar.dart
import 'package:amazon_clone/screens/search_screen.dart'; import 'package:amazon_clone/utils/color_theme.dart'; import 'package:amazon_clone/utils/constants.dart'; import 'package:flutter/material.dart'; class AccountScreenAppBar extends StatelessWidget implements PreferredSizeWidget { const AccountScreenAppBar({super.key}); @override Size get preferredSize => const Size.fromHeight(kToolbarHeight); @override Widget build(BuildContext context) { Size screenSize = MediaQuery.of(context).size; return Container( height: kAppBarHeight, width: screenSize.width, decoration: const BoxDecoration( gradient: LinearGradient( colors: backgroundGradient, begin: Alignment.centerLeft, end: Alignment.centerRight)), child: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Padding( padding: const EdgeInsets.symmetric(horizontal: 15), child: Image.network( amazonLogoUrl, height: kAppBarHeight * 0.7, ), ), Row( children: [ IconButton( onPressed: () {}, icon: const Icon( Icons.notifications_outlined, color: Colors.black, )), IconButton( onPressed: () { Navigator.push( context, MaterialPageRoute( builder: (context) => const SearchScreen())); }, icon: const Icon( Icons.search_outlined, color: Colors.black, )) ], ) ], ), ); } }
0
mirrored_repositories/flutter_amazon_clone/lib
mirrored_repositories/flutter_amazon_clone/lib/widgets/categories_horizontal_list_view_bar.dart
import 'package:amazon_clone/screens/result_screen.dart'; import 'package:amazon_clone/utils/constants.dart'; import 'package:flutter/widgets.dart'; import 'package:flutter/material.dart'; class CategoriesHorizonatlListviewBar extends StatelessWidget { const CategoriesHorizonatlListviewBar({super.key}); @override Widget build(BuildContext context) { return Container( height: kAppBarHeight, width: double.infinity, color: Colors.white, child: ListView.builder( scrollDirection: Axis.horizontal, itemCount: categoriesList.length, itemBuilder: (context, index) { return GestureDetector( onTap: () { Navigator.push( context, MaterialPageRoute( builder: (context) => ResulstScreen(query: categoriesList[index]), ), ); }, child: Padding( padding: const EdgeInsets.symmetric(vertical: 5, horizontal: 15), child: Center( child: Column( mainAxisSize: MainAxisSize.min, children: [ CircleAvatar( backgroundImage: NetworkImage(categoryLogos[index]), ), Padding( padding: const EdgeInsets.only(top: 10), child: Text(categoriesList[index]), ) ], ), ), ), ); }), ); } }
0
mirrored_repositories/flutter_amazon_clone/lib
mirrored_repositories/flutter_amazon_clone/lib/resources/cloudfirestore_methods.dart
import 'dart:convert'; import 'dart:typed_data'; import 'package:amazon_clone/models/order_requests_model.dart'; import 'package:amazon_clone/models/product_model.dart'; import 'package:amazon_clone/models/review_model.dart'; import 'package:amazon_clone/models/user_details_model.dart'; import 'package:amazon_clone/utils/utils.dart'; import 'package:amazon_clone/widgets/simple_product_widget.dart'; import 'package:cloud_firestore/cloud_firestore.dart'; import 'package:firebase_auth/firebase_auth.dart'; import 'package:firebase_storage/firebase_storage.dart'; import 'package:flutter/material.dart'; class CloudFirestoreClass { FirebaseFirestore firebaseFirestore = FirebaseFirestore.instance; FirebaseAuth firebaseAuth = FirebaseAuth.instance; Future uploadNameAndAddressToDatabase( {required UserDetailsModel user}) async { await firebaseFirestore .collection("users") .doc(firebaseAuth.currentUser!.uid) .set(user.getJson()); } Future getnameAndAddress() async { DocumentSnapshot snap = await firebaseFirestore .collection("users") .doc(firebaseAuth.currentUser!.uid) .get(); //print(snap.data()); UserDetailsModel userModel = UserDetailsModel.getModelFromJson( (snap.data() as dynamic), ); //print(userModel.getJson()); //same as print(snap); return userModel; } Future<String> uploadProductToDatabase({ required Uint8List? image, required String productName, required String rawCost, required int discount, required String sellerName, required String sellerUid, }) async { productName.trim(); rawCost.trim(); String output = "success"; if (image != null && productName != "" && rawCost != "") { try { //do more String uid = Utils().getUid(); String url = await uploadImageToDatabase(image: image, uid: uid); print(url); double cost = double.parse(rawCost); if (discount != 0) { cost = cost * (discount / 100); } ProductModel product = ProductModel( url: url, productName: productName, cost: cost, discount: discount, uid: uid, sellerName: sellerName, sellerUid: sellerUid, rating: 5, noOfRating: 0); await firebaseFirestore .collection("products") .doc(uid) .set(product.getJson()); output = "success"; } catch (e) { output = e.toString(); } } else { output = "Please make sure all the fields are not empty"; } return output; } Future<String> uploadImageToDatabase( {required Uint8List image, required String uid}) async { Reference storageRef = FirebaseStorage.instance.ref().child("products").child(uid); UploadTask uploadTask = storageRef.putData(image); TaskSnapshot task = await uploadTask; return task.ref.getDownloadURL(); } Future<List<Widget>> getProductsfromDiscount(int discount) async { List<Widget> children = []; QuerySnapshot<Map<String, dynamic>> snap = await firebaseFirestore .collection("products") .where("discount", isEqualTo: discount) .get(); for (int i = 0; i < snap.docs.length; i++) { DocumentSnapshot docSnap = snap.docs[i]; ProductModel model = ProductModel.getModelFromJson(json: (docSnap.data() as dynamic)); children.add(SimpleProductWidget(productModel: model)); } return children; } Future uploadReviewToDatabase( {required String productUid, required ReviewModel model}) async { await firebaseFirestore .collection("products") .doc(productUid) .collection("reviews") .add(model.getJson()); await changeAverageRating(productUid: productUid, reviewModel: model); } Future addProductToCart({required ProductModel productModel}) async { await firebaseFirestore .collection("users") .doc(firebaseAuth.currentUser!.uid) .collection("cart") .doc(productModel.uid) .set(productModel.getJson()); //.add(productModel.getJson()); we have to chnage add to set cz add will chnge the existin uid and create overrites existing } Future deleteProductFromCart({required String uid}) async { firebaseFirestore .collection("users") .doc(firebaseAuth.currentUser!.uid) .collection("cart") .doc(uid) .delete(); } Future buyAllItemsInCart({required UserDetailsModel userDetails}) async { QuerySnapshot<Map<String, dynamic>> snapshot = await firebaseFirestore .collection("users") .doc(firebaseAuth.currentUser!.uid) .collection("cart") .get(); for (int i = 0; i < snapshot.docs.length; i++) { ProductModel model = ProductModel.getModelFromJson(json: snapshot.docs[i].data()); addProductToOrders(model: model, userDetails: userDetails); await deleteProductFromCart(uid: model.uid); } } Future addProductToOrders( {required ProductModel model, required UserDetailsModel userDetails}) async { await firebaseFirestore .collection("users") .doc(firebaseAuth.currentUser!.uid) .collection("orders") .add(model.getJson()); await sendOrderRequest(model: model, userDetails: userDetails); } Future sendOrderRequest( {required ProductModel model, required UserDetailsModel userDetails}) async { OrderRequestModel orderRequestModel = OrderRequestModel( orderName: model.productName, buyersAddress: userDetails.address); await firebaseFirestore .collection("users") .doc(model.sellerUid) .collection("orderRequests") .add(orderRequestModel.getJson()); } Future changeAverageRating( {required String productUid, required ReviewModel reviewModel}) async { //5 //1 //5+1/2 DocumentSnapshot snapshot = await firebaseFirestore.collection("products").doc(productUid).get(); ProductModel model = ProductModel.getModelFromJson(json: (snapshot.data() as dynamic)); int currentRating = model.rating; int newRating = (currentRating + reviewModel.rating) ~/ 2; await firebaseFirestore .collection("products") .doc(productUid) .update({"rating": newRating}); } } /** * resources * ========= * * * * */
0
mirrored_repositories/flutter_amazon_clone/lib
mirrored_repositories/flutter_amazon_clone/lib/resources/authentication_methods.dart
import 'package:amazon_clone/models/user_details_model.dart'; import 'package:amazon_clone/resources/cloudfirestore_methods.dart'; import 'package:firebase_auth/firebase_auth.dart'; class AuthenticationMethods { FirebaseAuth firebaseAuth = FirebaseAuth.instance; CloudFirestoreClass cloudFirestoreClass = CloudFirestoreClass(); Future<String> signUpUser( {required String name, required String address, required String email, required String password, required String cPassword}) async { //used to delete all white spaces coming in the textfield name.trim(); address.trim(); email.trim(); password.trim(); cPassword.trim(); String output = "Something went wrong!"; if (name != "" && address != "" && email != "" && password != "" && cPassword != "") { //functions if (password == cPassword) { try { await firebaseAuth.createUserWithEmailAndPassword( email: email, password: password); UserDetailsModel user = UserDetailsModel(name: name, address: address); await cloudFirestoreClass.uploadNameAndAddressToDatabase( user: user); output = "success"; } on FirebaseAuthException catch (e) { output = e.message.toString(); } } else { output = "passwords do not match"; } } else { output = "Please fill up the fields"; } return output; } Future<String> signInUser( {required String email, required String password}) async { //used to delete all white spaces coming in the textfield email.trim(); password.trim(); String output = "Something went wrong!"; if (email != "" && password != "") { //functions try { await firebaseAuth.signInWithEmailAndPassword( email: email, password: password); output = "success"; } on FirebaseAuthException catch (e) { output = e.message.toString(); } } else { output = "Please fill up the fields"; } return output; } }
0
mirrored_repositories/flutter_amazon_clone/lib
mirrored_repositories/flutter_amazon_clone/lib/models/review_model.dart
class ReviewModel{ final String senderName; final String description; final int rating; const ReviewModel({ required this.senderName, required this.description, required this.rating }); factory ReviewModel.getModelFromJson({required Map<String, dynamic> json}) { return ReviewModel( senderName: json["senderName"], description: json["description"], rating: json["rating"]); } Map<String, dynamic> getJson() => { 'senderName': senderName, 'description': description, 'rating': rating, }; }
0
mirrored_repositories/flutter_amazon_clone/lib
mirrored_repositories/flutter_amazon_clone/lib/models/product_model.dart
class ProductModel { final String url; final String productName; final double cost; final int discount; final String uid; final String sellerName; final String sellerUid; final int rating; final int noOfRating; ProductModel( {required this.url, required this.productName, required this.cost, required this.discount, required this.uid, required this.sellerName, required this.sellerUid, required this.rating, required this.noOfRating}); Map<String, dynamic> getJson() { return { 'url': url, 'productName': productName, 'cost': cost, 'discount': discount, 'uid': uid, 'sellerName': sellerName, 'sellerUid': sellerUid, 'rating': rating, 'noOfRating': noOfRating, }; } factory ProductModel.getModelFromJson({required Map<String, dynamic> json}) { return ProductModel( url: json["url"], productName: json["productName"], cost: json["cost"], discount: json["discount"], uid: json["uid"], sellerName: json["sellerName"], sellerUid: json["sellerUid"], rating: json["rating"], noOfRating: json["noOfRating"]); } }
0
mirrored_repositories/flutter_amazon_clone/lib
mirrored_repositories/flutter_amazon_clone/lib/models/user_details_model.dart
class UserDetailsModel { final String name; final String address; UserDetailsModel({ required this.name, required this.address, }); Map<String, dynamic> getJson() => {"name": name, "address": address}; factory UserDetailsModel.getModelFromJson(Map<String, dynamic> json) { return UserDetailsModel(name: json["name"], address: json["address"]); } }
0
mirrored_repositories/flutter_amazon_clone/lib
mirrored_repositories/flutter_amazon_clone/lib/models/order_requests_model.dart
class OrderRequestModel { final String orderName; final String buyersAddress; OrderRequestModel({ required this.orderName, required this.buyersAddress, }); Map<String, dynamic> getJson() => { 'orderName': orderName, 'buyersAddress': buyersAddress, }; factory OrderRequestModel.getModelFromJson( {required Map<String, dynamic> json}) { return OrderRequestModel( orderName: json["orderName"], buyersAddress: json["buyersAddress"]); } }
0
mirrored_repositories/flutter_amazon_clone/lib
mirrored_repositories/flutter_amazon_clone/lib/utils/color_theme.dart
import 'package:flutter/material.dart'; const Color yellowColor = Color(0xfffed813); //Yellow const Color activeCyanColor = Color(0xff0a7c97); const Color backgroundColor = Color(0xffebecee); const List<Color> backgroundGradient = [ Color(0xff80d9e9), Color(0xffa0e9ce), ]; //Cyan, and a mix of Cyan and Green const List<Color> lightBackgroundaGradient = [ Color(0xffa2e0eb), Color.fromARGB(255, 200, 228, 218), ];
0
mirrored_repositories/flutter_amazon_clone/lib
mirrored_repositories/flutter_amazon_clone/lib/utils/constants.dart
import 'package:amazon_clone/models/product_model.dart'; import 'package:amazon_clone/screens/account_screen.dart'; import 'package:amazon_clone/screens/cart_screen.dart'; import 'package:amazon_clone/screens/home_screen.dart'; import 'package:amazon_clone/screens/more_screen.dart'; import 'package:amazon_clone/widgets/simple_product_widget.dart'; import 'package:flutter/material.dart'; const double kAppBarHeight = 80; const String amazonLogoUrl = "https://upload.wikimedia.org/wikipedia/commons/thumb/4/4a/Amazon_icon.svg/2500px-Amazon_icon.svg.png"; const String amazonLogo = "https://upload.wikimedia.org/wikipedia/commons/thumb/a/a9/Amazon_logo.svg/2560px-Amazon_logo.svg.png"; const List<String> categoriesList = [ "Prime", "Mobiles", "Fashion", "Electronics", "Home", "Fresh", "Appliances", "Books, Toys", "Essential" ]; const List<String> categoryLogos = [ "https://m.media-amazon.com/images/I/11uufjN3lYL._SX90_SY90_.png", "https://m.media-amazon.com/images/I/116KbsvwCRL._SX90_SY90_.png", "https://m.media-amazon.com/images/I/115yueUc1aL._SX90_SY90_.png", "https://m.media-amazon.com/images/I/11qyfRJvEbL._SX90_SY90_.png", "https://m.media-amazon.com/images/I/11BIyKooluL._SX90_SY90_.png", "https://m.media-amazon.com/images/I/11CR97WoieL._SX90_SY90_.png", "https://m.media-amazon.com/images/I/01cPTp7SLWL._SX90_SY90_.png", "https://m.media-amazon.com/images/I/11yLyO9f9ZL._SX90_SY90_.png", "https://m.media-amazon.com/images/I/11M0jYc-tRL._SX90_SY90_.png", ]; const List<String> largeAds = [ "https://m.media-amazon.com/images/I/51QISbJp5-L._SX3000_.jpg", "https://m.media-amazon.com/images/I/61jmYNrfVoL._SX3000_.jpg", "https://m.media-amazon.com/images/I/612a5cTzBiL._SX3000_.jpg", "https://m.media-amazon.com/images/I/61fiSvze0eL._SX3000_.jpg", "https://m.media-amazon.com/images/I/61PzxXMH-0L._SX3000_.jpg", ]; const List<String> smallAds = [ "https://m.media-amazon.com/images/I/11M5KkkmavL._SS70_.png", "https://m.media-amazon.com/images/I/11iTpTDy6TL._SS70_.png", "https://m.media-amazon.com/images/I/11dGLeeNRcL._SS70_.png", "https://m.media-amazon.com/images/I/11kOjZtNhnL._SS70_.png", ]; const List<String> adItemNames = [ "Amazon Pay", "Recharge", "Rewards", "Pay Bills" ]; List<String> keysOfRating = [ "Very bad", "Poor", "Average", "Good", "Excellent" ]; const List<Widget> screens = [ HomeScreen(), AccountScreen(), CartScreen(), MoreScreen() ]; List<Widget> testChildren = [ SimpleProductWidget( productModel: ProductModel( url: "https://m.media-amazon.com/images/I/11M5KkkmavL._SS70_.png", productName: "Fariza Latheef", cost: 1000, discount: 50, uid: "asfhf", sellerName: "jhcfbsdjkf", sellerUid: "jfhnadjkf", rating: 1, noOfRating: 1)), SimpleProductWidget( productModel: ProductModel( url: "https://m.media-amazon.com/images/I/11M5KkkmavL._SS70_.png", productName: "Fariza Latheef", cost: 1000, discount: 50, uid: "asfhf", sellerName: "jhcfbsdjkf", sellerUid: "jfhnadjkf", rating: 1, noOfRating: 1)), SimpleProductWidget( productModel: ProductModel( url: "https://m.media-amazon.com/images/I/11M5KkkmavL._SS70_.png", productName: "Fariza Latheef", cost: 1000, discount: 50, uid: "asfhf", sellerName: "jhcfbsdjkf", sellerUid: "jfhnadjkf", rating: 1, noOfRating: 1)), SimpleProductWidget( productModel: ProductModel( url: "https://m.media-amazon.com/images/I/11M5KkkmavL._SS70_.png", productName: "Fariza Latheef", cost: 1000, discount: 50, uid: "asfhf", sellerName: "jhcfbsdjkf", sellerUid: "jfhnadjkf", rating: 1, noOfRating: 1)), SimpleProductWidget( productModel: ProductModel( url: "https://m.media-amazon.com/images/I/11M5KkkmavL._SS70_.png", productName: "Fariza Latheef", cost: 1000, discount: 50, uid: "asfhf", sellerName: "jhcfbsdjkf", sellerUid: "jfhnadjkf", rating: 1, noOfRating: 1)), SimpleProductWidget( productModel: ProductModel( url: "https://m.media-amazon.com/images/I/11M5KkkmavL._SS70_.png", productName: "Fariza Latheef", cost: 1000, discount: 50, uid: "asfhf", sellerName: "jhcfbsdjkf", sellerUid: "jfhnadjkf", rating: 1, noOfRating: 1)), SimpleProductWidget( productModel: ProductModel( url: "https://m.media-amazon.com/images/I/11M5KkkmavL._SS70_.png", productName: "Fariza Latheef", cost: 1000, discount: 50, uid: "asfhf", sellerName: "jhcfbsdjkf", sellerUid: "jfhnadjkf", rating: 1, noOfRating: 1)), SimpleProductWidget( productModel: ProductModel( url: "https://m.media-amazon.com/images/I/11M5KkkmavL._SS70_.png", productName: "Fariza Latheef", cost: 1000, discount: 50, uid: "asfhf", sellerName: "jhcfbsdjkf", sellerUid: "jfhnadjkf", rating: 1, noOfRating: 1)), SimpleProductWidget( productModel: ProductModel( url: "https://m.media-amazon.com/images/I/11M5KkkmavL._SS70_.png", productName: "Fariza Latheef", cost: 1000, discount: 50, uid: "asfhf", sellerName: "jhcfbsdjkf", sellerUid: "jfhnadjkf", rating: 1, noOfRating: 1)), ]; List<String> keyOfRating = ["very bad", "poor", "Average", "good", "Excellent"];
0
mirrored_repositories/flutter_amazon_clone/lib
mirrored_repositories/flutter_amazon_clone/lib/utils/utils.dart
// import 'package:flutter/material.dart'; import 'dart:math'; import 'dart:typed_data'; import 'package:flutter/material.dart'; import 'package:flutter/widgets.dart'; import 'package:image_picker/image_picker.dart'; class Utils { // Size getScreenSize(BuildContext context){ // return MediaQueryData.fromView(View.of(context).size.; // } //snackbar is a small portion coming on bottom of screen showSnackBar({required BuildContext context, required String content}) { //we use context coz we need know where the bottom of the page is //it can be calculated using context ScaffoldMessenger.of(context).showSnackBar( SnackBar( backgroundColor: Colors.grey, shape: const RoundedRectangleBorder( borderRadius: BorderRadius.only( topLeft: Radius.circular(10), topRight: Radius.circular(10))), content: Row( mainAxisAlignment: MainAxisAlignment.center, children: [ Text( content, style: const TextStyle(color: Colors.black), ), ], )), ); } Future<Uint8List?> pickImage() async { ImagePicker picker = ImagePicker(); XFile? file = await picker.pickImage(source: ImageSource.gallery); return file!.readAsBytes(); } String getUid() { return (100000 + Random().nextInt(10000)).toString(); } }
0
mirrored_repositories/flutter_amazon_clone/lib
mirrored_repositories/flutter_amazon_clone/lib/screens/sign_in_screen.dart
// ignore_for_file: prefer_const_constructors import 'package:amazon_clone/resources/authentication_methods.dart'; import 'package:amazon_clone/utils/constants.dart'; import 'package:amazon_clone/screens/sign_up_screen.dart'; import 'package:amazon_clone/utils/color_theme.dart'; import 'package:amazon_clone/utils/utils.dart'; import 'package:amazon_clone/widgets/custom_main_button.dart'; import 'package:amazon_clone/widgets/text_field_widget.dart'; import 'package:flutter/material.dart'; class SignInScreen extends StatefulWidget { const SignInScreen({super.key}); @override State<SignInScreen> createState() => _SignInScreenState(); } class _SignInScreenState extends State<SignInScreen> { TextEditingController emailcontroller = TextEditingController(); TextEditingController passwordController = TextEditingController(); AuthenticationMethods authenticationMethods = AuthenticationMethods(); bool isLoading = false; @override void dispose() { super.dispose(); emailcontroller.dispose(); passwordController.dispose(); } ///Dispose is a method triggered whenever the created object from the stateful widget is removed permanently from the widget tree. It is generally overridden and called only when the state object is destroyed. Dispose releases the memory allocated to the existing variables of the state @override Widget build(BuildContext context) { final screenHeight = MediaQuery.of(context).size.height; final screenWidth = MediaQuery.of(context).size.width; return SafeArea( child: Scaffold( backgroundColor: Colors.white, body: SizedBox( height: screenHeight, width: screenWidth, child: SingleChildScrollView( child: Padding( padding: const EdgeInsets.symmetric(horizontal: 10, vertical: 20), child: Column( mainAxisAlignment: MainAxisAlignment.spaceEvenly, crossAxisAlignment: CrossAxisAlignment.center, children: [ Image.network( amazonLogo, height: screenHeight * 0.10, //width: screenWidth* 0.5, ), SizedBox( height: 30, ), Container( height: screenHeight * 0.6, width: screenWidth * 0.8, padding: const EdgeInsets.all(25), decoration: BoxDecoration( border: Border.all(color: Colors.grey, width: 1)), child: Column( mainAxisSize: MainAxisSize.min, mainAxisAlignment: MainAxisAlignment.spaceBetween, crossAxisAlignment: CrossAxisAlignment.start, children: [ const Text( "Sign-In", style: TextStyle( fontWeight: FontWeight.w500, fontSize: 33), ), TextFieldWidget( title: "Email", controller: emailcontroller, obscureText: false, hintText: "Enter your email"), TextFieldWidget( title: "Password", controller: passwordController, obscureText: true, hintText: "Enter your password"), Align( alignment: Alignment.center, child: CustomMainButton( color: yellowColor, isLoading: isLoading, onPressed: () async { setState(() { isLoading = true; }); String output = await authenticationMethods.signInUser( email: emailcontroller.text, password: passwordController.text); setState(() { isLoading = false; }); if (output == "success") { //functions } else { //error Utils().showSnackBar( context: context, content: output); } }, child: const Text( "Sign In", style: TextStyle( letterSpacing: 0.6, color: Colors.black), )), ), ], ), ), SizedBox( height: 40, ), Row( children: [ Expanded( child: Container( height: 1, color: Colors.grey, )), const Padding( padding: EdgeInsets.symmetric(vertical: 10), child: Text( "New to Amazon", style: TextStyle(color: Colors.grey), ), ), Expanded( child: Container( height: 1, color: Colors.grey, )), ], ), SizedBox( height: 40, ), CustomMainButton( child: const Text( "Create an Amazon Account", style: TextStyle(letterSpacing: 0.6, color: Colors.black), ), color: Colors.grey[400]!, isLoading: false, onPressed: () { Navigator.pushReplacement(context, MaterialPageRoute(builder: (context) { return const SignUpScreen(); })); }) ], ), ), ), ), ), ); } }
0
mirrored_repositories/flutter_amazon_clone/lib
mirrored_repositories/flutter_amazon_clone/lib/screens/cart_screen.dart
import 'package:amazon_clone/models/product_model.dart'; import 'package:amazon_clone/providers/user_details_provider.dart'; import 'package:amazon_clone/resources/cloudfirestore_methods.dart'; import 'package:amazon_clone/utils/color_theme.dart'; import 'package:amazon_clone/utils/constants.dart'; import 'package:amazon_clone/utils/utils.dart'; import 'package:amazon_clone/widgets/cart_item_widget.dart'; import 'package:amazon_clone/widgets/custom_main_button.dart'; import 'package:amazon_clone/widgets/search_bar_widget.dart'; import 'package:amazon_clone/widgets/user_details_bar.dart'; import 'package:cloud_firestore/cloud_firestore.dart'; import 'package:firebase_auth/firebase_auth.dart'; import 'package:firebase_core/firebase_core.dart'; import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; class CartScreen extends StatefulWidget { const CartScreen({super.key}); @override State<CartScreen> createState() => _CartScreenState(); } class _CartScreenState extends State<CartScreen> { @override Widget build(BuildContext context) { return Scaffold( appBar: SearchBarWidget(hasBackButton: false, isReadOnly: true), body: Center( child: Stack( children: [ Column( children: [ const SizedBox( height: kAppBarHeight / 2, ), Padding( padding: const EdgeInsets.all(20), child: Center( child: StreamBuilder( stream: FirebaseFirestore.instance .collection("users") .doc(FirebaseAuth.instance.currentUser!.uid) .collection("cart") .snapshots(), builder: (context, AsyncSnapshot<QuerySnapshot<Map<String, dynamic>>> snapshot) { if (snapshot.connectionState == ConnectionState.waiting) { return CustomMainButton( color: yellowColor, isLoading: true, onPressed: () {}, child: const Text("Loading")); } else { return CustomMainButton( color: yellowColor, isLoading: false, onPressed: () async { await CloudFirestoreClass() .buyAllItemsInCart( userDetails: Provider.of< UserDetailsProvider>( context, listen: false) .userDetails!); Utils().showSnackBar( context: context, content: "Done"); }, child: Text( "Proceed to buy (${snapshot.data!.docs.length}) items", style: const TextStyle(color: Colors.black), )); } })), ), Expanded( child: StreamBuilder( stream: FirebaseFirestore.instance .collection("users") .doc(FirebaseAuth.instance.currentUser!.uid) .collection("cart") .snapshots(), builder: (context, AsyncSnapshot<QuerySnapshot<Map<String, dynamic>>> snapshot) { if (snapshot.connectionState == ConnectionState.waiting) { return Container(); } else { return ListView.builder( itemBuilder: (context, index) { ProductModel model = ProductModel.getModelFromJson( json: snapshot.data!.docs[index].data()); return CartItemWidget(product: model); }, itemCount: snapshot.data!.docs.length); } }, ), ) ], ), const UserDetailsBar( offset: 0, ), ], ), ), ); } } /** * cart_screen.dart * ============== * -edit constants * -state full widget * -add * -SearchBarWidget * -UserDetailsBar * -CustomMainButton * -make * Widgets:cart_item_widget.dart * ---------------- * -create its UI * -we wanted the cart item horizontally divided by three rows in 5:1:1 ratio * -we acquire it through 3Expanded widgets with flex 5:1:1 * - to add info of product create a new wIDGET:product_information_widget.dart * -create three parameters name,cost,sellername * -insert ProductInformationWidget to the item page * - to add info of product codt craete Widgets:cost_widget.dart * -crteate two parameters color,cost * -create new widget:custom_square_buton.dart * -------------------- * -stateless * -tehse are to apply add,delete operations of cart item * -passs parameters child,color,onPressesd,dimention * -add it in cart_item_widget * -crete new custom_simple_rounded_button.dart * ------------- * -pass two parameters onpressed,text * * -connect it with cartscreeen * -give a ListView builder and give CartItemWidget() * -creating values of product info in cart_item widget * -changing value static to dynamic * -it will take a lot of time * -so we start a collection for it in the database * -create models:product_model.dart * -pass off fields of DB table * final String url; final String productName; final double cost; final int discount; final String uid; final String sellerName; final String sellerUid; final int rating; final int noOfRating; *-fix tis at top of cart_item as a parameter -change all values inside the cart_item page to parameter.value * * * working of cart items from DB * ===================== * -delete entire listview.builder * -add stremBuilder there * -make the proceed to buy n items showing button work * -wrap the button inside a stream builder and implement it there * * delete button work * -make a function deleteProductFromCart in cloudfirestore * -use it in delete buttons onpressed on cartitemwidget * * add button work * -crete on the onPreseed of that button * * buy all items cart button functional by buying all * -------------- * -create function buyAllItemsinCart in cloudfirestore * - */
0
mirrored_repositories/flutter_amazon_clone/lib
mirrored_repositories/flutter_amazon_clone/lib/screens/home_screen.dart
import 'package:amazon_clone/resources/cloudfirestore_methods.dart'; import 'package:amazon_clone/utils/constants.dart'; import 'package:amazon_clone/widgets/banner_add_widget.dart'; import 'package:amazon_clone/widgets/categories_horizontal_list_view_bar.dart'; import 'package:amazon_clone/widgets/loading_widget.dart'; import 'package:amazon_clone/widgets/products_showcase_list_view.dart'; import 'package:amazon_clone/widgets/search_bar_widget.dart'; import 'package:amazon_clone/widgets/user_details_bar.dart'; import 'package:flutter/material.dart'; class HomeScreen extends StatefulWidget { const HomeScreen({super.key}); @override State<HomeScreen> createState() => _HomeScreenState(); } class _HomeScreenState extends State<HomeScreen> { ScrollController controller = ScrollController(); double offset = 0; List<Widget>? discount70; List<Widget>? discount60; List<Widget>? discount50; List<Widget>? discount0; @override void initState() { super.initState(); getData(); //if anything changes in the screen we want to deetct it by the controller to controll the scrolling controller.addListener(() { setState(() { offset = controller.position.pixels; }); //print(controller.position.pixels); }); } @override void dispose() { super.dispose(); controller.dispose(); } void getData() async { List<Widget> temp70 = await CloudFirestoreClass().getProductsfromDiscount(70); List<Widget> temp60 = await CloudFirestoreClass().getProductsfromDiscount(60); List<Widget> temp50 = await CloudFirestoreClass().getProductsfromDiscount(50); //0 fro the explore product list section List<Widget> temp0 = await CloudFirestoreClass().getProductsfromDiscount(0); setState(() { discount70 = temp70; discount60 = temp60; discount50 = temp50; discount0 = temp0; }); } @override Widget build(BuildContext context) { print("everything fine==================="); return Scaffold( appBar: SearchBarWidget(hasBackButton: false, isReadOnly: true), body: discount70 != null && discount60 != null && discount50 != null && discount0 != null ? Stack(children: [ SingleChildScrollView( controller: controller, child: Column( children: [ const SizedBox( height: kAppBarHeight / 2, ), const CategoriesHorizonatlListviewBar(), const BannerAddWidget(), ProductsShowcaseListView( title: "Upto 70% off", children: discount70!), ProductsShowcaseListView( title: "Upto 60% off", children: discount60!), ProductsShowcaseListView( title: "Upto 50% off", children: discount50!), ProductsShowcaseListView( title: "Explore", children: discount0!) ], )), UserDetailsBar( offset: offset, ) ]) : const LoadingWidget(), ); } }
0
mirrored_repositories/flutter_amazon_clone/lib
mirrored_repositories/flutter_amazon_clone/lib/screens/more_screen.dart
import 'package:amazon_clone/utils/constants.dart'; import 'package:amazon_clone/widgets/category_widget.dart'; import 'package:amazon_clone/widgets/search_bar_widget.dart'; import 'package:flutter/material.dart'; class MoreScreen extends StatelessWidget { const MoreScreen({super.key}); @override Widget build(BuildContext context) { return Scaffold( appBar: SearchBarWidget(hasBackButton: true, isReadOnly: false), body: Padding( padding: const EdgeInsets.all(8.0), child: GridView.builder( gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount( crossAxisCount: 3, crossAxisSpacing: 15, childAspectRatio: 2.2 / 3.5, mainAxisSpacing: 15), itemCount: categoriesList.length, itemBuilder: (context, index) => CategoryWidget(index: index), ), )); } } /** * more_screen.dart * ============== * stateless * only stateless screen * change constants * on category screen * -------------- * -on ontap pass the call to result screen * */
0
mirrored_repositories/flutter_amazon_clone/lib
mirrored_repositories/flutter_amazon_clone/lib/screens/result_screen.dart
import 'package:amazon_clone/models/product_model.dart'; import 'package:amazon_clone/widgets/loading_widget.dart'; import 'package:amazon_clone/widgets/results_widget.dart'; import 'package:amazon_clone/widgets/search_bar_widget.dart'; import 'package:cloud_firestore/cloud_firestore.dart'; import 'package:flutter/material.dart'; class ResulstScreen extends StatelessWidget { final String query; const ResulstScreen({super.key, required this.query}); @override Widget build(BuildContext context) { return Scaffold( appBar: SearchBarWidget(hasBackButton: false, isReadOnly: true), body: Column( children: [ Align( alignment: Alignment.centerLeft, child: Padding( padding: const EdgeInsets.all(15), child: RichText( text: TextSpan(children: [ const TextSpan( text: "Showing results for ", style: TextStyle(fontSize: 17)), TextSpan( text: query, style: const TextStyle( fontSize: 17, fontStyle: FontStyle.italic)) ]), ), ), ), Expanded( child: FutureBuilder( future: FirebaseFirestore.instance .collection("products") .where("productName", isEqualTo: query) .get(), builder: (context, AsyncSnapshot<QuerySnapshot<Map<String, dynamic>>> snapshot) { if (snapshot.connectionState == ConnectionState.waiting) { return LoadingWidget(); } else { return GridView.builder( gridDelegate: SliverGridDelegateWithFixedCrossAxisCount( crossAxisCount: 3, childAspectRatio: 2 / 3.5), itemCount: snapshot.data!.docs.length, itemBuilder: (context, index) { ProductModel product = ProductModel.getModelFromJson( json: snapshot.data!.docs[index].data()); return ResultWidget(product: product); }, ); } }), ) ], ), ); } } /** * result_screen.dart * ================== * this screen the search result screen * create new widgets:category_widget.dart * ----------------------- * this widget is for specific category * code the UI * add a parameter query * -edit the main.dart * -inside * -else if (user.hasData) { * -comment =>return const ScreenLayout(); * -add new return to ResultScreen * * -create new widget:result_widget.dart * --------------------------------- * this widget is for specific product * add a parameter product as object of ProductModel * this is to add product details * -create new widget:rating_star_widget.dart * -------------------- * this is to add a rating star below every products * * * * */
0
mirrored_repositories/flutter_amazon_clone/lib
mirrored_repositories/flutter_amazon_clone/lib/screens/sign_up_screen.dart
import 'package:amazon_clone/resources/authentication_methods.dart'; import 'package:amazon_clone/screens/sign_in_screen.dart'; import 'package:amazon_clone/utils/constants.dart'; import 'package:amazon_clone/utils/color_theme.dart'; import 'package:amazon_clone/utils/utils.dart'; import 'package:amazon_clone/widgets/custom_main_button.dart'; import 'package:amazon_clone/widgets/text_field_widget.dart'; import 'package:flutter/material.dart'; class SignUpScreen extends StatefulWidget { const SignUpScreen({super.key}); @override State<SignUpScreen> createState() => _SignUpScreenState(); } class _SignUpScreenState extends State<SignUpScreen> { TextEditingController nameController = TextEditingController(); TextEditingController emailController = TextEditingController(); TextEditingController addressController = TextEditingController(); TextEditingController passwordController = TextEditingController(); TextEditingController confirmPasswordController = TextEditingController(); AuthenticationMethods authenticationMethods = AuthenticationMethods(); bool isLoading = false; @override void dispose() { super.dispose(); nameController.dispose(); emailController.dispose(); passwordController.dispose(); addressController.dispose(); } @override Widget build(BuildContext context) { final screenHeight = MediaQuery.of(context).size.height; final screenWidth = MediaQuery.of(context).size.width; return Scaffold( backgroundColor: Colors.white, body: SizedBox( height: screenHeight, width: screenWidth, child: SingleChildScrollView( child: Padding( padding: const EdgeInsets.symmetric(horizontal: 10, vertical: 20), child: Column( mainAxisAlignment: MainAxisAlignment.spaceEvenly, crossAxisAlignment: CrossAxisAlignment.center, children: [ Image.network( amazonLogo, height: screenHeight * 0.10, ), SizedBox( height: 30, ), SizedBox( height: screenHeight * 0.8, width: screenWidth, child: FittedBox( child: Container( height: screenHeight * 0.85, width: screenWidth * 0.8, padding: const EdgeInsets.all(25), decoration: BoxDecoration( border: Border.all(color: Colors.grey, width: 1)), child: Column( mainAxisSize: MainAxisSize.min, mainAxisAlignment: MainAxisAlignment.spaceBetween, crossAxisAlignment: CrossAxisAlignment.start, children: [ const Text( "Sign-Up", style: TextStyle( fontWeight: FontWeight.w500, fontSize: 33), ), TextFieldWidget( title: "Name", controller: nameController, obscureText: false, hintText: "Enter your name"), TextFieldWidget( title: "Address", controller: addressController, obscureText: false, hintText: "Enter your address"), TextFieldWidget( title: "Email", controller: emailController, obscureText: false, hintText: "Enter your email"), TextFieldWidget( title: "Password", controller: passwordController, obscureText: true, hintText: "Enter your password"), TextFieldWidget( title: "Confirm Password", controller: confirmPasswordController, obscureText: true, hintText: "Confirm your password"), Align( alignment: Alignment.center, child: CustomMainButton( color: yellowColor, isLoading: isLoading, onPressed: () async { setState(() { isLoading = true; }); String output = await authenticationMethods.signUpUser( name: nameController.text, address: addressController.text, email: emailController.text, password: passwordController.text, cPassword: confirmPasswordController.text); setState(() { isLoading = false; }); if (output == "success") { // ignore: use_build_context_synchronously Navigator.pushReplacement( context, MaterialPageRoute( builder: (_) => const SignInScreen())); //functions print("doing next step"); } else { //error messages //log(output); // ignore: use_build_context_synchronously Utils().showSnackBar( context: context, content: output); } }, child: const Text( "Sign Up", style: TextStyle( letterSpacing: 0.6, color: Colors.black), )), ), ], ), ), ), ), const SizedBox( height: 40, ), CustomMainButton( color: Colors.grey[400]!, isLoading: false, onPressed: () { Navigator.pushReplacement(context, MaterialPageRoute(builder: (context) { return const SignInScreen(); })); }, child: const Text( "Back", style: TextStyle(letterSpacing: 0.6, color: Colors.black), )) ], ), ), ), ), ); } }
0
mirrored_repositories/flutter_amazon_clone/lib
mirrored_repositories/flutter_amazon_clone/lib/screens/account_screen.dart
import 'package:amazon_clone/models/order_requests_model.dart'; import 'package:amazon_clone/models/product_model.dart'; import 'package:amazon_clone/models/user_details_model.dart'; import 'package:amazon_clone/providers/user_details_provider.dart'; import 'package:amazon_clone/screens/sell_screen.dart'; import 'package:amazon_clone/utils/color_theme.dart'; import 'package:amazon_clone/utils/constants.dart'; import 'package:amazon_clone/widgets/accont_screen_app_bar.dart'; import 'package:amazon_clone/widgets/custom_main_button.dart'; import 'package:amazon_clone/widgets/products_showcase_list_view.dart'; import 'package:amazon_clone/widgets/simple_product_widget.dart'; import 'package:cloud_firestore/cloud_firestore.dart'; import 'package:firebase_auth/firebase_auth.dart'; import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; class AccountScreen extends StatefulWidget { const AccountScreen({super.key}); @override State<AccountScreen> createState() => _AccountScreenState(); } class _AccountScreenState extends State<AccountScreen> { @override Widget build(BuildContext context) { Size screenSize = MediaQuery.of(context).size; return Scaffold( backgroundColor: Colors.white, appBar: const AccountScreenAppBar(), body: SingleChildScrollView( child: SizedBox( height: screenSize.height - (kAppBarHeight / 2), width: screenSize.width, child: Column( children: [ const IntroductionWidgetAccountScreen(), Padding( padding: const EdgeInsets.all(8.0), child: CustomMainButton( child: const Text("Sign Out", style: TextStyle(color: Colors.black)), color: Colors.orange, isLoading: false, onPressed: () { FirebaseAuth.instance.signOut(); }), ), Padding( padding: const EdgeInsets.all(8.0), child: CustomMainButton( child: const Text("Sell", style: TextStyle(color: Colors.black)), color: yellowColor, isLoading: false, onPressed: () { Navigator.push( context, MaterialPageRoute( builder: (context) => const SellScreen(), )); }), ), //future Builder is just like the stream builder //dosnt constantly listen for the changes it wait for a //future function or async or await to complete and rebuild the builder FutureBuilder( future: FirebaseFirestore.instance .collection("users") .doc(FirebaseAuth.instance.currentUser!.uid) .collection("orders") .get(), builder: (context, AsyncSnapshot<QuerySnapshot<Map<String, dynamic>>> snapshot) { if (snapshot.connectionState == ConnectionState.waiting) { return Container(); } else { List<Widget> children = []; for (int i = 0; i < snapshot.data!.docs.length; i++) { ProductModel model = ProductModel.getModelFromJson( json: snapshot.data!.docs[i].data()); children.add(SimpleProductWidget(productModel: model)); } return ProductsShowcaseListView( title: "Your Orders", children: children); } }), const Padding( padding: EdgeInsets.all(15), child: Align( alignment: Alignment.centerLeft, child: Text( "Order Requests", style: TextStyle(fontSize: 17, fontWeight: FontWeight.w900), )), ), Expanded( child: StreamBuilder( stream: FirebaseFirestore.instance .collection("users") .doc(FirebaseAuth.instance.currentUser!.uid) .collection("orderRequests") .snapshots(), builder: (context, AsyncSnapshot<QuerySnapshot<Map<String, dynamic>>> snapshot) { if (snapshot.connectionState == ConnectionState.waiting) { return Container(); } else { return ListView.builder( itemCount: snapshot.data!.docs.length, itemBuilder: (context, index) { OrderRequestModel model = OrderRequestModel.getModelFromJson( json: snapshot.data!.docs[index].data()); return ListTile( title: Text( "Order: ${model.orderName}", style: TextStyle(fontWeight: FontWeight.w500), ), subtitle: Text("Address: ${model.buyersAddress}"), trailing: IconButton( onPressed: () async { FirebaseFirestore.instance .collection("users") .doc(FirebaseAuth .instance.currentUser!.uid) .collection("orderRequests") .doc(snapshot.data!.docs[index].id) .delete(); }, icon: Icon(Icons.check)), ); ; }); } }, ), ), ], ), ), ), ); } } class IntroductionWidgetAccountScreen extends StatelessWidget { const IntroductionWidgetAccountScreen({ super.key, }); @override Widget build(BuildContext context) { UserDetailsModel userDetails = Provider.of<UserDetailsProvider>( context, listen: true, ).userDetails!; return Container( height: kAppBarHeight / 2, decoration: const BoxDecoration( gradient: LinearGradient( colors: backgroundGradient, begin: Alignment.centerLeft, end: Alignment.centerRight)), child: Container( height: kAppBarHeight / 2, decoration: BoxDecoration( gradient: LinearGradient( colors: [Colors.white, Colors.white.withOpacity(0.00000000001)], begin: Alignment.bottomCenter, end: Alignment.topCenter), ), child: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Padding( padding: const EdgeInsets.symmetric(horizontal: 17), child: RichText( text: TextSpan(children: [ const TextSpan( text: "Hello, ", style: TextStyle( color: Colors.black, fontSize: 27, )), TextSpan( text: "${userDetails.name}", style: const TextStyle( color: Colors.black, fontSize: 27, fontWeight: FontWeight.bold)) ])), ), const Padding( padding: EdgeInsets.only(right: 20), child: CircleAvatar( backgroundImage: NetworkImage( "https://i0.wp.com/www.tech-sisters.com/wp-content/uploads/2020/02/muslim-women-in-tech-amina-aweis-profile-picture.jpg?resize=400%2C400"), ), ) ], )), ); } }
0
mirrored_repositories/flutter_amazon_clone/lib
mirrored_repositories/flutter_amazon_clone/lib/screens/search_screen.dart
import 'package:amazon_clone/widgets/search_bar_widget.dart'; import 'package:flutter/material.dart'; class SearchScreen extends StatelessWidget { const SearchScreen({super.key}); @override Widget build(BuildContext context) { return Scaffold( appBar: SearchBarWidget(hasBackButton: true, isReadOnly: false), ); } }
0
mirrored_repositories/flutter_amazon_clone/lib
mirrored_repositories/flutter_amazon_clone/lib/screens/product_screen.dart
import 'package:amazon_clone/models/product_model.dart'; import 'package:amazon_clone/models/review_model.dart'; import 'package:amazon_clone/providers/user_details_provider.dart'; import 'package:amazon_clone/resources/cloudfirestore_methods.dart'; import 'package:amazon_clone/utils/color_theme.dart'; import 'package:amazon_clone/utils/constants.dart'; import 'package:amazon_clone/utils/utils.dart'; import 'package:amazon_clone/widgets/cost_widget.dart'; import 'package:amazon_clone/widgets/custom_main_button.dart'; import 'package:amazon_clone/widgets/custom_simple_round_button.dart'; import 'package:amazon_clone/widgets/rating_star_widget.dart'; import 'package:amazon_clone/widgets/review_dialog.dart'; import 'package:amazon_clone/widgets/review_widget.dart'; import 'package:amazon_clone/widgets/search_bar_widget.dart'; import 'package:amazon_clone/widgets/user_details_bar.dart'; import 'package:cloud_firestore/cloud_firestore.dart'; import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; class ProductScreen extends StatefulWidget { final ProductModel product; const ProductScreen({super.key, required this.product}); @override State<ProductScreen> createState() => _ProductScreenState(); } class _ProductScreenState extends State<ProductScreen> { Expanded spaceThing = Expanded(child: Container()); @override Widget build(BuildContext context) { Size screenSize = MediaQuery.of(context).size; return SafeArea( child: Scaffold( appBar: SearchBarWidget(hasBackButton: true, isReadOnly: true), body: Stack( children: [ SingleChildScrollView( child: Padding( padding: const EdgeInsets.symmetric(horizontal: 20.0), child: Column( children: [ SizedBox( height: screenSize.height - (kAppBarHeight + (kAppBarHeight / 2)), child: Column( children: [ const SizedBox( height: kAppBarHeight / 2, ), Padding( padding: const EdgeInsets.symmetric(vertical: 10.0), child: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Padding( padding: const EdgeInsets.only(bottom: 5.0), child: Text( widget.product.sellerName, style: const TextStyle( color: activeCyanColor, fontSize: 16, fontWeight: FontWeight.w700), ), ), Container( width: 300, child: Text( widget.product.productName, style: const TextStyle( overflow: TextOverflow.ellipsis, fontSize: 16, fontWeight: FontWeight.w600, ), ), ) ], ), RatingStar( rating: widget.product.rating, ) ], ), ), Padding( padding: const EdgeInsets.all(15), child: Container( height: screenSize.height / 3, constraints: BoxConstraints( maxHeight: screenSize.height / 3), child: Image.network(widget.product.url), ), ), spaceThing, CostWidget( color: Colors.black, cost: widget.product.cost), spaceThing, CustomMainButton( color: Colors.orange, isLoading: false, onPressed: () async { CloudFirestoreClass().addProductToOrders( model: widget.product, userDetails: Provider.of<UserDetailsProvider>( context, listen: false) .userDetails!); Utils().showSnackBar( context: context, content: "Done"); }, child: const Text("Buy Now", style: TextStyle(color: Colors.black))), spaceThing, CustomMainButton( color: yellowColor, isLoading: false, onPressed: () async { await CloudFirestoreClass().addProductToCart( productModel: widget.product); Utils().showSnackBar( context: context, content: "Added to Cart"); }, child: const Text("Add to Cart", style: TextStyle(color: Colors.black))), spaceThing, CustomSimpleRoundButton( onPressed: () { showDialog( context: context, builder: (context) => RiviewDialog( productUid: widget.product.uid)); }, text: "Add a review for this product"), ], ), ), SizedBox( height: screenSize.height, child: StreamBuilder( stream: FirebaseFirestore.instance .collection("products") .doc(widget.product.uid) .collection("reviews") .snapshots(), builder: (context, AsyncSnapshot<QuerySnapshot<Map<String, dynamic>>> snapshot) { if (snapshot.connectionState == ConnectionState.waiting) { return Container(); } else { return ListView.builder( itemCount: snapshot.data!.docs.length, itemBuilder: (context, index) { ReviewModel model = ReviewModel.getModelFromJson( json: snapshot.data!.docs[index].data()); return ReviewWidget(review: model); }, ); } }, ), ), ], ), ), ), const UserDetailsBar( offset: 0, ) ], ), ), ); } } /** * create product_screen.dart * add parameter ProductModel clss object * add * rating_star widget and user_details_model * add * Custom Main Button 2 * add CustomSimpleButton * -create a model class named review_model * -this is for creating the riview button work in DB * -create new widget:review_widget.dart * -------------------------- * add parameter reviewModel * -connect it on the product screen as listview.builder * to make this page appear after clicking product pic * ---------------------- * -in the simple_product_widget * -add new parameter of product model * -give gesture detector nad in ontap * -give navigator .push to productscreen * * chnage the teschildren list in constants:which shows the products from the database * -inside it addd Simple_product_widget with required parameters * * -create new file widgets:review_dialod.dart * ------------------------------------------ * this is to add the dialog box coming after clicking on the addreviewforthisproduct button *! -for this we have to use a package called rating_dialog * add it in the pubspec.yaml file * -for this copy the example of rating dialog from pub.dev * andd update the code in it * * * - call the reviewdialog widget in the product screen inside the CustomSimpleWidgetButton * -using showDialog () * * review collection * ================== * -take the child listview of SizedBox * - and put it inside a StreamBuilder * -the StreamBuilder will constantly listen to changes that happening in the collection section of productcollection * -when we add a review in the dialog box it will appear quickly below the review section * -there will be a collection of review inside every product * -thus each product will have a folder named review * -thus we want changes to this reviews collection and add those items to a listview inside a stream builder * -AsyncSnapshot? checkout * -create a class inside reviewModel getModelFromJson * -create a future function uploadReviewtodatabase in the cloudfirestore * -using this we can upload review to db * -create a getJson function inside the ReviewModel to use inside it * -inside the reviewDialod widget add one more parameter called productUid * -create a function inside onSubmitted to submit data into cloudFirestore * -in the onsubmitted section * inside productscreen at Customsimpleroundedbutton add parameter to review dialog * * add to cart button(working) * ================ * -create addProducttoCart function inside the cloudfirestore clAss * -we need a new collection named cart * inside every users collection * -we implement this in this function * -make the add to cart function of button async * -use the function there * -go to cart and listen to the stream there * * */
0
mirrored_repositories/flutter_amazon_clone/lib
mirrored_repositories/flutter_amazon_clone/lib/screens/sell_screen.dart
import 'dart:typed_data'; import 'package:amazon_clone/resources/cloudfirestore_methods.dart'; import 'package:amazon_clone/utils/color_theme.dart'; import 'package:amazon_clone/utils/utils.dart'; import 'package:amazon_clone/widgets/custom_main_button.dart'; import 'package:amazon_clone/widgets/loading_widget.dart'; import 'package:amazon_clone/widgets/text_field_widget.dart'; import 'package:firebase_auth/firebase_auth.dart'; import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; import '../providers/user_details_provider.dart'; class SellScreen extends StatefulWidget { const SellScreen({super.key}); @override State<SellScreen> createState() => _SellScreenState(); } class _SellScreenState extends State<SellScreen> { bool isLoading = false; int selected = 1; Uint8List? img; TextEditingController nameController = TextEditingController(); TextEditingController costController = TextEditingController(); List<int> keysForDiscount = [0, 70, 60, 50]; // Expanded spaceThing = @override void dispose() { super.dispose(); nameController.dispose(); costController.dispose(); } @override Widget build(BuildContext context) { Size screenSize = MediaQuery.of(context).size; return SafeArea( child: Scaffold( backgroundColor: Colors.white, body: !isLoading ? SingleChildScrollView( child: SizedBox( height: screenSize.height, width: screenSize.width, child: Padding( padding: const EdgeInsets.symmetric( vertical: 10.0, horizontal: 20), child: Center( child: Column( crossAxisAlignment: CrossAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.spaceEvenly, children: [ Stack( children: [ img == null ? Image.network( "https://thumbs.dreamstime.com/b/default-avatar-profile-icon-social-media-user-vector-default-avatar-profile-icon-social-media-user-vector-portrait-176194876.jpg", height: screenSize.height / 10, ) : Image.memory( img!, height: screenSize.height / 10, ), IconButton( onPressed: () async { Uint8List? temp = await Utils().pickImage(); if (temp != null) { setState(() { img = temp; }); } }, icon: const Icon(Icons.file_upload)) ], ), const SizedBox( height: 15, ), Container( padding: const EdgeInsets.symmetric( horizontal: 35, vertical: 10), height: screenSize.height * 0.7, width: screenSize.width * 0.7, decoration: BoxDecoration( border: Border.all( color: Colors.grey, width: 1, )), child: Column( mainAxisAlignment: MainAxisAlignment.spaceEvenly, crossAxisAlignment: CrossAxisAlignment.start, children: [ const Text( "Item Details", style: TextStyle( fontWeight: FontWeight.bold, fontSize: 20), ), const SizedBox( height: 5, ), TextFieldWidget( title: "Name", controller: nameController, obscureText: false, hintText: "Enter the name of the item"), TextFieldWidget( title: "Cost", controller: costController, obscureText: false, hintText: "Enter the cost of the item"), const Text( "Discount", style: TextStyle( fontWeight: FontWeight.bold, fontSize: 17), ), ListTile( title: const Text("None"), leading: Radio( value: 1, groupValue: selected, onChanged: (int? i) { setState(() { selected = i!; }); }, ), ), ListTile( title: const Text("70%"), leading: Radio( value: 2, groupValue: selected, onChanged: (int? i) { setState(() { selected = i!; }); }, ), ), ListTile( title: const Text("60%"), leading: Radio( value: 3, groupValue: selected, onChanged: (int? i) { setState(() { selected = i!; }); }, ), ), ListTile( title: const Text("50%"), leading: Radio( value: 4, groupValue: selected, onChanged: (int? i) { setState(() { selected = i!; }); }, ), ) ], ), ), const SizedBox( height: 10, ), CustomMainButton( color: yellowColor, isLoading: isLoading, onPressed: () async { String output = await CloudFirestoreClass() .uploadProductToDatabase( image: img, productName: nameController.text, rawCost: costController.text, discount: keysForDiscount[selected - 1], sellerName: Provider.of<UserDetailsProvider>( context, listen: false) .userDetails! .name, sellerUid: FirebaseAuth .instance.currentUser!.uid); print("output======$output"); if (output == "success") { Utils().showSnackBar( context: context, content: "Posted Product"); } else { Utils().showSnackBar( context: context, content: output); } }, child: const Text( "Sell", style: TextStyle(color: Colors.black), )), const SizedBox( height: 5, ), CustomMainButton( color: Colors.grey[300]!, isLoading: false, onPressed: () { Navigator.pop(context); }, child: const Text( "Back", style: TextStyle(color: Colors.black), )), ], )), ), ), ) : const LoadingWidget(), ), ); } } /** * create sell_screen.dart * =================== * code ui * -crete img of avatar inside the profile using conditionla operator * -download a library called image_picker(library helping to pick new img from sysytem file) * -craete function inside utils to picking the image from system file * -for updating the img * -code ba;ance * -make sell button in account sceen functional * -next go to cloudfirestore_mehtods for creating function uploadProducttoDatabase * * * -create new function uploadimagetoDatabase * -use this function inside uploadproduct function * -make another function inside utils:getUid * -to create random uid fior the image to store into the database * -use the productmodel object inside uploadproduct and * -use the firebaseFirestore.collection method to create a collection in DB * -just like we craeted collection of users * -crete a getJson function inside productModelClass * -use taht function in uploadproduct class * -- run all * --succcess product uploaded and product collection created in firebase db * --we can also see taht the price is reducing according to the discount we given * * */
0
mirrored_repositories/flutter_amazon_clone/lib
mirrored_repositories/flutter_amazon_clone/lib/layout/screen_layout.dart
import 'package:amazon_clone/providers/user_details_provider.dart'; import 'package:amazon_clone/resources/cloudfirestore_methods.dart'; import 'package:amazon_clone/utils/color_theme.dart'; import 'package:amazon_clone/utils/constants.dart'; import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; class ScreenLayout extends StatefulWidget { const ScreenLayout({super.key}); @override State<ScreenLayout> createState() => _ScreenLayoutState(); } class _ScreenLayoutState extends State<ScreenLayout> { PageController pageController = PageController(); int currentPage = 0; @override void dispose() { super.dispose(); pageController.dispose(); } changePage(int page) { pageController.jumpToPage(page); setState(() { currentPage = page; }); } @override void initState() { super.initState(); CloudFirestoreClass().getnameAndAddress(); } @override Widget build(BuildContext context) { Provider.of<UserDetailsProvider>(context, listen: true).getData(); return DefaultTabController( length: 4, child: SafeArea( child: Scaffold( body: PageView(controller: pageController, children: screens), bottomNavigationBar: Container( decoration: BoxDecoration( border: Border( top: BorderSide(color: Colors.grey[400]!, width: 1))), child: TabBar( indicatorSize: TabBarIndicatorSize.label, indicator: const BoxDecoration( border: Border( top: BorderSide(color: activeCyanColor, width: 4))), onTap: changePage, tabs: [ Tab( child: Icon( Icons.home_outlined, color: currentPage == 0 ? activeCyanColor : Colors.black, ), ), Tab( child: Icon( Icons.account_circle_outlined, color: currentPage == 1 ? activeCyanColor : Colors.black, ), ), Tab( child: Icon( Icons.shopping_cart_outlined, color: currentPage == 2 ? activeCyanColor : Colors.black, ), ), Tab( child: Icon( Icons.menu, color: currentPage == 3 ? activeCyanColor : Colors.black, ), ) ]), ), ), ), ); } }
0
mirrored_repositories/flutter_amazon_clone/lib
mirrored_repositories/flutter_amazon_clone/lib/providers/user_details_provider.dart
import 'package:amazon_clone/models/user_details_model.dart'; import 'package:amazon_clone/resources/cloudfirestore_methods.dart'; import 'package:flutter/material.dart'; class UserDetailsProvider with ChangeNotifier { //we aare initializing all values first to null //to prevent null errors UserDetailsModel? userDetails; UserDetailsProvider() : userDetails = UserDetailsModel(name: "Loading", address: "Loading"); Future getData() async { userDetails = await CloudFirestoreClass().getnameAndAddress(); //print(userDetails!.address); notifyListeners(); } } /** * create class UDP * inherit it from CNP * -create an object of UDM * -initilise it to null by ? * create constructor of UDP and initialize object of UDM in it * * -inside the resourses:cloudfirestore_resourses * -create a future function to return the instance got from DB to PRovider * -in the form of UDM * * -in the user_details_model create a new function to return the data in our required preference * -in the form of factory * * -finally call the function in the UDP * -add notifylistener inside the function * * activate this provider in the main * * -use provider in the user_detail_bar * -by deleting its parameters and accessing the value from provider * * -in the screen layout craete an instance of this provider to * -make the user authenticated * * * * * * */
0
mirrored_repositories/flutter_amazon_clone
mirrored_repositories/flutter_amazon_clone/projectnotes/layout.dart
/** * SCREEN LAYOUT * ============== * !1.create a StatefullWidget * -overiide * initState(),dispose() * !2.create an object of PageController(below extends class) * -this is to give inside controller of PageView * -dispose it inside the dispose() * !3.create a variable currentPage=0 * -this is to use inside changePage() * !4.create a function changePage() * -this functn is to change index of pages when we click bottom bar * -the function is called on the ontap of TabBar * -but inside it we call a function inside pageView * -thus it get activated * -for this we use PageController object we created * *pageController.jumpToPage() * -we use currentPage variable * -we use setState() to set the currentpage=page(from jumptopage) * void chnagePage( int page) * { * pageController.jumptoPage(page); * setstate((){ * currentPage=page;}) * } * !5.dispose pageController inside dispose * @override * void dispose() * {super.dispose();pageController.dispose();} * !6.CloudFireStore user data * -initailize it in the starting point of our application to fetch data * -inside initState() * @override * void initState(){ * super.initState(); * CloudFirestoreClass.getNameAndAddress();} * !7.PROVIDER:we nave to activate user provider here * -inside Wideget Build * Provider.of<UserDetailsProvider>((context,listen=true)).getData(); * !8.UI ** DefaultTabController( * length:4 * child: * *SafeArea( * child: * *Scaffold( * body:PageView(controller:pageController,children:screens) * bottomNavigationBar: * *Container( * child: * *TabBar( * ontap:changePage * tabs:[ * *Tab(child:Icon()) * Tab(child:Icon()) * Tab(child:Icon()) * Tab(child:Icon()) * ]//give 4 * indicatorSize: * indicator: * ) * ) * )) * ) * * */
0
mirrored_repositories/flutter_amazon_clone
mirrored_repositories/flutter_amazon_clone/projectnotes/amazon_clone.dart
/** * AMAZON CLONE * =========== * >.dart_tool * >.idea * >.vscode * >android * >build * >ios * >lib * >linux * >macos * >web * >windows * file:.flutter-plugins * file:.flutter-plugins-dependencies * git file:.gitignore * file:metadata * iml:amazon_clone.iml * yaml:analysis_options.yaml * file:pubspec.lock * yaml:pubspec.yaml * md:README.md * * >lib * ===== * >layout * >models * >providers * >resources * >screens * >utils * >widgets * firebase_options.dart * main.dart * * >layout:1 * ======= * screen_layout.dart * >models:3 * ======= * product_model.dart * review_model.dart * user_details_model.dart * >providers:1 * ========== * user_details_provider.dart * >resources:2 * ========== * authentication_methods.dart * cloudfirestore_methods.dart * screens:9 * ======= * sign_in_screen.dart * sign_up_screen.dart * home_screen.dart * account_screen.dart * cart_screen.dart * more_screen.dart * search_screen.dart * product_screen.dart * result_screen.dart * sell_screen.dart\ * utils:3 * ===== * constants.dart * color_theme.dart * utils.dart * >widgets: * ========= * loading_widget.dart * text_field_widget.dart * custom_main_button.dart * * search_bar_widget.dart * results_widget.dart * account_screen_app_bar.dart * user_details_bar.dart * * banner_add_widget.dart * * categories_horizontal_list_view.dart * category_widget.dart * * simple_product_widget.dart * product_showcase_list_view.dart * * product_information_widget.dart * cost_widget.dart * rating_star_widget.dart * review_widget.dart * review_dialog.dart * custom_simple_round_button.dart * custom_square_button.dart * * cart_item_widget.dart * ====================================== * firbase_options.dart * ======================================= * main.dart * */
0
mirrored_repositories/flutter_amazon_clone
mirrored_repositories/flutter_amazon_clone/projectnotes/main.dart
/** * MAIN * ======== *! 1.make void main future * ----------------- * void main() async{ ** WidgetsFlutterBinding.ensureInitialized(); * WidgetFlutterBinding is used to interact with the Flutter engine. * Firebase.initializeApp() needs to call native code to initialize * Firebase, and since the plugin needs to use platform channels to call * the native code, which is done asynchronously therefore you have to call * ensureInitialized() to make sure that you have an instance of the WidgetsBinding ** await Firebase.initializeApp( options: DefaultFirebaseOptions.currentPlatform, ); *! 2.runApp ------ runApp(AmazonClone()); * } * !3.stateless widget:AmazonClone * ------------------------ * class AmazonClone extends StatelessWidget { const AmazonClone({super.key}); * !4.wrap material app with Multiprovider:use UserDetailsProvider * ------------------------- * @override Widget build(BuildContext context) { return MultiProvider( providers:[ ChangeNotifierProvider<UserDetailsProvider>( create: (_) => UserDetailsProvider() ) ] ) * !5.Extend MaterialApp as its child:title,theme,debugshowcheckedmodebanner,home * ---------------------------------- * child:MaterialApp( * title:"Amazon Clone" * theme:themeData.light().copyWith(scaffoldBackGroundColor: backgroundColor) * * !6.Wrap home: inside Stream Builder:stream,builder * ----------------------------------- * home:StremBuilder( * *stream Builder:StreamBuilder is a widget that builds itself based on the latest snapshot of interaction with a stream. * *stream builder constantly listens to the changes(data that chnages,Strems) * *that happen in the stream that attached(database,cloud) and rebuilds what changed * strem:FirebaseAuth.instance.authStateChanges(), * builder:(context,AsyncSnapshot<User?> user) * { * if(user.conneectionState==Connectionstate.waiting) * { * return Center(child:CircularProgressIndicator); * } * else if(user.hasData) * { * return ScreenLayout(); * } * else * { * return SignInScreen(); * } * } * ) * * ) * * * * * * * * * */
0
mirrored_repositories/flutter_amazon_clone/projectnotes
mirrored_repositories/flutter_amazon_clone/projectnotes/models/models.dart
/*** * USER DETAILS MODEL:2 * ================== * !1.create a class UserDetailsModel * class UserDetailsModel{} * !2.declare two variables:name,address * final String name; * final String address; * !3.initialize it using the constructor:make it required * UserDetailsModel({required this.name,required this.address}); * !4.create getJson:getter function to return json file model * Map<String, dynamic> getJson() => {"name":name,"address":address}; * !5.create getModelFromJson :named constructor function to set json type file * - return type factory * - class.fnNmae * *factory UserDetailsModel.getModelFromJson(Map<String ,dynamic> json) * { * return UserDetailsModel(name:json["name"], address:json["address"]); * } * * PRODUCT MODEL:9 * ============= * String:url,productName,uid,sellerName * * * * */
0
mirrored_repositories/flutter_amazon_clone/projectnotes
mirrored_repositories/flutter_amazon_clone/projectnotes/screens/screens.dart
/** * Home screen:the home screen * account screen:the account tscren of user * * * * */
0
mirrored_repositories/FlutterGithubClient
mirrored_repositories/FlutterGithubClient/lib/Routes.dart
import 'package:LoginUI/ui/dashboard/DashboardPage.dart'; import 'package:LoginUI/ui/login/LoginPage.dart'; import 'package:LoginUI/ui/repodetails/RepoDetailsPage.dart'; import 'package:LoginUI/ui/repolist/RepoListPage.dart'; import 'package:LoginUI/ui/searchusers/UserSearchPage.dart'; import 'package:LoginUI/ui/usergists/UserGistsPage.dart'; import 'ui/notifications/NotificationsPage.dart'; import 'package:fluro/fluro.dart'; import 'package:flutter/cupertino.dart'; class Routes { static String root = "/"; static String login = "/login"; static String loginDashboard = "/dashboard"; static String dashboardRepoList = "/repolist"; static String dashboardUserSearch = "/usersearch"; static String repoDetails = "/repolist/:loginname/:repo"; static String userGists = "/users/:loginname/gists"; static String notificationsList = "/notifications"; static void configureRoutes(Router router) { router.notFoundHandler = new Handler( handlerFunc: (BuildContext context, Map<String, List<String>> params) { print("ROUTE WAS NOT FOUND !!!"); }); router.define(root, handler: loginHandler); router.define(login, handler: loginHandler); router.define(loginDashboard, handler: loginDashHandler); router.define(dashboardRepoList, handler: dashboardRepoListHandler); router.define(dashboardUserSearch, handler: dashboardUserSearchHandler); router.define(repoDetails, handler: repoDetailsHandler); router.define(userGists, handler: userGistsHandler); router.define(notificationsList, handler: notificationsHandler); } } var loginHandler = new Handler( handlerFunc: (BuildContext context, Map<String, List<String>> params) { return new LoginPage(); }); var loginDashHandler = new Handler( handlerFunc: (BuildContext context, Map<String, List<String>> params) { return new DashboardPage(); }); var dashboardRepoListHandler = new Handler( handlerFunc: (BuildContext context, Map<String, List<String>> params) { return new RepoListPage(); }); var dashboardUserSearchHandler = new Handler( handlerFunc: (BuildContext context, Map<String, List<String>> params) { return new UserSearchPage(); }); var repoDetailsHandler = new Handler( handlerFunc: (BuildContext context, Map<String, List<String>> params) { return new RepoDetailsPage(params["loginname"][0],params["repo"][0]); }); var userGistsHandler = new Handler( handlerFunc: (BuildContext context, Map<String, List<String>> params) { return new UserGistsPage(params["loginname"][0]); }); var notificationsHandler = Handler( handlerFunc: (BuildContext context, Map<String, List<String>> params) { return new NotificationsPage(); } );
0
mirrored_repositories/FlutterGithubClient
mirrored_repositories/FlutterGithubClient/lib/main.dart
import 'package:LoginUI/Routes.dart'; import 'package:fluro/fluro.dart'; import 'package:flutter/material.dart'; void main() { runApp(new AppGithubClient()); } class AppGithubClient extends StatelessWidget { // This widget is the root of your application. AppGithubClient() { final router = new Router(); Routes.configureRoutes(router); Application.router = router; } @override Widget build(BuildContext context) { var app = new MaterialApp( title: 'Flutter Github Client', debugShowCheckedModeBanner: false, theme: new ThemeData(), onGenerateRoute: Application.router.generator, ); print("initial route = ${app.initialRoute}"); return app; } } class Application { static Router router; }
0
mirrored_repositories/FlutterGithubClient/lib
mirrored_repositories/FlutterGithubClient/lib/network/apis.dart
import 'dart:async'; import 'dart:io'; import 'package:LoginUI/ui/Utils.dart'; import 'package:http/http.dart' as http; class Apis { static Future<http.Response> fetchCurrentUser(var username, var password) { var encodedCreds = Utils.encodeCredentials(username, password); var authHeaderValue = "Basic $encodedCreds"; return http.get("https://api.github.com/user", headers: {HttpHeaders.authorizationHeader: authHeaderValue}); } static Future<http.Response> fetchPost() { return http.get('https://jsonplaceholder.typicode.com/posts/1'); } }
0
mirrored_repositories/FlutterGithubClient/lib
mirrored_repositories/FlutterGithubClient/lib/network/Github.dart
import 'dart:async'; import 'dart:convert'; import 'dart:io'; import 'package:LoginUI/ui/AppConstants.dart'; import 'package:http/http.dart' as http; import 'package:url_launcher/url_launcher.dart'; class Github { static var USER = "{user}"; static var REPO = "{repo}"; static String githubApiBaseUrl = "https://api.github.com"; static String authorizeURL = "https://github.com/login/oauth/authorize"; static String accessTokenURL = "https://github.com/login/oauth/access_token"; static String authorizeBasicUrl = "$githubApiBaseUrl/authorizations"; static String getUserGithub = "$githubApiBaseUrl/search/users"; static String getMyUserGithub = "$githubApiBaseUrl/user"; static String getUserProfileGithub = "$githubApiBaseUrl/users"; static String getMyReposGithub = "$githubApiBaseUrl/user/repos"; static String getMyOrgsGithub = "$githubApiBaseUrl/user/orgs"; static String getUsersReposGithub = "$githubApiBaseUrl/users/:username/repos"; static String getUserRepoGithub = "$githubApiBaseUrl/repos/$USER/$REPO"; static String getStarredReposGithub = "$githubApiBaseUrl/users/$USER/starred"; static String getUserNotificationsGithub = "$githubApiBaseUrl/notifications"; static String getGistsGithub = "$githubApiBaseUrl/users/$USER/gists"; static String clientId = "client_id"; //Required. The client ID you received from GitHub when you registered. static String clientSecret = "client_secret"; //Required. The client secret you received from GitHub for your GitHub App. static String redirectUri = "redirect_uri"; //The URL in your application where users will be sent after authorization. See details below about redirect urls. static String scope = "scope"; //A space-delimited list of scopes. If not provided, scope defaults to an empty list for users that have not authorized any scopes for the application. For users who have authorized scopes for the application, the user won't be shown the OAuth authorization page with the list of scopes. Instead, this step of the flow will automatically complete with the set of scopes the user has authorized for the application. For example, if a user has already performed the web flow twice and has authorized one token with user scope and another token with repo scope, a third web flow that does not provide a scope will receive a token with user and repo scope. static String state = "state"; //An unguessable random string. It is used to protect against cross-site request forgery attacks. static String allowSignup = "allow_signup"; //Whether or not unauthenticated users will be offered an option to sign up for GitHub during the OAuth flow. The default is true. Use false in the case that a policy prohibits signups. static String affiliationParamRepoSearch = "&visibility=all&affiliation=owner,collaborator,organization_member"; static Future<http.Response> authorize(Map<String, String> requestData) { return http.get(authorizeURL, headers: requestData); } static Map<String, String> getGithubHeaders() { Map<String, String> headers = new Map(); headers.putIfAbsent(Github.clientId, () { return AppConstants.GITHUB_CLIENT_ID; }); headers.putIfAbsent(Github.redirectUri, () { return AppConstants.GITHUB_CALLBACK_URL; }); headers.putIfAbsent(Github.scope, () { return "repo,user"; }); headers.putIfAbsent(Github.state, () { return AppConstants.GITHUB_CLIENT_ID; }); headers.putIfAbsent(Github.allowSignup, () { return "true"; }); return headers; } //https://github.com/login/oauth/authorize?client_id=5eebe59bc6ed95a4f4b1&redirect_uri =http://localhost:8080/&scope=repo,user&state=5eebe59bc6ed95a4f4b1&allow_signup=true& static Future<Stream<String>> _server() async { final StreamController<String> onCode = new StreamController(); HttpServer server = await HttpServer.bind(InternetAddress.loopbackIPv4, 8080, shared: true); server.listen((HttpRequest request) async { final String code = request.uri.queryParameters["code"]; request.response ..statusCode = 200 ..headers.set("Content-Type", ContentType.html.mimeType) ..write("<html><h1>You can now close this window</h1></html>"); await request.response.close(); await server.close(force: true); onCode.add(code); await onCode.close(); }); return onCode.stream; } static String githubAuthUrl() { StringBuffer buffer = new StringBuffer(); buffer.write(Github.authorizeURL); buffer.write("?"); getGithubHeaders().forEach((key, value) { buffer.write(key); buffer.write("="); buffer.write(value); buffer.write("&"); }); return buffer.toString(); } static Future<String> authenticate(Null Function(String) param0) async { Stream<String> onToken = await _server(); String url = Github.githubAuthUrl().replaceAll(" ", ""); print(url); if (await canLaunch(url)) { await launch(url); } else { param0(""); throw 'Could not launch $url'; } final String token = await onToken.first; print("Received token " + token); Github.postAccessToken(token).then((response) { print("Response status: ${response}"); param0(response); }).catchError((error) { param0("Error body: $error"); }).whenComplete(() {}); return token; } static Future<String> postAccessToken(String code) async { HttpClient httpClient = new HttpClient(); Map map = { clientId: AppConstants.GITHUB_CLIENT_ID, clientSecret: AppConstants.GITHUB_CLIENT_SECRET, 'code': code, }; HttpClientRequest request = await httpClient.postUrl(Uri.parse(accessTokenURL)); request.headers.set('content-type', 'application/json'); request.write(json.encode(map)); print(request.headers); print(request.encoding.name); print(request.uri.toString()); print(json.encode(map)); HttpClientResponse response = await request.close(); print(response.statusCode); String reply = await response.transform(utf8.decoder).join(); print(reply); reply = reply.split("=")[1].split("&")[0]; httpClient.close(); return reply; } static Future<http.Response> getUsersBySearch(String accessToken, String value, int page) { String fullUrl = getUserGithub + "?access_token=" + accessToken + "&q=" + value+"&page=$page&per_page=10"+"&" + getClientIdSecret(); print(fullUrl); return http.get(fullUrl); } static Future<http.Response> getMyUserProfile(String accessToken){ String fullUrl = getMyUserGithub + "?access_token=" + accessToken+ "&" +getClientIdSecret(); print(fullUrl); return http.get(fullUrl); } static Future<http.Response> getUserProfile(String username) { String fullUrl = getUserProfileGithub + "/$username" + "?" + "&" + getClientIdSecret(); print(fullUrl); return http.get(fullUrl); } static Future<http.Response> getNotificationDetail(String url, String accessToken) { String fullUrl = url + "?access_token=" + accessToken; print(fullUrl); return http.get(fullUrl); } static Future<http.Response> getAllMyRepos(String accessToken,int max,int page) { String fullUrl = getMyReposGithub + "?access_token=" + accessToken+"&page=$page&per_page=$max" +"&" + getClientIdSecret() + affiliationParamRepoSearch; print(fullUrl); return http.get(fullUrl); } static Future<http.Response> getUserNotifications(String accessToken) { String fullUrl = getUserNotificationsGithub + "?access_token=" + accessToken; print(fullUrl); return http.get(fullUrl); } static Future<http.Response> getUserRepos(int page,int max,String accessToken,String userName) { String fullUrl = getUsersReposGithub.replaceAll(":username", userName) + "?accessToken=" + accessToken+"&page=$page&per_page=$max" +"&" + getClientIdSecret() + affiliationParamRepoSearch+"&"+"type=all"; print(fullUrl); return http.get(fullUrl); } static Future<http.Response> getFromUrl(String reposUrl, String accessToken) { String fullUrl = reposUrl + "?access_token=" + accessToken + affiliationParamRepoSearch; print(fullUrl); return http.get(fullUrl); } static Future<http.Response> getMyOrganizations(String accessToken) { String fullUrl = getMyOrgsGithub + "?access_token=" + accessToken + affiliationParamRepoSearch; print(fullUrl); return http.get(fullUrl); } static Future<http.Response> getApiForUrl(String contributorsUrl, String accessToken) { var fullUrl = contributorsUrl + "?access_token=" + accessToken +"&"+ getClientIdSecret(); return http.get(fullUrl); } //flutter: https://api.github.com/users/Anmol92verma/starred static Future<http.Response> getUserStarredRepos( String username, int max, int page) { String fullUrl = getStarredReposGithub.replaceAll(USER, username) + "?page=$page&per_page=$max" + "&" + getClientIdSecret(); print(fullUrl); return http.get(fullUrl); } static Future<http.Response> getGistsForUser( String username, int max, int page) { String fullUrl = getGistsGithub.replaceAll(USER, username) + "?page=$page&per_page=$max" + "&" + getClientIdSecret(); print(fullUrl); return http.get(fullUrl); } static Future<http.Response> authenticateUsernamePassword( String username, String password) async { var value = base64Encode(utf8.encode('$username:$password')); var authrorization = 'Basic $value'; print(authrorization); print(authorizeBasicUrl); var list = List<String>(); list.add("user"); list.add("repo"); list.add("gist"); list.add("notifications"); list.add("read:org"); Map map = { clientId: AppConstants.GITHUB_CLIENT_ID, "scopes": list, clientSecret: AppConstants.GITHUB_CLIENT_SECRET, }; print(map); return http.post(authorizeBasicUrl, headers: {'Authorization': authrorization}, body: json.encode(map)); } static String getClientIdSecret() { return "${Github.clientId}=${AppConstants.GITHUB_CLIENT_ID}&${Github.clientSecret}=${AppConstants.GITHUB_CLIENT_SECRET}"; } }
0
mirrored_repositories/FlutterGithubClient/lib
mirrored_repositories/FlutterGithubClient/lib/userprofile/UserProfileState.dart
import 'dart:async'; import 'dart:convert'; import 'package:LoginUI/model/ReposModel.dart'; import 'package:LoginUI/model/UserProfile.dart'; import 'package:LoginUI/network/Github.dart'; import 'package:LoginUI/ui/base/BaseStatefulState.dart'; import 'package:LoginUI/userprofile/UserProfileHeader.dart'; import 'package:LoginUI/userprofile/UserProfilePage.dart'; import 'package:LoginUI/utils/RepoListProvider.dart'; import 'package:LoginUI/utils/SharedPrefs.dart'; import 'package:flutter/material.dart'; import 'package:flutter/src/widgets/framework.dart'; import 'package:http/http.dart'; class UserProfileState extends BaseStatefulState<UserProfilePage> { UserProfile user; var login; String accessToken; StreamSubscription<Response> subscriptionRepos; List<ReposModel> repos; StreamSubscription<Response> subScriptionApiUserProfile; UserProfileState(@required this.login); int page = 1; ScrollController scrollController; RepoListProvider repoListProvider; @override void initState() { super.initState(); repoListProvider = new RepoListProvider(); scrollController = new ScrollController(); scrollController.addListener(_scrollListener); SharedPrefs().getToken().then((token) { accessToken = token; getUserProfile(); getRepos(); }); } @override void dispose() { if (subscriptionRepos != null) { subscriptionRepos.cancel(); } scrollController.removeListener(_scrollListener); super.dispose(); } void _scrollListener() { print(scrollController.position.extentAfter); if (scrollController.position.extentAfter == 0 && repos != null) { if (subscriptionRepos == null) { getRepos(); } } } @override Widget prepareWidget(BuildContext context) { var uiElements = <Widget>[]; uiElements.add(header()); uiElements.add(new Expanded( child: repoListProvider.getReposList(repos, false, scrollController))); return new Scaffold( key: scaffoldKey, appBar: toolbarAndroid(), body: new Column( children: uiElements, ), ); } toolbarAndroid() { return new AppBar( centerTitle: false, backgroundColor: Colors.black, title: new Text( login, textDirection: TextDirection.ltr, ), ); } header() { if (this.user != null) { return new UserProfileHeader(user); } else { return Text(""); } } getRepos() { if (subscriptionRepos != null) { subscriptionRepos.cancel(); } showProgress(); subscriptionRepos = repoListProvider.getUserRepos(page, 10, accessToken, login, (repos) { this.setState(() { if (this.repos == null) { this.repos = repos; } else { this.repos.addAll(repos); } }); page = page + 1; hideProgress(); subscriptionRepos = null; }); } void getUserProfile() { hideProgress(); if (subScriptionApiUserProfile != null) { subScriptionApiUserProfile.cancel(); } showProgress(); var getUserProfile = Github.getUserProfile(login).asStream(); subScriptionApiUserProfile = getUserProfile.listen((response) { print(response.body); this.user = UserProfile.fromJson(json.decode(response.body)); this.setState(() {}); hideProgress(); }); } }
0
mirrored_repositories/FlutterGithubClient/lib
mirrored_repositories/FlutterGithubClient/lib/userprofile/UserProfilePage.dart
import 'package:LoginUI/model/UserProfile.dart'; import 'package:LoginUI/userprofile/UserProfileState.dart'; import 'package:flutter/material.dart'; class UserProfilePage extends StatefulWidget{ String user; UserProfilePage(@required this.user); @override UserProfileState createState() => UserProfileState(user); }
0
mirrored_repositories/FlutterGithubClient/lib
mirrored_repositories/FlutterGithubClient/lib/userprofile/UserProfileHeader.dart
import 'package:LoginUI/model/UserProfile.dart'; import 'package:LoginUI/userprofile/UserProfileHeaderState.dart'; import 'package:flutter/material.dart'; class UserProfileHeader extends StatefulWidget { UserProfile userProfile; UserProfileHeader(@required this.userProfile); @override UserProfileHeaderState createState() => UserProfileHeaderState(userProfile: userProfile); }
0
mirrored_repositories/FlutterGithubClient/lib
mirrored_repositories/FlutterGithubClient/lib/userprofile/UserProfileHeaderState.dart
import 'package:LoginUI/Routes.dart'; import 'package:LoginUI/main.dart'; import 'package:LoginUI/model/UserProfile.dart'; import 'package:LoginUI/ui/base/BaseStatefulState.dart'; import 'package:LoginUI/userprofile/UserProfileHeader.dart'; import 'package:flutter/material.dart'; class UserProfileHeaderState extends BaseStatefulState<UserProfileHeader> { final UserProfile userProfile; UserProfileHeaderState({userProfile: UserProfile}) : this.userProfile = userProfile; userImageWidget() { return Expanded( flex: 1, child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: <Widget>[ Container( child: new CircleAvatar( backgroundImage: new NetworkImage(userProfile.avatarUrl), radius: 40.0, )), ], )); } userDetailsWidget(BuildContext context) { return Expanded( flex: 2, child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: <Widget>[ Padding( child: Text("${userProfile.name}", style: new TextStyle(color: Colors.white)), padding: EdgeInsets.only(top: 2)), Padding( child: Text("${userProfile.login}", style: new TextStyle(color: Colors.white)), padding: EdgeInsets.only(top: 2)), Padding( child: Text( "${userProfile.bio}", style: new TextStyle(color: Colors.white), maxLines: 4, overflow: TextOverflow.ellipsis, ), padding: EdgeInsets.only(top: 2)), Padding( child: Text("${userProfile.company}", style: new TextStyle(color: Colors.white)), padding: EdgeInsets.only(top: 2)), GestureDetector( child: Padding( child: Text("See ${userProfile.name}'s Gist's", style: new TextStyle(color: Colors.white)), padding: EdgeInsets.all(4)), onTap: () { Application.router.navigateTo( context, Routes.userGists .replaceFirst(":loginname", userProfile.login)); }, ) ], )); } @override Widget prepareWidget(BuildContext context) { var listWidgets = <Widget>[]; if (userProfile != null) { listWidgets.add(userImageWidget()); listWidgets.add(userDetailsWidget(context)); } return Container( padding: EdgeInsets.only(top: 48), child: Row( children: listWidgets, ), decoration: BoxDecoration( color: Colors.black87, ), ); } }
0
mirrored_repositories/FlutterGithubClient/lib
mirrored_repositories/FlutterGithubClient/lib/model/PullRequest.dart
class PullRequest { String url; int id; String nodeId; String htmlUrl; String diffUrl; String patchUrl; String issueUrl; int number; String state; bool locked; String title; User user; String body; String createdAt; String updatedAt; String closedAt; String mergedAt; String mergeCommitSha; Assignee assignee; List<Assignees> assignees; List<RequestedReviewers> requestedReviewers; List<String> requestedTeams; List<Labels> labels; Milestone milestone; String commitsUrl; String reviewCommentsUrl; String reviewCommentUrl; String commentsUrl; String statusesUrl; Head head; Base base; Links lLinks; String authorAssociation; bool merged; bool mergeable; bool rebaseable; String mergeableState; User mergedBy; int comments; int reviewComments; bool maintainerCanModify; int commits; int additions; int deletions; int changedFiles; PullRequest( {this.url, this.id, this.nodeId, this.htmlUrl, this.diffUrl, this.patchUrl, this.issueUrl, this.number, this.state, this.locked, this.title, this.user, this.body, this.createdAt, this.updatedAt, this.closedAt, this.mergedAt, this.mergeCommitSha, this.assignee, this.assignees, this.requestedReviewers, this.requestedTeams, this.labels, this.milestone, this.commitsUrl, this.reviewCommentsUrl, this.reviewCommentUrl, this.commentsUrl, this.statusesUrl, this.head, this.base, this.lLinks, this.authorAssociation, this.merged, this.mergeable, this.rebaseable, this.mergeableState, this.mergedBy, this.comments, this.reviewComments, this.maintainerCanModify, this.commits, this.additions, this.deletions, this.changedFiles}); PullRequest.fromJson(Map<String, dynamic> json) { url = json['url']; id = json['id']; nodeId = json['node_id']; htmlUrl = json['html_url']; diffUrl = json['diff_url']; patchUrl = json['patch_url']; issueUrl = json['issue_url']; number = json['number']; state = json['state']; locked = json['locked']; title = json['title']; user = json['user'] != null ? new User.fromJson(json['user']) : null; body = json['body']; createdAt = json['created_at']; updatedAt = json['updated_at']; closedAt = json['closed_at']; mergedAt = json['merged_at']; mergeCommitSha = json['merge_commit_sha']; assignee = json['assignee'] != null ? new Assignee.fromJson(json['assignee']) : null; if (json['assignees'] != null) { assignees = new List<Assignees>(); json['assignees'].forEach((v) { assignees.add(new Assignees.fromJson(v)); }); } if (json['requested_reviewers'] != null) { requestedReviewers = new List<RequestedReviewers>(); json['requested_reviewers'].forEach((v) { requestedReviewers.add(new RequestedReviewers.fromJson(v)); }); } if (json['requested_teams'] != null) { requestedTeams = new List<String>(); json['requested_teams'].forEach((v) { requestedTeams.add(""); }); } if (json['labels'] != null) { labels = new List<Labels>(); json['labels'].forEach((v) { labels.add(new Labels.fromJson(v)); }); } milestone = json['milestone'] != null ? new Milestone.fromJson(json['milestone']) : null; commitsUrl = json['commits_url']; reviewCommentsUrl = json['review_comments_url']; reviewCommentUrl = json['review_comment_url']; commentsUrl = json['comments_url']; statusesUrl = json['statuses_url']; head = json['head'] != null ? new Head.fromJson(json['head']) : null; base = json['base'] != null ? new Base.fromJson(json['base']) : null; lLinks = json['_links'] != null ? new Links.fromJson(json['_links']) : null; authorAssociation = json['author_association']; merged = json['merged']; mergeable = json['mergeable']; rebaseable = json['rebaseable']; mergeableState = json['mergeable_state']; mergedBy = json['merged_by'] != null ? new User.fromJson(json['merged_by']) : null; comments = json['comments']; reviewComments = json['review_comments']; maintainerCanModify = json['maintainer_can_modify']; commits = json['commits']; additions = json['additions']; deletions = json['deletions']; changedFiles = json['changed_files']; } Map<String, dynamic> toJson() { final Map<String, dynamic> data = new Map<String, dynamic>(); data['url'] = this.url; data['id'] = this.id; data['node_id'] = this.nodeId; data['html_url'] = this.htmlUrl; data['diff_url'] = this.diffUrl; data['patch_url'] = this.patchUrl; data['issue_url'] = this.issueUrl; data['number'] = this.number; data['state'] = this.state; data['locked'] = this.locked; data['title'] = this.title; if (this.user != null) { data['user'] = this.user.toJson(); } data['body'] = this.body; data['created_at'] = this.createdAt; data['updated_at'] = this.updatedAt; data['closed_at'] = this.closedAt; data['merged_at'] = this.mergedAt; data['merge_commit_sha'] = this.mergeCommitSha; if (this.assignee != null) { data['assignee'] = this.assignee.toJson(); } if (this.assignees != null) { data['assignees'] = this.assignees.map((v) => v.toJson()).toList(); } if (this.requestedReviewers != null) { data['requested_reviewers'] = this.requestedReviewers.map((v) => v.toJson()).toList(); } if (this.requestedTeams != null) { data['requested_teams'] = []; } if (this.labels != null) { data['labels'] = this.labels.map((v) => v.toJson()).toList(); } if (this.milestone != null) { data['milestone'] = this.milestone.toJson(); } data['commits_url'] = this.commitsUrl; data['review_comments_url'] = this.reviewCommentsUrl; data['review_comment_url'] = this.reviewCommentUrl; data['comments_url'] = this.commentsUrl; data['statuses_url'] = this.statusesUrl; if (this.head != null) { data['head'] = this.head.toJson(); } if (this.base != null) { data['base'] = this.base.toJson(); } if (this.lLinks != null) { data['_links'] = this.lLinks.toJson(); } data['author_association'] = this.authorAssociation; data['merged'] = this.merged; data['mergeable'] = this.mergeable; data['rebaseable'] = this.rebaseable; data['mergeable_state'] = this.mergeableState; data['merged_by'] = this.mergedBy; data['comments'] = this.comments; data['review_comments'] = this.reviewComments; data['maintainer_can_modify'] = this.maintainerCanModify; data['commits'] = this.commits; data['additions'] = this.additions; data['deletions'] = this.deletions; data['changed_files'] = this.changedFiles; return data; } } class User { String login; int id; String nodeId; String avatarUrl; String gravatarId; String url; String htmlUrl; String followersUrl; String followingUrl; String gistsUrl; String starredUrl; String subscriptionsUrl; String organizationsUrl; String reposUrl; String eventsUrl; String receivedEventsUrl; String type; bool siteAdmin; User( {this.login, this.id, this.nodeId, this.avatarUrl, this.gravatarId, this.url, this.htmlUrl, this.followersUrl, this.followingUrl, this.gistsUrl, this.starredUrl, this.subscriptionsUrl, this.organizationsUrl, this.reposUrl, this.eventsUrl, this.receivedEventsUrl, this.type, this.siteAdmin}); User.fromJson(Map<String, dynamic> json) { login = json['login']; id = json['id']; nodeId = json['node_id']; avatarUrl = json['avatar_url']; gravatarId = json['gravatar_id']; url = json['url']; htmlUrl = json['html_url']; followersUrl = json['followers_url']; followingUrl = json['following_url']; gistsUrl = json['gists_url']; starredUrl = json['starred_url']; subscriptionsUrl = json['subscriptions_url']; organizationsUrl = json['organizations_url']; reposUrl = json['repos_url']; eventsUrl = json['events_url']; receivedEventsUrl = json['received_events_url']; type = json['type']; siteAdmin = json['site_admin']; } Map<String, dynamic> toJson() { final Map<String, dynamic> data = new Map<String, dynamic>(); data['login'] = this.login; data['id'] = this.id; data['node_id'] = this.nodeId; data['avatar_url'] = this.avatarUrl; data['gravatar_id'] = this.gravatarId; data['url'] = this.url; data['html_url'] = this.htmlUrl; data['followers_url'] = this.followersUrl; data['following_url'] = this.followingUrl; data['gists_url'] = this.gistsUrl; data['starred_url'] = this.starredUrl; data['subscriptions_url'] = this.subscriptionsUrl; data['organizations_url'] = this.organizationsUrl; data['repos_url'] = this.reposUrl; data['events_url'] = this.eventsUrl; data['received_events_url'] = this.receivedEventsUrl; data['type'] = this.type; data['site_admin'] = this.siteAdmin; return data; } } class Assignee { String login; int id; String nodeId; String avatarUrl; String gravatarId; String url; String htmlUrl; String followersUrl; String followingUrl; String gistsUrl; String starredUrl; String subscriptionsUrl; String organizationsUrl; String reposUrl; String eventsUrl; String receivedEventsUrl; String type; bool siteAdmin; Assignee( {this.login, this.id, this.nodeId, this.avatarUrl, this.gravatarId, this.url, this.htmlUrl, this.followersUrl, this.followingUrl, this.gistsUrl, this.starredUrl, this.subscriptionsUrl, this.organizationsUrl, this.reposUrl, this.eventsUrl, this.receivedEventsUrl, this.type, this.siteAdmin}); Assignee.fromJson(Map<String, dynamic> json) { login = json['login']; id = json['id']; nodeId = json['node_id']; avatarUrl = json['avatar_url']; gravatarId = json['gravatar_id']; url = json['url']; htmlUrl = json['html_url']; followersUrl = json['followers_url']; followingUrl = json['following_url']; gistsUrl = json['gists_url']; starredUrl = json['starred_url']; subscriptionsUrl = json['subscriptions_url']; organizationsUrl = json['organizations_url']; reposUrl = json['repos_url']; eventsUrl = json['events_url']; receivedEventsUrl = json['received_events_url']; type = json['type']; siteAdmin = json['site_admin']; } Map<String, dynamic> toJson() { final Map<String, dynamic> data = new Map<String, dynamic>(); data['login'] = this.login; data['id'] = this.id; data['node_id'] = this.nodeId; data['avatar_url'] = this.avatarUrl; data['gravatar_id'] = this.gravatarId; data['url'] = this.url; data['html_url'] = this.htmlUrl; data['followers_url'] = this.followersUrl; data['following_url'] = this.followingUrl; data['gists_url'] = this.gistsUrl; data['starred_url'] = this.starredUrl; data['subscriptions_url'] = this.subscriptionsUrl; data['organizations_url'] = this.organizationsUrl; data['repos_url'] = this.reposUrl; data['events_url'] = this.eventsUrl; data['received_events_url'] = this.receivedEventsUrl; data['type'] = this.type; data['site_admin'] = this.siteAdmin; return data; } } class Assignees { String login; int id; String nodeId; String avatarUrl; String gravatarId; String url; String htmlUrl; String followersUrl; String followingUrl; String gistsUrl; String starredUrl; String subscriptionsUrl; String organizationsUrl; String reposUrl; String eventsUrl; String receivedEventsUrl; String type; bool siteAdmin; Assignees( {this.login, this.id, this.nodeId, this.avatarUrl, this.gravatarId, this.url, this.htmlUrl, this.followersUrl, this.followingUrl, this.gistsUrl, this.starredUrl, this.subscriptionsUrl, this.organizationsUrl, this.reposUrl, this.eventsUrl, this.receivedEventsUrl, this.type, this.siteAdmin}); Assignees.fromJson(Map<String, dynamic> json) { login = json['login']; id = json['id']; nodeId = json['node_id']; avatarUrl = json['avatar_url']; gravatarId = json['gravatar_id']; url = json['url']; htmlUrl = json['html_url']; followersUrl = json['followers_url']; followingUrl = json['following_url']; gistsUrl = json['gists_url']; starredUrl = json['starred_url']; subscriptionsUrl = json['subscriptions_url']; organizationsUrl = json['organizations_url']; reposUrl = json['repos_url']; eventsUrl = json['events_url']; receivedEventsUrl = json['received_events_url']; type = json['type']; siteAdmin = json['site_admin']; } Map<String, dynamic> toJson() { final Map<String, dynamic> data = new Map<String, dynamic>(); data['login'] = this.login; data['id'] = this.id; data['node_id'] = this.nodeId; data['avatar_url'] = this.avatarUrl; data['gravatar_id'] = this.gravatarId; data['url'] = this.url; data['html_url'] = this.htmlUrl; data['followers_url'] = this.followersUrl; data['following_url'] = this.followingUrl; data['gists_url'] = this.gistsUrl; data['starred_url'] = this.starredUrl; data['subscriptions_url'] = this.subscriptionsUrl; data['organizations_url'] = this.organizationsUrl; data['repos_url'] = this.reposUrl; data['events_url'] = this.eventsUrl; data['received_events_url'] = this.receivedEventsUrl; data['type'] = this.type; data['site_admin'] = this.siteAdmin; return data; } } class RequestedReviewers { String login; int id; String nodeId; String avatarUrl; String gravatarId; String url; String htmlUrl; String followersUrl; String followingUrl; String gistsUrl; String starredUrl; String subscriptionsUrl; String organizationsUrl; String reposUrl; String eventsUrl; String receivedEventsUrl; String type; bool siteAdmin; RequestedReviewers( {this.login, this.id, this.nodeId, this.avatarUrl, this.gravatarId, this.url, this.htmlUrl, this.followersUrl, this.followingUrl, this.gistsUrl, this.starredUrl, this.subscriptionsUrl, this.organizationsUrl, this.reposUrl, this.eventsUrl, this.receivedEventsUrl, this.type, this.siteAdmin}); RequestedReviewers.fromJson(Map<String, dynamic> json) { login = json['login']; id = json['id']; nodeId = json['node_id']; avatarUrl = json['avatar_url']; gravatarId = json['gravatar_id']; url = json['url']; htmlUrl = json['html_url']; followersUrl = json['followers_url']; followingUrl = json['following_url']; gistsUrl = json['gists_url']; starredUrl = json['starred_url']; subscriptionsUrl = json['subscriptions_url']; organizationsUrl = json['organizations_url']; reposUrl = json['repos_url']; eventsUrl = json['events_url']; receivedEventsUrl = json['received_events_url']; type = json['type']; siteAdmin = json['site_admin']; } Map<String, dynamic> toJson() { final Map<String, dynamic> data = new Map<String, dynamic>(); data['login'] = this.login; data['id'] = this.id; data['node_id'] = this.nodeId; data['avatar_url'] = this.avatarUrl; data['gravatar_id'] = this.gravatarId; data['url'] = this.url; data['html_url'] = this.htmlUrl; data['followers_url'] = this.followersUrl; data['following_url'] = this.followingUrl; data['gists_url'] = this.gistsUrl; data['starred_url'] = this.starredUrl; data['subscriptions_url'] = this.subscriptionsUrl; data['organizations_url'] = this.organizationsUrl; data['repos_url'] = this.reposUrl; data['events_url'] = this.eventsUrl; data['received_events_url'] = this.receivedEventsUrl; data['type'] = this.type; data['site_admin'] = this.siteAdmin; return data; } } class Labels { int id; String nodeId; String url; String name; String color; bool defaults; Labels( {this.id, this.nodeId, this.url, this.name, this.color, this.defaults}); Labels.fromJson(Map<String, dynamic> json) { id = json['id']; nodeId = json['node_id']; url = json['url']; name = json['name']; color = json['color']; defaults = json['default']; } Map<String, dynamic> toJson() { final Map<String, dynamic> data = new Map<String, dynamic>(); data['id'] = this.id; data['node_id'] = this.nodeId; data['url'] = this.url; data['name'] = this.name; data['color'] = this.color; data['default'] = this.defaults; return data; } } class Milestone { String url; String htmlUrl; String labelsUrl; int id; String nodeId; int number; String title; String description; Creator creator; int openIssues; int closedIssues; String state; String createdAt; String updatedAt; String dueOn; String closedAt; Milestone( {this.url, this.htmlUrl, this.labelsUrl, this.id, this.nodeId, this.number, this.title, this.description, this.creator, this.openIssues, this.closedIssues, this.state, this.createdAt, this.updatedAt, this.dueOn, this.closedAt}); Milestone.fromJson(Map<String, dynamic> json) { url = json['url']; htmlUrl = json['html_url']; labelsUrl = json['labels_url']; id = json['id']; nodeId = json['node_id']; number = json['number']; title = json['title']; description = json['description']; creator = json['creator'] != null ? new Creator.fromJson(json['creator']) : null; openIssues = json['open_issues']; closedIssues = json['closed_issues']; state = json['state']; createdAt = json['created_at']; updatedAt = json['updated_at']; dueOn = json['due_on']; closedAt = json['closed_at']; } Map<String, dynamic> toJson() { final Map<String, dynamic> data = new Map<String, dynamic>(); data['url'] = this.url; data['html_url'] = this.htmlUrl; data['labels_url'] = this.labelsUrl; data['id'] = this.id; data['node_id'] = this.nodeId; data['number'] = this.number; data['title'] = this.title; data['description'] = this.description; if (this.creator != null) { data['creator'] = this.creator.toJson(); } data['open_issues'] = this.openIssues; data['closed_issues'] = this.closedIssues; data['state'] = this.state; data['created_at'] = this.createdAt; data['updated_at'] = this.updatedAt; data['due_on'] = this.dueOn; data['closed_at'] = this.closedAt; return data; } } class Creator { String login; int id; String nodeId; String avatarUrl; String gravatarId; String url; String htmlUrl; String followersUrl; String followingUrl; String gistsUrl; String starredUrl; String subscriptionsUrl; String organizationsUrl; String reposUrl; String eventsUrl; String receivedEventsUrl; String type; bool siteAdmin; Creator( {this.login, this.id, this.nodeId, this.avatarUrl, this.gravatarId, this.url, this.htmlUrl, this.followersUrl, this.followingUrl, this.gistsUrl, this.starredUrl, this.subscriptionsUrl, this.organizationsUrl, this.reposUrl, this.eventsUrl, this.receivedEventsUrl, this.type, this.siteAdmin}); Creator.fromJson(Map<String, dynamic> json) { login = json['login']; id = json['id']; nodeId = json['node_id']; avatarUrl = json['avatar_url']; gravatarId = json['gravatar_id']; url = json['url']; htmlUrl = json['html_url']; followersUrl = json['followers_url']; followingUrl = json['following_url']; gistsUrl = json['gists_url']; starredUrl = json['starred_url']; subscriptionsUrl = json['subscriptions_url']; organizationsUrl = json['organizations_url']; reposUrl = json['repos_url']; eventsUrl = json['events_url']; receivedEventsUrl = json['received_events_url']; type = json['type']; siteAdmin = json['site_admin']; } Map<String, dynamic> toJson() { final Map<String, dynamic> data = new Map<String, dynamic>(); data['login'] = this.login; data['id'] = this.id; data['node_id'] = this.nodeId; data['avatar_url'] = this.avatarUrl; data['gravatar_id'] = this.gravatarId; data['url'] = this.url; data['html_url'] = this.htmlUrl; data['followers_url'] = this.followersUrl; data['following_url'] = this.followingUrl; data['gists_url'] = this.gistsUrl; data['starred_url'] = this.starredUrl; data['subscriptions_url'] = this.subscriptionsUrl; data['organizations_url'] = this.organizationsUrl; data['repos_url'] = this.reposUrl; data['events_url'] = this.eventsUrl; data['received_events_url'] = this.receivedEventsUrl; data['type'] = this.type; data['site_admin'] = this.siteAdmin; return data; } } class Head { String label; String ref; String sha; User user; Repo repo; Head({this.label, this.ref, this.sha, this.user, this.repo}); Head.fromJson(Map<String, dynamic> json) { label = json['label']; ref = json['ref']; sha = json['sha']; user = json['user'] != null ? new User.fromJson(json['user']) : null; repo = json['repo'] != null ? new Repo.fromJson(json['repo']) : null; } Map<String, dynamic> toJson() { final Map<String, dynamic> data = new Map<String, dynamic>(); data['label'] = this.label; data['ref'] = this.ref; data['sha'] = this.sha; if (this.user != null) { data['user'] = this.user.toJson(); } if (this.repo != null) { data['repo'] = this.repo.toJson(); } return data; } } class Repo { int id; String nodeId; String name; String fullName; bool private; Owner owner; String htmlUrl; String description; bool fork; String url; String forksUrl; String keysUrl; String collaboratorsUrl; String teamsUrl; String hooksUrl; String issueEventsUrl; String eventsUrl; String assigneesUrl; String branchesUrl; String tagsUrl; String blobsUrl; String gitTagsUrl; String gitRefsUrl; String treesUrl; String statusesUrl; String languagesUrl; String stargazersUrl; String contributorsUrl; String subscribersUrl; String subscriptionUrl; String commitsUrl; String gitCommitsUrl; String commentsUrl; String issueCommentUrl; String contentsUrl; String compareUrl; String mergesUrl; String archiveUrl; String downloadsUrl; String issuesUrl; String pullsUrl; String milestonesUrl; String notificationsUrl; String labelsUrl; String releasesUrl; String deploymentsUrl; String createdAt; String updatedAt; String pushedAt; String gitUrl; String sshUrl; String cloneUrl; String svnUrl; String homepage; int size; int stargazersCount; int watchersCount; String language; bool hasIssues; bool hasProjects; bool hasDownloads; bool hasWiki; bool hasPages; int forksCount; String mirrorUrl; bool archived; int openIssuesCount; License license; int forks; int openIssues; int watchers; String defaultBranch; Repo( {this.id, this.nodeId, this.name, this.fullName, this.private, this.owner, this.htmlUrl, this.description, this.fork, this.url, this.forksUrl, this.keysUrl, this.collaboratorsUrl, this.teamsUrl, this.hooksUrl, this.issueEventsUrl, this.eventsUrl, this.assigneesUrl, this.branchesUrl, this.tagsUrl, this.blobsUrl, this.gitTagsUrl, this.gitRefsUrl, this.treesUrl, this.statusesUrl, this.languagesUrl, this.stargazersUrl, this.contributorsUrl, this.subscribersUrl, this.subscriptionUrl, this.commitsUrl, this.gitCommitsUrl, this.commentsUrl, this.issueCommentUrl, this.contentsUrl, this.compareUrl, this.mergesUrl, this.archiveUrl, this.downloadsUrl, this.issuesUrl, this.pullsUrl, this.milestonesUrl, this.notificationsUrl, this.labelsUrl, this.releasesUrl, this.deploymentsUrl, this.createdAt, this.updatedAt, this.pushedAt, this.gitUrl, this.sshUrl, this.cloneUrl, this.svnUrl, this.homepage, this.size, this.stargazersCount, this.watchersCount, this.language, this.hasIssues, this.hasProjects, this.hasDownloads, this.hasWiki, this.hasPages, this.forksCount, this.mirrorUrl, this.archived, this.openIssuesCount, this.license, this.forks, this.openIssues, this.watchers, this.defaultBranch}); Repo.fromJson(Map<String, dynamic> json) { id = json['id']; nodeId = json['node_id']; name = json['name']; fullName = json['full_name']; private = json['private']; owner = json['owner'] != null ? new Owner.fromJson(json['owner']) : null; htmlUrl = json['html_url']; description = json['description']; fork = json['fork']; url = json['url']; forksUrl = json['forks_url']; keysUrl = json['keys_url']; collaboratorsUrl = json['collaborators_url']; teamsUrl = json['teams_url']; hooksUrl = json['hooks_url']; issueEventsUrl = json['issue_events_url']; eventsUrl = json['events_url']; assigneesUrl = json['assignees_url']; branchesUrl = json['branches_url']; tagsUrl = json['tags_url']; blobsUrl = json['blobs_url']; gitTagsUrl = json['git_tags_url']; gitRefsUrl = json['git_refs_url']; treesUrl = json['trees_url']; statusesUrl = json['statuses_url']; languagesUrl = json['languages_url']; stargazersUrl = json['stargazers_url']; contributorsUrl = json['contributors_url']; subscribersUrl = json['subscribers_url']; subscriptionUrl = json['subscription_url']; commitsUrl = json['commits_url']; gitCommitsUrl = json['git_commits_url']; commentsUrl = json['comments_url']; issueCommentUrl = json['issue_comment_url']; contentsUrl = json['contents_url']; compareUrl = json['compare_url']; mergesUrl = json['merges_url']; archiveUrl = json['archive_url']; downloadsUrl = json['downloads_url']; issuesUrl = json['issues_url']; pullsUrl = json['pulls_url']; milestonesUrl = json['milestones_url']; notificationsUrl = json['notifications_url']; labelsUrl = json['labels_url']; releasesUrl = json['releases_url']; deploymentsUrl = json['deployments_url']; createdAt = json['created_at']; updatedAt = json['updated_at']; pushedAt = json['pushed_at']; gitUrl = json['git_url']; sshUrl = json['ssh_url']; cloneUrl = json['clone_url']; svnUrl = json['svn_url']; homepage = json['homepage']; size = json['size']; stargazersCount = json['stargazers_count']; watchersCount = json['watchers_count']; language = json['language']; hasIssues = json['has_issues']; hasProjects = json['has_projects']; hasDownloads = json['has_downloads']; hasWiki = json['has_wiki']; hasPages = json['has_pages']; forksCount = json['forks_count']; mirrorUrl = json['mirror_url']; archived = json['archived']; openIssuesCount = json['open_issues_count']; license = json['license'] != null ? new License.fromJson(json['license']) : null; forks = json['forks']; openIssues = json['open_issues']; watchers = json['watchers']; defaultBranch = json['default_branch']; } Map<String, dynamic> toJson() { final Map<String, dynamic> data = new Map<String, dynamic>(); data['id'] = this.id; data['node_id'] = this.nodeId; data['name'] = this.name; data['full_name'] = this.fullName; data['private'] = this.private; if (this.owner != null) { data['owner'] = this.owner.toJson(); } data['html_url'] = this.htmlUrl; data['description'] = this.description; data['fork'] = this.fork; data['url'] = this.url; data['forks_url'] = this.forksUrl; data['keys_url'] = this.keysUrl; data['collaborators_url'] = this.collaboratorsUrl; data['teams_url'] = this.teamsUrl; data['hooks_url'] = this.hooksUrl; data['issue_events_url'] = this.issueEventsUrl; data['events_url'] = this.eventsUrl; data['assignees_url'] = this.assigneesUrl; data['branches_url'] = this.branchesUrl; data['tags_url'] = this.tagsUrl; data['blobs_url'] = this.blobsUrl; data['git_tags_url'] = this.gitTagsUrl; data['git_refs_url'] = this.gitRefsUrl; data['trees_url'] = this.treesUrl; data['statuses_url'] = this.statusesUrl; data['languages_url'] = this.languagesUrl; data['stargazers_url'] = this.stargazersUrl; data['contributors_url'] = this.contributorsUrl; data['subscribers_url'] = this.subscribersUrl; data['subscription_url'] = this.subscriptionUrl; data['commits_url'] = this.commitsUrl; data['git_commits_url'] = this.gitCommitsUrl; data['comments_url'] = this.commentsUrl; data['issue_comment_url'] = this.issueCommentUrl; data['contents_url'] = this.contentsUrl; data['compare_url'] = this.compareUrl; data['merges_url'] = this.mergesUrl; data['archive_url'] = this.archiveUrl; data['downloads_url'] = this.downloadsUrl; data['issues_url'] = this.issuesUrl; data['pulls_url'] = this.pullsUrl; data['milestones_url'] = this.milestonesUrl; data['notifications_url'] = this.notificationsUrl; data['labels_url'] = this.labelsUrl; data['releases_url'] = this.releasesUrl; data['deployments_url'] = this.deploymentsUrl; data['created_at'] = this.createdAt; data['updated_at'] = this.updatedAt; data['pushed_at'] = this.pushedAt; data['git_url'] = this.gitUrl; data['ssh_url'] = this.sshUrl; data['clone_url'] = this.cloneUrl; data['svn_url'] = this.svnUrl; data['homepage'] = this.homepage; data['size'] = this.size; data['stargazers_count'] = this.stargazersCount; data['watchers_count'] = this.watchersCount; data['language'] = this.language; data['has_issues'] = this.hasIssues; data['has_projects'] = this.hasProjects; data['has_downloads'] = this.hasDownloads; data['has_wiki'] = this.hasWiki; data['has_pages'] = this.hasPages; data['forks_count'] = this.forksCount; data['mirror_url'] = this.mirrorUrl; data['archived'] = this.archived; data['open_issues_count'] = this.openIssuesCount; if (this.license != null) { data['license'] = this.license.toJson(); } data['forks'] = this.forks; data['open_issues'] = this.openIssues; data['watchers'] = this.watchers; data['default_branch'] = this.defaultBranch; return data; } } class Owner { String login; int id; String nodeId; String avatarUrl; String gravatarId; String url; String htmlUrl; String followersUrl; String followingUrl; String gistsUrl; String starredUrl; String subscriptionsUrl; String organizationsUrl; String reposUrl; String eventsUrl; String receivedEventsUrl; String type; bool siteAdmin; Owner( {this.login, this.id, this.nodeId, this.avatarUrl, this.gravatarId, this.url, this.htmlUrl, this.followersUrl, this.followingUrl, this.gistsUrl, this.starredUrl, this.subscriptionsUrl, this.organizationsUrl, this.reposUrl, this.eventsUrl, this.receivedEventsUrl, this.type, this.siteAdmin}); Owner.fromJson(Map<String, dynamic> json) { login = json['login']; id = json['id']; nodeId = json['node_id']; avatarUrl = json['avatar_url']; gravatarId = json['gravatar_id']; url = json['url']; htmlUrl = json['html_url']; followersUrl = json['followers_url']; followingUrl = json['following_url']; gistsUrl = json['gists_url']; starredUrl = json['starred_url']; subscriptionsUrl = json['subscriptions_url']; organizationsUrl = json['organizations_url']; reposUrl = json['repos_url']; eventsUrl = json['events_url']; receivedEventsUrl = json['received_events_url']; type = json['type']; siteAdmin = json['site_admin']; } Map<String, dynamic> toJson() { final Map<String, dynamic> data = new Map<String, dynamic>(); data['login'] = this.login; data['id'] = this.id; data['node_id'] = this.nodeId; data['avatar_url'] = this.avatarUrl; data['gravatar_id'] = this.gravatarId; data['url'] = this.url; data['html_url'] = this.htmlUrl; data['followers_url'] = this.followersUrl; data['following_url'] = this.followingUrl; data['gists_url'] = this.gistsUrl; data['starred_url'] = this.starredUrl; data['subscriptions_url'] = this.subscriptionsUrl; data['organizations_url'] = this.organizationsUrl; data['repos_url'] = this.reposUrl; data['events_url'] = this.eventsUrl; data['received_events_url'] = this.receivedEventsUrl; data['type'] = this.type; data['site_admin'] = this.siteAdmin; return data; } } class License { String key; String name; String spdxId; String url; String nodeId; License({this.key, this.name, this.spdxId, this.url, this.nodeId}); License.fromJson(Map<String, dynamic> json) { key = json['key']; name = json['name']; spdxId = json['spdx_id']; url = json['url']; nodeId = json['node_id']; } Map<String, dynamic> toJson() { final Map<String, dynamic> data = new Map<String, dynamic>(); data['key'] = this.key; data['name'] = this.name; data['spdx_id'] = this.spdxId; data['url'] = this.url; data['node_id'] = this.nodeId; return data; } } class Base { String label; String ref; String sha; User user; Repo repo; Base({this.label, this.ref, this.sha, this.user, this.repo}); Base.fromJson(Map<String, dynamic> json) { label = json['label']; ref = json['ref']; sha = json['sha']; user = json['user'] != null ? new User.fromJson(json['user']) : null; repo = json['repo'] != null ? new Repo.fromJson(json['repo']) : null; } Map<String, dynamic> toJson() { final Map<String, dynamic> data = new Map<String, dynamic>(); data['label'] = this.label; data['ref'] = this.ref; data['sha'] = this.sha; if (this.user != null) { data['user'] = this.user.toJson(); } if (this.repo != null) { data['repo'] = this.repo.toJson(); } return data; } } class Links { Self self; Html html; Issue issue; Comments comments; ReviewComments reviewComments; ReviewComment reviewComment; Commits commits; Statuses statuses; Links( {this.self, this.html, this.issue, this.comments, this.reviewComments, this.reviewComment, this.commits, this.statuses}); Links.fromJson(Map<String, dynamic> json) { self = json['self'] != null ? new Self.fromJson(json['self']) : null; html = json['html'] != null ? new Html.fromJson(json['html']) : null; issue = json['issue'] != null ? new Issue.fromJson(json['issue']) : null; comments = json['comments'] != null ? new Comments.fromJson(json['comments']) : null; reviewComments = json['review_comments'] != null ? new ReviewComments.fromJson(json['review_comments']) : null; reviewComment = json['review_comment'] != null ? new ReviewComment.fromJson(json['review_comment']) : null; commits = json['commits'] != null ? new Commits.fromJson(json['commits']) : null; statuses = json['statuses'] != null ? new Statuses.fromJson(json['statuses']) : null; } Map<String, dynamic> toJson() { final Map<String, dynamic> data = new Map<String, dynamic>(); if (this.self != null) { data['self'] = this.self.toJson(); } if (this.html != null) { data['html'] = this.html.toJson(); } if (this.issue != null) { data['issue'] = this.issue.toJson(); } if (this.comments != null) { data['comments'] = this.comments.toJson(); } if (this.reviewComments != null) { data['review_comments'] = this.reviewComments.toJson(); } if (this.reviewComment != null) { data['review_comment'] = this.reviewComment.toJson(); } if (this.commits != null) { data['commits'] = this.commits.toJson(); } if (this.statuses != null) { data['statuses'] = this.statuses.toJson(); } return data; } } class Self { String href; Self({this.href}); Self.fromJson(Map<String, dynamic> json) { href = json['href']; } Map<String, dynamic> toJson() { final Map<String, dynamic> data = new Map<String, dynamic>(); data['href'] = this.href; return data; } } class Html { String href; Html({this.href}); Html.fromJson(Map<String, dynamic> json) { href = json['href']; } Map<String, dynamic> toJson() { final Map<String, dynamic> data = new Map<String, dynamic>(); data['href'] = this.href; return data; } } class Issue { String href; Issue({this.href}); Issue.fromJson(Map<String, dynamic> json) { href = json['href']; } Map<String, dynamic> toJson() { final Map<String, dynamic> data = new Map<String, dynamic>(); data['href'] = this.href; return data; } } class Comments { String href; Comments({this.href}); Comments.fromJson(Map<String, dynamic> json) { href = json['href']; } Map<String, dynamic> toJson() { final Map<String, dynamic> data = new Map<String, dynamic>(); data['href'] = this.href; return data; } } class ReviewComments { String href; ReviewComments({this.href}); ReviewComments.fromJson(Map<String, dynamic> json) { href = json['href']; } Map<String, dynamic> toJson() { final Map<String, dynamic> data = new Map<String, dynamic>(); data['href'] = this.href; return data; } } class ReviewComment { String href; ReviewComment({this.href}); ReviewComment.fromJson(Map<String, dynamic> json) { href = json['href']; } Map<String, dynamic> toJson() { final Map<String, dynamic> data = new Map<String, dynamic>(); data['href'] = this.href; return data; } } class Commits { String href; Commits({this.href}); Commits.fromJson(Map<String, dynamic> json) { href = json['href']; } Map<String, dynamic> toJson() { final Map<String, dynamic> data = new Map<String, dynamic>(); data['href'] = this.href; return data; } } class Statuses { String href; Statuses({this.href}); Statuses.fromJson(Map<String, dynamic> json) { href = json['href']; } Map<String, dynamic> toJson() { final Map<String, dynamic> data = new Map<String, dynamic>(); data['href'] = this.href; return data; } }
0
mirrored_repositories/FlutterGithubClient/lib
mirrored_repositories/FlutterGithubClient/lib/model/GistModel.dart
import 'dart:convert'; class GistModel { String url; String forksUrl; String commitsUrl; String id; String nodeId; String gitPullUrl; String gitPushUrl; String htmlUrl; Files files; bool public; String createdAt; String updatedAt; String description; int comments; Null user; String commentsUrl; Owner owner; bool truncated; GistModel( {this.url, this.forksUrl, this.commitsUrl, this.id, this.nodeId, this.gitPullUrl, this.gitPushUrl, this.htmlUrl, this.files, this.public, this.createdAt, this.updatedAt, this.description, this.comments, this.user, this.commentsUrl, this.owner, this.truncated}); GistModel.fromJson(Map<String, dynamic> json) { url = json['url']; forksUrl = json['forks_url']; commitsUrl = json['commits_url']; id = json['id']; nodeId = json['node_id']; gitPullUrl = json['git_pull_url']; gitPushUrl = json['git_push_url']; htmlUrl = json['html_url']; files = json['files'] != null ? new Files.fromJson(json['files']) : null; public = json['public']; createdAt = json['created_at']; updatedAt = json['updated_at']; description = json['description']; comments = json['comments']; user = json['user']; commentsUrl = json['comments_url']; owner = json['owner'] != null ? new Owner.fromJson(json['owner']) : null; truncated = json['truncated']; } getDescription() { var desc = StringBuffer(""); if(description.isNotEmpty){ desc.write(description); } return desc; } getLangFileInfo(){ var desc = StringBuffer(); desc.writeln("Language:"+files.getLanguages()); desc.write(files.getFileInfo()); return desc; } } class Files { List<GistFile> gistFile = List(); Files({this.gistFile}); Files.fromJson(Map<String, dynamic> jsonFiles) { jsonFiles.forEach((key,value){ print(key); print(value); gistFile.add(GistFile.fromJson(value)); }); } String getLanguages() { var languages= this.gistFile.map((file){ return file.language; }); return languages.join(","); } String getFileInfo() { var fileInfo= this.gistFile.map((file){ return "File Name:"+file.filename +"\n"+"File Type:"+ file.type+"\n"+"File Size:"+file.size.toString(); }); return fileInfo.join(","); } } class GistFile { String filename; String type; String language; String rawUrl; int size; GistFile( {this.filename, this.type, this.language, this.rawUrl, this.size}); GistFile.fromJson(Map<String, dynamic> json) { filename = json['filename']; type = json['type']; language = json['language']; rawUrl = json['raw_url']; size = json['size']; } Map<String, dynamic> toJson() { final Map<String, dynamic> data = new Map<String, dynamic>(); data['filename'] = this.filename; data['type'] = this.type; data['language'] = this.language; data['raw_url'] = this.rawUrl; data['size'] = this.size; return data; } } class Owner { String login; int id; String nodeId; String avatarUrl; String gravatarId; String url; String htmlUrl; String followersUrl; String followingUrl; String gistsUrl; String starredUrl; String subscriptionsUrl; String organizationsUrl; String reposUrl; String eventsUrl; String receivedEventsUrl; String type; bool siteAdmin; Owner( {this.login, this.id, this.nodeId, this.avatarUrl, this.gravatarId, this.url, this.htmlUrl, this.followersUrl, this.followingUrl, this.gistsUrl, this.starredUrl, this.subscriptionsUrl, this.organizationsUrl, this.reposUrl, this.eventsUrl, this.receivedEventsUrl, this.type, this.siteAdmin}); Owner.fromJson(Map<String, dynamic> json) { login = json['login']; id = json['id']; nodeId = json['node_id']; avatarUrl = json['avatar_url']; gravatarId = json['gravatar_id']; url = json['url']; htmlUrl = json['html_url']; followersUrl = json['followers_url']; followingUrl = json['following_url']; gistsUrl = json['gists_url']; starredUrl = json['starred_url']; subscriptionsUrl = json['subscriptions_url']; organizationsUrl = json['organizations_url']; reposUrl = json['repos_url']; eventsUrl = json['events_url']; receivedEventsUrl = json['received_events_url']; type = json['type']; siteAdmin = json['site_admin']; } Map<String, dynamic> toJson() { final Map<String, dynamic> data = new Map<String, dynamic>(); data['login'] = this.login; data['id'] = this.id; data['node_id'] = this.nodeId; data['avatar_url'] = this.avatarUrl; data['gravatar_id'] = this.gravatarId; data['url'] = this.url; data['html_url'] = this.htmlUrl; data['followers_url'] = this.followersUrl; data['following_url'] = this.followingUrl; data['gists_url'] = this.gistsUrl; data['starred_url'] = this.starredUrl; data['subscriptions_url'] = this.subscriptionsUrl; data['organizations_url'] = this.organizationsUrl; data['repos_url'] = this.reposUrl; data['events_url'] = this.eventsUrl; data['received_events_url'] = this.receivedEventsUrl; data['type'] = this.type; data['site_admin'] = this.siteAdmin; return data; } }
0
mirrored_repositories/FlutterGithubClient/lib
mirrored_repositories/FlutterGithubClient/lib/model/Issue.dart
class Issue { String url; String repositoryUrl; String labelsUrl; String commentsUrl; String eventsUrl; String htmlUrl; int id; String nodeId; int number; String title; User user; List<Labels> labels; String state; bool locked; Assignee assignee; List<Assignees> assignees; Milestone milestone; int comments; String createdAt; String updatedAt; String closedAt; String authorAssociation; String body; ClosedBy closedBy; Issue( {this.url, this.repositoryUrl, this.labelsUrl, this.commentsUrl, this.eventsUrl, this.htmlUrl, this.id, this.nodeId, this.number, this.title, this.user, this.labels, this.state, this.locked, this.assignee, this.assignees, this.milestone, this.comments, this.createdAt, this.updatedAt, this.closedAt, this.authorAssociation, this.body, this.closedBy}); Issue.fromJson(Map<String, dynamic> json) { url = json['url']; repositoryUrl = json['repository_url']; labelsUrl = json['labels_url']; commentsUrl = json['comments_url']; eventsUrl = json['events_url']; htmlUrl = json['html_url']; id = json['id']; nodeId = json['node_id']; number = json['number']; title = json['title']; user = json['user'] != null ? new User.fromJson(json['user']) : null; if (json['labels'] != null) { labels = new List<Labels>(); json['labels'].forEach((v) { labels.add(new Labels.fromJson(v)); }); } state = json['state']; locked = json['locked']; assignee = json['assignee'] != null ? new Assignee.fromJson(json['assignee']) : null; if (json['assignees'] != null) { assignees = new List<Assignees>(); json['assignees'].forEach((v) { assignees.add(new Assignees.fromJson(v)); }); } milestone = json['milestone'] != null ? new Milestone.fromJson(json['milestone']) : null; comments = json['comments']; createdAt = json['created_at']; updatedAt = json['updated_at']; closedAt = json['closed_at']; authorAssociation = json['author_association']; body = json['body']; closedBy = json['closed_by'] != null ? new ClosedBy.fromJson(json['closed_by']) : null; } Map<String, dynamic> toJson() { final Map<String, dynamic> data = new Map<String, dynamic>(); data['url'] = this.url; data['repository_url'] = this.repositoryUrl; data['labels_url'] = this.labelsUrl; data['comments_url'] = this.commentsUrl; data['events_url'] = this.eventsUrl; data['html_url'] = this.htmlUrl; data['id'] = this.id; data['node_id'] = this.nodeId; data['number'] = this.number; data['title'] = this.title; if (this.user != null) { data['user'] = this.user.toJson(); } if (this.labels != null) { data['labels'] = this.labels.map((v) => v.toJson()).toList(); } data['state'] = this.state; data['locked'] = this.locked; if (this.assignee != null) { data['assignee'] = this.assignee.toJson(); } if (this.assignees != null) { data['assignees'] = this.assignees.map((v) => v.toJson()).toList(); } if (this.milestone != null) { data['milestone'] = this.milestone.toJson(); } data['comments'] = this.comments; data['created_at'] = this.createdAt; data['updated_at'] = this.updatedAt; data['closed_at'] = this.closedAt; data['author_association'] = this.authorAssociation; data['body'] = this.body; if (this.closedBy != null) { data['closed_by'] = this.closedBy.toJson(); } return data; } } class User { String login; int id; String nodeId; String avatarUrl; String gravatarId; String url; String htmlUrl; String followersUrl; String followingUrl; String gistsUrl; String starredUrl; String subscriptionsUrl; String organizationsUrl; String reposUrl; String eventsUrl; String receivedEventsUrl; String type; bool siteAdmin; User( {this.login, this.id, this.nodeId, this.avatarUrl, this.gravatarId, this.url, this.htmlUrl, this.followersUrl, this.followingUrl, this.gistsUrl, this.starredUrl, this.subscriptionsUrl, this.organizationsUrl, this.reposUrl, this.eventsUrl, this.receivedEventsUrl, this.type, this.siteAdmin}); User.fromJson(Map<String, dynamic> json) { login = json['login']; id = json['id']; nodeId = json['node_id']; avatarUrl = json['avatar_url']; gravatarId = json['gravatar_id']; url = json['url']; htmlUrl = json['html_url']; followersUrl = json['followers_url']; followingUrl = json['following_url']; gistsUrl = json['gists_url']; starredUrl = json['starred_url']; subscriptionsUrl = json['subscriptions_url']; organizationsUrl = json['organizations_url']; reposUrl = json['repos_url']; eventsUrl = json['events_url']; receivedEventsUrl = json['received_events_url']; type = json['type']; siteAdmin = json['site_admin']; } Map<String, dynamic> toJson() { final Map<String, dynamic> data = new Map<String, dynamic>(); data['login'] = this.login; data['id'] = this.id; data['node_id'] = this.nodeId; data['avatar_url'] = this.avatarUrl; data['gravatar_id'] = this.gravatarId; data['url'] = this.url; data['html_url'] = this.htmlUrl; data['followers_url'] = this.followersUrl; data['following_url'] = this.followingUrl; data['gists_url'] = this.gistsUrl; data['starred_url'] = this.starredUrl; data['subscriptions_url'] = this.subscriptionsUrl; data['organizations_url'] = this.organizationsUrl; data['repos_url'] = this.reposUrl; data['events_url'] = this.eventsUrl; data['received_events_url'] = this.receivedEventsUrl; data['type'] = this.type; data['site_admin'] = this.siteAdmin; return data; } } class Labels { int id; String nodeId; String url; String name; String color; bool defaults; Labels( {this.id, this.nodeId, this.url, this.name, this.color, this.defaults}); Labels.fromJson(Map<String, dynamic> json) { id = json['id']; nodeId = json['node_id']; url = json['url']; name = json['name']; color = json['color']; defaults = json['default']; } Map<String, dynamic> toJson() { final Map<String, dynamic> data = new Map<String, dynamic>(); data['id'] = this.id; data['node_id'] = this.nodeId; data['url'] = this.url; data['name'] = this.name; data['color'] = this.color; data['default'] = this.defaults; return data; } } class Assignee { String login; int id; String nodeId; String avatarUrl; String gravatarId; String url; String htmlUrl; String followersUrl; String followingUrl; String gistsUrl; String starredUrl; String subscriptionsUrl; String organizationsUrl; String reposUrl; String eventsUrl; String receivedEventsUrl; String type; bool siteAdmin; Assignee( {this.login, this.id, this.nodeId, this.avatarUrl, this.gravatarId, this.url, this.htmlUrl, this.followersUrl, this.followingUrl, this.gistsUrl, this.starredUrl, this.subscriptionsUrl, this.organizationsUrl, this.reposUrl, this.eventsUrl, this.receivedEventsUrl, this.type, this.siteAdmin}); Assignee.fromJson(Map<String, dynamic> json) { login = json['login']; id = json['id']; nodeId = json['node_id']; avatarUrl = json['avatar_url']; gravatarId = json['gravatar_id']; url = json['url']; htmlUrl = json['html_url']; followersUrl = json['followers_url']; followingUrl = json['following_url']; gistsUrl = json['gists_url']; starredUrl = json['starred_url']; subscriptionsUrl = json['subscriptions_url']; organizationsUrl = json['organizations_url']; reposUrl = json['repos_url']; eventsUrl = json['events_url']; receivedEventsUrl = json['received_events_url']; type = json['type']; siteAdmin = json['site_admin']; } Map<String, dynamic> toJson() { final Map<String, dynamic> data = new Map<String, dynamic>(); data['login'] = this.login; data['id'] = this.id; data['node_id'] = this.nodeId; data['avatar_url'] = this.avatarUrl; data['gravatar_id'] = this.gravatarId; data['url'] = this.url; data['html_url'] = this.htmlUrl; data['followers_url'] = this.followersUrl; data['following_url'] = this.followingUrl; data['gists_url'] = this.gistsUrl; data['starred_url'] = this.starredUrl; data['subscriptions_url'] = this.subscriptionsUrl; data['organizations_url'] = this.organizationsUrl; data['repos_url'] = this.reposUrl; data['events_url'] = this.eventsUrl; data['received_events_url'] = this.receivedEventsUrl; data['type'] = this.type; data['site_admin'] = this.siteAdmin; return data; } } class Assignees { String login; int id; String nodeId; String avatarUrl; String gravatarId; String url; String htmlUrl; String followersUrl; String followingUrl; String gistsUrl; String starredUrl; String subscriptionsUrl; String organizationsUrl; String reposUrl; String eventsUrl; String receivedEventsUrl; String type; bool siteAdmin; Assignees( {this.login, this.id, this.nodeId, this.avatarUrl, this.gravatarId, this.url, this.htmlUrl, this.followersUrl, this.followingUrl, this.gistsUrl, this.starredUrl, this.subscriptionsUrl, this.organizationsUrl, this.reposUrl, this.eventsUrl, this.receivedEventsUrl, this.type, this.siteAdmin}); Assignees.fromJson(Map<String, dynamic> json) { login = json['login']; id = json['id']; nodeId = json['node_id']; avatarUrl = json['avatar_url']; gravatarId = json['gravatar_id']; url = json['url']; htmlUrl = json['html_url']; followersUrl = json['followers_url']; followingUrl = json['following_url']; gistsUrl = json['gists_url']; starredUrl = json['starred_url']; subscriptionsUrl = json['subscriptions_url']; organizationsUrl = json['organizations_url']; reposUrl = json['repos_url']; eventsUrl = json['events_url']; receivedEventsUrl = json['received_events_url']; type = json['type']; siteAdmin = json['site_admin']; } Map<String, dynamic> toJson() { final Map<String, dynamic> data = new Map<String, dynamic>(); data['login'] = this.login; data['id'] = this.id; data['node_id'] = this.nodeId; data['avatar_url'] = this.avatarUrl; data['gravatar_id'] = this.gravatarId; data['url'] = this.url; data['html_url'] = this.htmlUrl; data['followers_url'] = this.followersUrl; data['following_url'] = this.followingUrl; data['gists_url'] = this.gistsUrl; data['starred_url'] = this.starredUrl; data['subscriptions_url'] = this.subscriptionsUrl; data['organizations_url'] = this.organizationsUrl; data['repos_url'] = this.reposUrl; data['events_url'] = this.eventsUrl; data['received_events_url'] = this.receivedEventsUrl; data['type'] = this.type; data['site_admin'] = this.siteAdmin; return data; } } class Milestone { String url; String htmlUrl; String labelsUrl; int id; String nodeId; int number; String title; String description; Creator creator; int openIssues; int closedIssues; String state; String createdAt; String updatedAt; String dueOn; String closedAt; Milestone( {this.url, this.htmlUrl, this.labelsUrl, this.id, this.nodeId, this.number, this.title, this.description, this.creator, this.openIssues, this.closedIssues, this.state, this.createdAt, this.updatedAt, this.dueOn, this.closedAt}); Milestone.fromJson(Map<String, dynamic> json) { url = json['url']; htmlUrl = json['html_url']; labelsUrl = json['labels_url']; id = json['id']; nodeId = json['node_id']; number = json['number']; title = json['title']; description = json['description']; creator = json['creator'] != null ? new Creator.fromJson(json['creator']) : null; openIssues = json['open_issues']; closedIssues = json['closed_issues']; state = json['state']; createdAt = json['created_at']; updatedAt = json['updated_at']; dueOn = json['due_on']; closedAt = json['closed_at']; } Map<String, dynamic> toJson() { final Map<String, dynamic> data = new Map<String, dynamic>(); data['url'] = this.url; data['html_url'] = this.htmlUrl; data['labels_url'] = this.labelsUrl; data['id'] = this.id; data['node_id'] = this.nodeId; data['number'] = this.number; data['title'] = this.title; data['description'] = this.description; if (this.creator != null) { data['creator'] = this.creator.toJson(); } data['open_issues'] = this.openIssues; data['closed_issues'] = this.closedIssues; data['state'] = this.state; data['created_at'] = this.createdAt; data['updated_at'] = this.updatedAt; data['due_on'] = this.dueOn; data['closed_at'] = this.closedAt; return data; } } class Creator { String login; int id; String nodeId; String avatarUrl; String gravatarId; String url; String htmlUrl; String followersUrl; String followingUrl; String gistsUrl; String starredUrl; String subscriptionsUrl; String organizationsUrl; String reposUrl; String eventsUrl; String receivedEventsUrl; String type; bool siteAdmin; Creator( {this.login, this.id, this.nodeId, this.avatarUrl, this.gravatarId, this.url, this.htmlUrl, this.followersUrl, this.followingUrl, this.gistsUrl, this.starredUrl, this.subscriptionsUrl, this.organizationsUrl, this.reposUrl, this.eventsUrl, this.receivedEventsUrl, this.type, this.siteAdmin}); Creator.fromJson(Map<String, dynamic> json) { login = json['login']; id = json['id']; nodeId = json['node_id']; avatarUrl = json['avatar_url']; gravatarId = json['gravatar_id']; url = json['url']; htmlUrl = json['html_url']; followersUrl = json['followers_url']; followingUrl = json['following_url']; gistsUrl = json['gists_url']; starredUrl = json['starred_url']; subscriptionsUrl = json['subscriptions_url']; organizationsUrl = json['organizations_url']; reposUrl = json['repos_url']; eventsUrl = json['events_url']; receivedEventsUrl = json['received_events_url']; type = json['type']; siteAdmin = json['site_admin']; } Map<String, dynamic> toJson() { final Map<String, dynamic> data = new Map<String, dynamic>(); data['login'] = this.login; data['id'] = this.id; data['node_id'] = this.nodeId; data['avatar_url'] = this.avatarUrl; data['gravatar_id'] = this.gravatarId; data['url'] = this.url; data['html_url'] = this.htmlUrl; data['followers_url'] = this.followersUrl; data['following_url'] = this.followingUrl; data['gists_url'] = this.gistsUrl; data['starred_url'] = this.starredUrl; data['subscriptions_url'] = this.subscriptionsUrl; data['organizations_url'] = this.organizationsUrl; data['repos_url'] = this.reposUrl; data['events_url'] = this.eventsUrl; data['received_events_url'] = this.receivedEventsUrl; data['type'] = this.type; data['site_admin'] = this.siteAdmin; return data; } } class ClosedBy { String login; int id; String nodeId; String avatarUrl; String gravatarId; String url; String htmlUrl; String followersUrl; String followingUrl; String gistsUrl; String starredUrl; String subscriptionsUrl; String organizationsUrl; String reposUrl; String eventsUrl; String receivedEventsUrl; String type; bool siteAdmin; ClosedBy( {this.login, this.id, this.nodeId, this.avatarUrl, this.gravatarId, this.url, this.htmlUrl, this.followersUrl, this.followingUrl, this.gistsUrl, this.starredUrl, this.subscriptionsUrl, this.organizationsUrl, this.reposUrl, this.eventsUrl, this.receivedEventsUrl, this.type, this.siteAdmin}); ClosedBy.fromJson(Map<String, dynamic> json) { login = json['login']; id = json['id']; nodeId = json['node_id']; avatarUrl = json['avatar_url']; gravatarId = json['gravatar_id']; url = json['url']; htmlUrl = json['html_url']; followersUrl = json['followers_url']; followingUrl = json['following_url']; gistsUrl = json['gists_url']; starredUrl = json['starred_url']; subscriptionsUrl = json['subscriptions_url']; organizationsUrl = json['organizations_url']; reposUrl = json['repos_url']; eventsUrl = json['events_url']; receivedEventsUrl = json['received_events_url']; type = json['type']; siteAdmin = json['site_admin']; } Map<String, dynamic> toJson() { final Map<String, dynamic> data = new Map<String, dynamic>(); data['login'] = this.login; data['id'] = this.id; data['node_id'] = this.nodeId; data['avatar_url'] = this.avatarUrl; data['gravatar_id'] = this.gravatarId; data['url'] = this.url; data['html_url'] = this.htmlUrl; data['followers_url'] = this.followersUrl; data['following_url'] = this.followingUrl; data['gists_url'] = this.gistsUrl; data['starred_url'] = this.starredUrl; data['subscriptions_url'] = this.subscriptionsUrl; data['organizations_url'] = this.organizationsUrl; data['repos_url'] = this.reposUrl; data['events_url'] = this.eventsUrl; data['received_events_url'] = this.receivedEventsUrl; data['type'] = this.type; data['site_admin'] = this.siteAdmin; return data; } }
0
mirrored_repositories/FlutterGithubClient/lib
mirrored_repositories/FlutterGithubClient/lib/model/UserProfile.dart
class UserProfile { String login; int id; String nodeId; String avatarUrl; String gravatarId; String url; String htmlUrl; String followersUrl; String followingUrl; String gistsUrl; String starredUrl; String subscriptionsUrl; String organizationsUrl; String reposUrl; String eventsUrl; String receivedEventsUrl; String type; bool siteAdmin; String name; String company; String blog; String location; String email; bool hireable; String bio; int publicRepos; int publicGists; int followers; int following; String createdAt; String updatedAt; int privateGists; int totalPrivateRepos; int ownedPrivateRepos; int diskUsage; int collaborators; bool twoFactorAuthentication; Plan plan; UserProfile( {this.login, this.id, this.nodeId, this.avatarUrl, this.gravatarId, this.url, this.htmlUrl, this.followersUrl, this.followingUrl, this.gistsUrl, this.starredUrl, this.subscriptionsUrl, this.organizationsUrl, this.reposUrl, this.eventsUrl, this.receivedEventsUrl, this.type, this.siteAdmin, this.name, this.company, this.blog, this.location, this.email, this.hireable, this.bio, this.publicRepos, this.publicGists, this.followers, this.following, this.createdAt, this.updatedAt, this.privateGists, this.totalPrivateRepos, this.ownedPrivateRepos, this.diskUsage, this.collaborators, this.twoFactorAuthentication, this.plan}); UserProfile.fromJson(Map<String, dynamic> json) { login = json['login']?? ""; id = json['id']?? ""; nodeId = json['node_id']?? ""; avatarUrl = json['avatar_url']?? ""; gravatarId = json['gravatar_id']?? ""; url = json['url']?? ""; htmlUrl = json['html_url']?? ""; followersUrl = json['followers_url']?? ""; followingUrl = json['following_url']?? ""; gistsUrl = json['gists_url']?? ""; starredUrl = json['starred_url']?? ""; subscriptionsUrl = json['subscriptions_url']?? ""; organizationsUrl = json['organizations_url']?? ""; reposUrl = json['repos_url']?? ""; eventsUrl = json['events_url']?? ""; receivedEventsUrl = json['received_events_url']?? ""; type = json['type']?? ""; siteAdmin = json['site_admin']?? ""; name = json['name']?? ""; company = json['company']?? ""; blog = json['blog']?? ""; location = json['location']?? ""; email = json['email']?? ""; hireable = json['hireable']?? false; bio = json['bio']?? ""; publicRepos = json['public_repos']?? 0; publicGists = json['public_gists']?? 0; followers = json['followers']?? 0; following = json['following']?? 0; createdAt = json['created_at']?? ""; updatedAt = json['updated_at']?? ""; privateGists = json['private_gists']?? 0; totalPrivateRepos = json['total_private_repos']?? 0; ownedPrivateRepos = json['owned_private_repos']?? 0; diskUsage = json['disk_usage']?? 0; collaborators = json['collaborators']?? 0; twoFactorAuthentication = json['two_factor_authentication']?? false; plan = json['plan'] != null ? new Plan.fromJson(json['plan']) : null; } Map<String, dynamic> toJson() { final Map<String, dynamic> data = new Map<String, dynamic>(); data['login'] = this.login; data['id'] = this.id; data['node_id'] = this.nodeId; data['avatar_url'] = this.avatarUrl; data['gravatar_id'] = this.gravatarId; data['url'] = this.url; data['html_url'] = this.htmlUrl; data['followers_url'] = this.followersUrl; data['following_url'] = this.followingUrl; data['gists_url'] = this.gistsUrl; data['starred_url'] = this.starredUrl; data['subscriptions_url'] = this.subscriptionsUrl; data['organizations_url'] = this.organizationsUrl; data['repos_url'] = this.reposUrl; data['events_url'] = this.eventsUrl; data['received_events_url'] = this.receivedEventsUrl; data['type'] = this.type; data['site_admin'] = this.siteAdmin; data['name'] = this.name; data['company'] = this.company; data['blog'] = this.blog; data['location'] = this.location; data['email'] = this.email; data['hireable'] = this.hireable; data['bio'] = this.bio; data['public_repos'] = this.publicRepos; data['public_gists'] = this.publicGists; data['followers'] = this.followers; data['following'] = this.following; data['created_at'] = this.createdAt; data['updated_at'] = this.updatedAt; data['private_gists'] = this.privateGists; data['total_private_repos'] = this.totalPrivateRepos; data['owned_private_repos'] = this.ownedPrivateRepos; data['disk_usage'] = this.diskUsage; data['collaborators'] = this.collaborators; data['two_factor_authentication'] = this.twoFactorAuthentication; if (this.plan != null) { data['plan'] = this.plan.toJson(); } return data; } getName() { if(name.isEmpty){ return login; }else{ return name; } } } class Plan { String name; int space; int collaborators; int privateRepos; Plan({this.name, this.space, this.collaborators, this.privateRepos}); Plan.fromJson(Map<String, dynamic> json) { name = json['name']; space = json['space']; collaborators = json['collaborators']; privateRepos = json['private_repos']; } Map<String, dynamic> toJson() { final Map<String, dynamic> data = new Map<String, dynamic>(); data['name'] = this.name; data['space'] = this.space; data['collaborators'] = this.collaborators; data['private_repos'] = this.privateRepos; return data; } } /* { "login": "barykaed", "id": 1313194, "node_id": "MDQ6VXNlcjEzMTMxOTQ=", "avatar_url": "https://avatars0.githubusercontent.com/u/1313194?v=4", "gravatar_id": "", "url": "https://api.github.com/users/barykaed", "html_url": "https://github.com/barykaed", "followers_url": "https://api.github.com/users/barykaed/followers", "following_url": "https://api.github.com/users/barykaed/following{/other_user}", "gists_url": "https://api.github.com/users/barykaed/gists{/gist_id}", "starred_url": "https://api.github.com/users/barykaed/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/barykaed/subscriptions", "organizations_url": "https://api.github.com/users/barykaed/orgs", "repos_url": "https://api.github.com/users/barykaed/repos", "events_url": "https://api.github.com/users/barykaed/events{/privacy}", "received_events_url": "https://api.github.com/users/barykaed/received_events", "type": "User", "site_admin": false, "name": "Kishore Babu", "company": "@MutualMobile", "blog": "", "location": "India", "email": "barykaed@gmail.com", "hireable": true, "bio": "I'm an Android Developer", "public_repos": 23, "public_gists": 1, "followers": 19, "following": 27, "created_at": "2012-01-08T16:31:07Z", "updated_at": "2018-09-04T12:03:21Z", "private_gists": 4, "total_private_repos": 0, "owned_private_repos": 0, "disk_usage": 14302, "collaborators": 0, "two_factor_authentication": false, "plan": { "name": "free", "space": 976562499, "collaborators": 0, "private_repos": 0 } } */
0
mirrored_repositories/FlutterGithubClient/lib
mirrored_repositories/FlutterGithubClient/lib/model/NotificationModel.dart
class NotificationModel { String id; bool unread; String reason; String updatedAt; String lastReadAt; Subject subject; Repository repository; String url; String subscriptionUrl; String status = ""; NotificationModel( {this.id, this.unread, this.reason, this.updatedAt, this.lastReadAt, this.subject, this.repository, this.url, this.subscriptionUrl}); NotificationModel.fromJson(Map<String, dynamic> json) { id = json['id']; unread = json['unread']; reason = json['reason']; updatedAt = json['updated_at']; lastReadAt = json['last_read_at']; subject = json['subject'] != null ? new Subject.fromJson(json['subject']) : null; repository = json['repository'] != null ? new Repository.fromJson(json['repository']) : null; url = json['url']; subscriptionUrl = json['subscription_url']; } Map<String, dynamic> toJson() { final Map<String, dynamic> data = new Map<String, dynamic>(); data['id'] = this.id; data['unread'] = this.unread; data['reason'] = this.reason; data['updated_at'] = this.updatedAt; data['last_read_at'] = this.lastReadAt; if (this.subject != null) { data['subject'] = this.subject.toJson(); } if (this.repository != null) { data['repository'] = this.repository.toJson(); } data['url'] = this.url; data['subscription_url'] = this.subscriptionUrl; return data; } } class Subject { String title; String url; String latestCommentUrl; String type; Subject({this.title, this.url, this.latestCommentUrl, this.type}); Subject.fromJson(Map<String, dynamic> json) { title = json['title']; url = json['url']; latestCommentUrl = json['latest_comment_url']; type = json['type']; } Map<String, dynamic> toJson() { final Map<String, dynamic> data = new Map<String, dynamic>(); data['title'] = this.title; data['url'] = this.url; data['latest_comment_url'] = this.latestCommentUrl; data['type'] = this.type; return data; } } class Repository { int id; String nodeId; String name; String fullName; bool private; Owner owner; String htmlUrl; String description; bool fork; String url; String forksUrl; String keysUrl; String collaboratorsUrl; String teamsUrl; String hooksUrl; String issueEventsUrl; String eventsUrl; String assigneesUrl; String branchesUrl; String tagsUrl; String blobsUrl; String gitTagsUrl; String gitRefsUrl; String treesUrl; String statusesUrl; String languagesUrl; String stargazersUrl; String contributorsUrl; String subscribersUrl; String subscriptionUrl; String commitsUrl; String gitCommitsUrl; String commentsUrl; String issueCommentUrl; String contentsUrl; String compareUrl; String mergesUrl; String archiveUrl; String downloadsUrl; String issuesUrl; String pullsUrl; String milestonesUrl; String notificationsUrl; String labelsUrl; String releasesUrl; String deploymentsUrl; Repository( {this.id, this.nodeId, this.name, this.fullName, this.private, this.owner, this.htmlUrl, this.description, this.fork, this.url, this.forksUrl, this.keysUrl, this.collaboratorsUrl, this.teamsUrl, this.hooksUrl, this.issueEventsUrl, this.eventsUrl, this.assigneesUrl, this.branchesUrl, this.tagsUrl, this.blobsUrl, this.gitTagsUrl, this.gitRefsUrl, this.treesUrl, this.statusesUrl, this.languagesUrl, this.stargazersUrl, this.contributorsUrl, this.subscribersUrl, this.subscriptionUrl, this.commitsUrl, this.gitCommitsUrl, this.commentsUrl, this.issueCommentUrl, this.contentsUrl, this.compareUrl, this.mergesUrl, this.archiveUrl, this.downloadsUrl, this.issuesUrl, this.pullsUrl, this.milestonesUrl, this.notificationsUrl, this.labelsUrl, this.releasesUrl, this.deploymentsUrl}); Repository.fromJson(Map<String, dynamic> json) { id = json['id']; nodeId = json['node_id']; name = json['name']; fullName = json['full_name']; private = json['private']; owner = json['owner'] != null ? new Owner.fromJson(json['owner']) : null; htmlUrl = json['html_url']; description = json['description']; fork = json['fork']; url = json['url']; forksUrl = json['forks_url']; keysUrl = json['keys_url']; collaboratorsUrl = json['collaborators_url']; teamsUrl = json['teams_url']; hooksUrl = json['hooks_url']; issueEventsUrl = json['issue_events_url']; eventsUrl = json['events_url']; assigneesUrl = json['assignees_url']; branchesUrl = json['branches_url']; tagsUrl = json['tags_url']; blobsUrl = json['blobs_url']; gitTagsUrl = json['git_tags_url']; gitRefsUrl = json['git_refs_url']; treesUrl = json['trees_url']; statusesUrl = json['statuses_url']; languagesUrl = json['languages_url']; stargazersUrl = json['stargazers_url']; contributorsUrl = json['contributors_url']; subscribersUrl = json['subscribers_url']; subscriptionUrl = json['subscription_url']; commitsUrl = json['commits_url']; gitCommitsUrl = json['git_commits_url']; commentsUrl = json['comments_url']; issueCommentUrl = json['issue_comment_url']; contentsUrl = json['contents_url']; compareUrl = json['compare_url']; mergesUrl = json['merges_url']; archiveUrl = json['archive_url']; downloadsUrl = json['downloads_url']; issuesUrl = json['issues_url']; pullsUrl = json['pulls_url']; milestonesUrl = json['milestones_url']; notificationsUrl = json['notifications_url']; labelsUrl = json['labels_url']; releasesUrl = json['releases_url']; deploymentsUrl = json['deployments_url']; } Map<String, dynamic> toJson() { final Map<String, dynamic> data = new Map<String, dynamic>(); data['id'] = this.id; data['node_id'] = this.nodeId; data['name'] = this.name; data['full_name'] = this.fullName; data['private'] = this.private; if (this.owner != null) { data['owner'] = this.owner.toJson(); } data['html_url'] = this.htmlUrl; data['description'] = this.description; data['fork'] = this.fork; data['url'] = this.url; data['forks_url'] = this.forksUrl; data['keys_url'] = this.keysUrl; data['collaborators_url'] = this.collaboratorsUrl; data['teams_url'] = this.teamsUrl; data['hooks_url'] = this.hooksUrl; data['issue_events_url'] = this.issueEventsUrl; data['events_url'] = this.eventsUrl; data['assignees_url'] = this.assigneesUrl; data['branches_url'] = this.branchesUrl; data['tags_url'] = this.tagsUrl; data['blobs_url'] = this.blobsUrl; data['git_tags_url'] = this.gitTagsUrl; data['git_refs_url'] = this.gitRefsUrl; data['trees_url'] = this.treesUrl; data['statuses_url'] = this.statusesUrl; data['languages_url'] = this.languagesUrl; data['stargazers_url'] = this.stargazersUrl; data['contributors_url'] = this.contributorsUrl; data['subscribers_url'] = this.subscribersUrl; data['subscription_url'] = this.subscriptionUrl; data['commits_url'] = this.commitsUrl; data['git_commits_url'] = this.gitCommitsUrl; data['comments_url'] = this.commentsUrl; data['issue_comment_url'] = this.issueCommentUrl; data['contents_url'] = this.contentsUrl; data['compare_url'] = this.compareUrl; data['merges_url'] = this.mergesUrl; data['archive_url'] = this.archiveUrl; data['downloads_url'] = this.downloadsUrl; data['issues_url'] = this.issuesUrl; data['pulls_url'] = this.pullsUrl; data['milestones_url'] = this.milestonesUrl; data['notifications_url'] = this.notificationsUrl; data['labels_url'] = this.labelsUrl; data['releases_url'] = this.releasesUrl; data['deployments_url'] = this.deploymentsUrl; return data; } } class Owner { String login; int id; String nodeId; String avatarUrl; String gravatarId; String url; String htmlUrl; String followersUrl; String followingUrl; String gistsUrl; String starredUrl; String subscriptionsUrl; String organizationsUrl; String reposUrl; String eventsUrl; String receivedEventsUrl; String type; bool siteAdmin; Owner( {this.login, this.id, this.nodeId, this.avatarUrl, this.gravatarId, this.url, this.htmlUrl, this.followersUrl, this.followingUrl, this.gistsUrl, this.starredUrl, this.subscriptionsUrl, this.organizationsUrl, this.reposUrl, this.eventsUrl, this.receivedEventsUrl, this.type, this.siteAdmin}); Owner.fromJson(Map<String, dynamic> json) { login = json['login']; id = json['id']; nodeId = json['node_id']; avatarUrl = json['avatar_url']; gravatarId = json['gravatar_id']; url = json['url']; htmlUrl = json['html_url']; followersUrl = json['followers_url']; followingUrl = json['following_url']; gistsUrl = json['gists_url']; starredUrl = json['starred_url']; subscriptionsUrl = json['subscriptions_url']; organizationsUrl = json['organizations_url']; reposUrl = json['repos_url']; eventsUrl = json['events_url']; receivedEventsUrl = json['received_events_url']; type = json['type']; siteAdmin = json['site_admin']; } Map<String, dynamic> toJson() { final Map<String, dynamic> data = new Map<String, dynamic>(); data['login'] = this.login; data['id'] = this.id; data['node_id'] = this.nodeId; data['avatar_url'] = this.avatarUrl; data['gravatar_id'] = this.gravatarId; data['url'] = this.url; data['html_url'] = this.htmlUrl; data['followers_url'] = this.followersUrl; data['following_url'] = this.followingUrl; data['gists_url'] = this.gistsUrl; data['starred_url'] = this.starredUrl; data['subscriptions_url'] = this.subscriptionsUrl; data['organizations_url'] = this.organizationsUrl; data['repos_url'] = this.reposUrl; data['events_url'] = this.eventsUrl; data['received_events_url'] = this.receivedEventsUrl; data['type'] = this.type; data['site_admin'] = this.siteAdmin; return data; } }
0
mirrored_repositories/FlutterGithubClient/lib
mirrored_repositories/FlutterGithubClient/lib/model/ReposModel.dart
class ReposModel { int id; String nodeId; String name; String fullName; bool private; Owner owner; String htmlUrl; String description; bool fork; String url; String forksUrl; String keysUrl; String collaboratorsUrl; String teamsUrl; String hooksUrl; String issueEventsUrl; String eventsUrl; String assigneesUrl; String branchesUrl; String tagsUrl; String blobsUrl; String gitTagsUrl; String gitRefsUrl; String treesUrl; String statusesUrl; String languagesUrl; String stargazersUrl; String contributorsUrl; String subscribersUrl; String subscriptionUrl; String commitsUrl; String gitCommitsUrl; String commentsUrl; String issueCommentUrl; String contentsUrl; String compareUrl; String mergesUrl; String archiveUrl; String downloadsUrl; String issuesUrl; String pullsUrl; String milestonesUrl; String notificationsUrl; String labelsUrl; String releasesUrl; String deploymentsUrl; String createdAt; String updatedAt; String pushedAt; String gitUrl; String sshUrl; String cloneUrl; String svnUrl; String homepage; int size; int stargazersCount; int watchersCount; String language; bool hasIssues; bool hasProjects; bool hasDownloads; bool hasWiki; bool hasPages; int forksCount; String mirrorUrl; bool archived; int openIssuesCount; License license; int forks; int openIssues; int watchers; String defaultBranch; Permissions permissions; ReposModel( {this.id, this.nodeId, this.name, this.fullName, this.private, this.owner, this.htmlUrl, this.description, this.fork, this.url, this.forksUrl, this.keysUrl, this.collaboratorsUrl, this.teamsUrl, this.hooksUrl, this.issueEventsUrl, this.eventsUrl, this.assigneesUrl, this.branchesUrl, this.tagsUrl, this.blobsUrl, this.gitTagsUrl, this.gitRefsUrl, this.treesUrl, this.statusesUrl, this.languagesUrl, this.stargazersUrl, this.contributorsUrl, this.subscribersUrl, this.subscriptionUrl, this.commitsUrl, this.gitCommitsUrl, this.commentsUrl, this.issueCommentUrl, this.contentsUrl, this.compareUrl, this.mergesUrl, this.archiveUrl, this.downloadsUrl, this.issuesUrl, this.pullsUrl, this.milestonesUrl, this.notificationsUrl, this.labelsUrl, this.releasesUrl, this.deploymentsUrl, this.createdAt, this.updatedAt, this.pushedAt, this.gitUrl, this.sshUrl, this.cloneUrl, this.svnUrl, this.homepage, this.size, this.stargazersCount, this.watchersCount, this.language, this.hasIssues, this.hasProjects, this.hasDownloads, this.hasWiki, this.hasPages, this.forksCount, this.mirrorUrl, this.archived, this.openIssuesCount, this.license, this.forks, this.openIssues, this.watchers, this.defaultBranch, this.permissions}); ReposModel.fromJson(Map<String, dynamic> json) { id = json['id']; nodeId = json['node_id']; name = json['name']; fullName = json['full_name']; private = json['private']; owner = json['owner'] != null ? new Owner.fromJson(json['owner']) : null; htmlUrl = json['html_url']; description = json['description']; fork = json['fork']; url = json['url']; forksUrl = json['forks_url']; keysUrl = json['keys_url']; collaboratorsUrl = json['collaborators_url']; teamsUrl = json['teams_url']; hooksUrl = json['hooks_url']; issueEventsUrl = json['issue_events_url']; eventsUrl = json['events_url']; assigneesUrl = json['assignees_url']; branchesUrl = json['branches_url']; tagsUrl = json['tags_url']; blobsUrl = json['blobs_url']; gitTagsUrl = json['git_tags_url']; gitRefsUrl = json['git_refs_url']; treesUrl = json['trees_url']; statusesUrl = json['statuses_url']; languagesUrl = json['languages_url']; stargazersUrl = json['stargazers_url']; contributorsUrl = json['contributors_url']; subscribersUrl = json['subscribers_url']; subscriptionUrl = json['subscription_url']; commitsUrl = json['commits_url']; gitCommitsUrl = json['git_commits_url']; commentsUrl = json['comments_url']; issueCommentUrl = json['issue_comment_url']; contentsUrl = json['contents_url']; compareUrl = json['compare_url']; mergesUrl = json['merges_url']; archiveUrl = json['archive_url']; downloadsUrl = json['downloads_url']; issuesUrl = json['issues_url']; pullsUrl = json['pulls_url']; milestonesUrl = json['milestones_url']; notificationsUrl = json['notifications_url']; labelsUrl = json['labels_url']; releasesUrl = json['releases_url']; deploymentsUrl = json['deployments_url']; createdAt = json['created_at']; updatedAt = json['updated_at']; pushedAt = json['pushed_at']; gitUrl = json['git_url']; sshUrl = json['ssh_url']; cloneUrl = json['clone_url']; svnUrl = json['svn_url']; homepage = json['homepage']; size = json['size']; stargazersCount = json['stargazers_count']; watchersCount = json['watchers_count']; language = json['language']?? ""; hasIssues = json['has_issues']; hasProjects = json['has_projects']; hasDownloads = json['has_downloads']; hasWiki = json['has_wiki']; hasPages = json['has_pages']; forksCount = json['forks_count']; mirrorUrl = json['mirror_url']; archived = json['archived']; openIssuesCount = json['open_issues_count']; license = json['license'] != null ? new License.fromJson(json['license']) : null; forks = json['forks']; openIssues = json['open_issues']; watchers = json['watchers']; defaultBranch = json['default_branch']; permissions = json['permissions'] != null ? new Permissions.fromJson(json['permissions']) : null; } Map<String, dynamic> toJson() { final Map<String, dynamic> data = new Map<String, dynamic>(); data['id'] = this.id; data['node_id'] = this.nodeId; data['name'] = this.name; data['full_name'] = this.fullName; data['private'] = this.private; if (this.owner != null) { data['owner'] = this.owner.toJson(); } data['html_url'] = this.htmlUrl; data['description'] = this.description; data['fork'] = this.fork; data['url'] = this.url; data['forks_url'] = this.forksUrl; data['keys_url'] = this.keysUrl; data['collaborators_url'] = this.collaboratorsUrl; data['teams_url'] = this.teamsUrl; data['hooks_url'] = this.hooksUrl; data['issue_events_url'] = this.issueEventsUrl; data['events_url'] = this.eventsUrl; data['assignees_url'] = this.assigneesUrl; data['branches_url'] = this.branchesUrl; data['tags_url'] = this.tagsUrl; data['blobs_url'] = this.blobsUrl; data['git_tags_url'] = this.gitTagsUrl; data['git_refs_url'] = this.gitRefsUrl; data['trees_url'] = this.treesUrl; data['statuses_url'] = this.statusesUrl; data['languages_url'] = this.languagesUrl; data['stargazers_url'] = this.stargazersUrl; data['contributors_url'] = this.contributorsUrl; data['subscribers_url'] = this.subscribersUrl; data['subscription_url'] = this.subscriptionUrl; data['commits_url'] = this.commitsUrl; data['git_commits_url'] = this.gitCommitsUrl; data['comments_url'] = this.commentsUrl; data['issue_comment_url'] = this.issueCommentUrl; data['contents_url'] = this.contentsUrl; data['compare_url'] = this.compareUrl; data['merges_url'] = this.mergesUrl; data['archive_url'] = this.archiveUrl; data['downloads_url'] = this.downloadsUrl; data['issues_url'] = this.issuesUrl; data['pulls_url'] = this.pullsUrl; data['milestones_url'] = this.milestonesUrl; data['notifications_url'] = this.notificationsUrl; data['labels_url'] = this.labelsUrl; data['releases_url'] = this.releasesUrl; data['deployments_url'] = this.deploymentsUrl; data['created_at'] = this.createdAt; data['updated_at'] = this.updatedAt; data['pushed_at'] = this.pushedAt; data['git_url'] = this.gitUrl; data['ssh_url'] = this.sshUrl; data['clone_url'] = this.cloneUrl; data['svn_url'] = this.svnUrl; data['homepage'] = this.homepage; data['size'] = this.size; data['stargazers_count'] = this.stargazersCount; data['watchers_count'] = this.watchersCount; data['language'] = this.language; data['has_issues'] = this.hasIssues; data['has_projects'] = this.hasProjects; data['has_downloads'] = this.hasDownloads; data['has_wiki'] = this.hasWiki; data['has_pages'] = this.hasPages; data['forks_count'] = this.forksCount; data['mirror_url'] = this.mirrorUrl; data['archived'] = this.archived; data['open_issues_count'] = this.openIssuesCount; if (this.license != null) { data['license'] = this.license.toJson(); } data['forks'] = this.forks; data['open_issues'] = this.openIssues; data['watchers'] = this.watchers; data['default_branch'] = this.defaultBranch; if (this.permissions != null) { data['permissions'] = this.permissions.toJson(); } return data; } } class License { String key; String name; String spdxId; String url; String nodeId; License({this.key, this.name, this.spdxId, this.url, this.nodeId}); License.fromJson(Map<String, dynamic> json) { key = json['key']; name = json['name']; spdxId = json['spdx_id']; url = json['url']; nodeId = json['node_id']; } Map<String, dynamic> toJson() { final Map<String, dynamic> data = new Map<String, dynamic>(); data['key'] = this.key; data['name'] = this.name; data['spdx_id'] = this.spdxId; data['url'] = this.url; data['node_id'] = this.nodeId; return data; } } class Owner { String login; int id; String nodeId; String avatarUrl; String gravatarId; String url; String htmlUrl; String followersUrl; String followingUrl; String gistsUrl; String starredUrl; String subscriptionsUrl; String organizationsUrl; String reposUrl; String eventsUrl; String receivedEventsUrl; String type; bool siteAdmin; Owner( {this.login, this.id, this.nodeId, this.avatarUrl, this.gravatarId, this.url, this.htmlUrl, this.followersUrl, this.followingUrl, this.gistsUrl, this.starredUrl, this.subscriptionsUrl, this.organizationsUrl, this.reposUrl, this.eventsUrl, this.receivedEventsUrl, this.type, this.siteAdmin}); Owner.fromJson(Map<String, dynamic> json) { login = json['login']; id = json['id']; nodeId = json['node_id']; avatarUrl = json['avatar_url']; gravatarId = json['gravatar_id']; url = json['url']; htmlUrl = json['html_url']; followersUrl = json['followers_url']; followingUrl = json['following_url']; gistsUrl = json['gists_url']; starredUrl = json['starred_url']; subscriptionsUrl = json['subscriptions_url']; organizationsUrl = json['organizations_url']; reposUrl = json['repos_url']; eventsUrl = json['events_url']; receivedEventsUrl = json['received_events_url']; type = json['type']; siteAdmin = json['site_admin']; } Map<String, dynamic> toJson() { final Map<String, dynamic> data = new Map<String, dynamic>(); data['login'] = this.login; data['id'] = this.id; data['node_id'] = this.nodeId; data['avatar_url'] = this.avatarUrl; data['gravatar_id'] = this.gravatarId; data['url'] = this.url; data['html_url'] = this.htmlUrl; data['followers_url'] = this.followersUrl; data['following_url'] = this.followingUrl; data['gists_url'] = this.gistsUrl; data['starred_url'] = this.starredUrl; data['subscriptions_url'] = this.subscriptionsUrl; data['organizations_url'] = this.organizationsUrl; data['repos_url'] = this.reposUrl; data['events_url'] = this.eventsUrl; data['received_events_url'] = this.receivedEventsUrl; data['type'] = this.type; data['site_admin'] = this.siteAdmin; return data; } } class Permissions { bool admin; bool push; bool pull; Permissions({this.admin, this.push, this.pull}); Permissions.fromJson(Map<String, dynamic> json) { admin = json['admin']; push = json['push']; pull = json['pull']; } Map<String, dynamic> toJson() { final Map<String, dynamic> data = new Map<String, dynamic>(); data['admin'] = this.admin; data['push'] = this.push; data['pull'] = this.pull; return data; } }
0
mirrored_repositories/FlutterGithubClient/lib
mirrored_repositories/FlutterGithubClient/lib/model/ContributorsModel.dart
class ContributorsModel { String login; int id; String nodeId; String avatarUrl; String gravatarId; String url; String htmlUrl; String followersUrl; String followingUrl; String gistsUrl; String starredUrl; String subscriptionsUrl; String organizationsUrl; String reposUrl; String eventsUrl; String receivedEventsUrl; String type; bool siteAdmin; int contributions; ContributorsModel( {this.login, this.id, this.nodeId, this.avatarUrl, this.gravatarId, this.url, this.htmlUrl, this.followersUrl, this.followingUrl, this.gistsUrl, this.starredUrl, this.subscriptionsUrl, this.organizationsUrl, this.reposUrl, this.eventsUrl, this.receivedEventsUrl, this.type, this.siteAdmin, this.contributions}); ContributorsModel.fromJson(Map<String, dynamic> json) { login = json['login']; id = json['id']; nodeId = json['node_id']; avatarUrl = json['avatar_url']; gravatarId = json['gravatar_id']; url = json['url']; htmlUrl = json['html_url']; followersUrl = json['followers_url']; followingUrl = json['following_url']; gistsUrl = json['gists_url']; starredUrl = json['starred_url']; subscriptionsUrl = json['subscriptions_url']; organizationsUrl = json['organizations_url']; reposUrl = json['repos_url']; eventsUrl = json['events_url']; receivedEventsUrl = json['received_events_url']; type = json['type']; siteAdmin = json['site_admin']; contributions = json['contributions']; } Map<String, dynamic> toJson() { final Map<String, dynamic> data = new Map<String, dynamic>(); data['login'] = this.login; data['id'] = this.id; data['node_id'] = this.nodeId; data['avatar_url'] = this.avatarUrl; data['gravatar_id'] = this.gravatarId; data['url'] = this.url; data['html_url'] = this.htmlUrl; data['followers_url'] = this.followersUrl; data['following_url'] = this.followingUrl; data['gists_url'] = this.gistsUrl; data['starred_url'] = this.starredUrl; data['subscriptions_url'] = this.subscriptionsUrl; data['organizations_url'] = this.organizationsUrl; data['repos_url'] = this.reposUrl; data['events_url'] = this.eventsUrl; data['received_events_url'] = this.receivedEventsUrl; data['type'] = this.type; data['site_admin'] = this.siteAdmin; data['contributions'] = this.contributions; return data; } }
0
mirrored_repositories/FlutterGithubClient/lib
mirrored_repositories/FlutterGithubClient/lib/generated/i18n.dart
import 'dart:async'; import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; // ignore_for_file: non_constant_identifier_names // ignore_for_file: camel_case_types // ignore_for_file: prefer_single_quotes //This file is automatically generated. DO NOT EDIT, all your changes would be lost. class S implements WidgetsLocalizations { const S(); static const GeneratedLocalizationsDelegate delegate = GeneratedLocalizationsDelegate(); static S of(BuildContext context) => Localizations.of<S>(context, S); @override TextDirection get textDirection => TextDirection.ltr; } class $en extends S { const $en(); } class GeneratedLocalizationsDelegate extends LocalizationsDelegate<S> { const GeneratedLocalizationsDelegate(); List<Locale> get supportedLocales { return const <Locale>[ Locale("en", ""), ]; } LocaleListResolutionCallback listResolution({Locale fallback}) { return (List<Locale> locales, Iterable<Locale> supported) { if (locales == null || locales.isEmpty) { return fallback ?? supported.first; } else { return _resolve(locales.first, fallback, supported); } }; } LocaleResolutionCallback resolution({Locale fallback}) { return (Locale locale, Iterable<Locale> supported) { return _resolve(locale, fallback, supported); }; } Locale _resolve(Locale locale, Locale fallback, Iterable<Locale> supported) { if (locale == null || !isSupported(locale)) { return fallback ?? supported.first; } final Locale languageLocale = Locale(locale.languageCode, ""); if (supported.contains(locale)) { return locale; } else if (supported.contains(languageLocale)) { return languageLocale; } else { final Locale fallbackLocale = fallback ?? supported.first; return fallbackLocale; } } @override Future<S> load(Locale locale) { final String lang = getLang(locale); if (lang != null) { switch (lang) { case "en": return SynchronousFuture<S>(const $en()); default: // NO-OP. } } return SynchronousFuture<S>(const S()); } @override bool isSupported(Locale locale) => locale != null && supportedLocales.contains(locale); @override bool shouldReload(GeneratedLocalizationsDelegate old) => false; } String getLang(Locale l) => l == null ? null : l.countryCode != null && l.countryCode.isEmpty ? l.languageCode : l.toString();
0
mirrored_repositories/FlutterGithubClient/lib
mirrored_repositories/FlutterGithubClient/lib/utils/SharedPrefs.dart
import 'dart:async'; import 'dart:convert'; import 'package:LoginUI/model/UserProfile.dart'; import 'package:shared_preferences/shared_preferences.dart'; class SharedPrefs{ static final SharedPrefs _instance = new SharedPrefs._internal(); final String _token ="TOKEN"; final String _currenUserProfile ="CURRENT_USER_PROFILE"; factory SharedPrefs(){ return _instance; } SharedPrefs._internal(); void saveToken(String token) async { SharedPreferences pref = await SharedPreferences.getInstance(); pref.setString(_token, token); } Future<bool> clear() async { SharedPreferences pref = await SharedPreferences.getInstance(); return pref.clear(); } Future<String> getToken()async { SharedPreferences pref = await SharedPreferences.getInstance(); return pref.getString(_token); } void saveCurrentUserProfile(String userProfileJson) async { SharedPreferences pref = await SharedPreferences.getInstance(); pref.setString(_currenUserProfile, userProfileJson); } Future<UserProfile> getCurrentUserProfile() async { SharedPreferences pref = await SharedPreferences.getInstance(); var userProfile = pref.getString(_currenUserProfile); if(userProfile==null){ return null; }else{ return UserProfile.fromJson(json.decode(userProfile)); } } }
0
mirrored_repositories/FlutterGithubClient/lib
mirrored_repositories/FlutterGithubClient/lib/utils/Strings.dart
class Strings { static String MERGED_JSON_KEY = "merged"; static String STATUS_OPEN_JSON_VALUE = "open"; static String STATUS_PR_OPEN = "Open"; static String STATUS_PR_MERGED = "Merged"; static String STATUS_ISSUE_OPEN = "Open"; static String STATUS_ISSUE_CLOSED = "Closed"; }
0
mirrored_repositories/FlutterGithubClient/lib
mirrored_repositories/FlutterGithubClient/lib/utils/RepoListProvider.dart
import 'dart:async'; import 'dart:convert'; import 'package:LoginUI/Routes.dart'; import 'package:LoginUI/main.dart'; import 'package:LoginUI/model/ReposModel.dart'; import 'package:LoginUI/network/Github.dart'; import 'package:flutter/material.dart'; import 'package:http/src/response.dart'; class RepoListProvider { List<ReposModel> starredRepos; List<ReposModel> myRepos; List<ReposModel> userRepos; List<Widget> reposList(List<dynamic> repos, String title) { return [ new Container( child: new Text(title, style: new TextStyle(fontStyle: FontStyle.italic, fontSize: 18), textAlign: TextAlign.start), padding: EdgeInsets.only(left: 15, top: 15), alignment: Alignment.centerLeft), getReposList(repos, true) ]; } StreamSubscription getMyRepos( int page, int max, String accessToken, Function func) { var stream = Github.getAllMyRepos(accessToken, max, page).asStream(); return stream.listen((response) { var repos = json.decode(response.body) as List; var reposList = List<ReposModel>(); repos.forEach((json) { reposList.add(ReposModel.fromJson(json)); }); func(reposList); }); } StreamSubscription<Response> getUserRepos( int page, int max, String accessToken, String login, Function func) { var stream = Github.getUserRepos(page, max, accessToken, login).asStream(); return stream.listen((response) { var repos = json.decode(response.body) as List; var reposList = List<ReposModel>(); repos.forEach((json) { reposList.add(ReposModel.fromJson(json)); }); func(reposList); }); } StreamSubscription<Response> getStarredRepos( int max, String username, Function func) { var stream = Github.getUserStarredRepos(username, max, 1).asStream(); return stream.listen((response) { var repos = json.decode(response.body) as List; var reposList = List<ReposModel>(); repos.forEach((json) { reposList.add(ReposModel.fromJson(json)); }); starredRepos = reposList; func(reposList); }); } getReposList(@required List<ReposModel> repos, @required bool notScrollable, [ScrollController scrollController]) { return new ListView.builder( controller: scrollController, padding: new EdgeInsets.all(8.0), itemCount: repos == null ? 0 : repos.length, shrinkWrap: true, physics: notScrollable ? ClampingScrollPhysics() : AlwaysScrollableScrollPhysics(), itemBuilder: (BuildContext context, int index) { return new GestureDetector( onTap: () { Application.router.navigateTo( context, Routes.repoDetails .replaceFirst( ":loginname", repos.elementAt(index).owner.login) .replaceFirst(":repo", repos.elementAt(index).name)); }, child: new Row( mainAxisAlignment: MainAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.center, children: <Widget>[ new Container( child: new Image.network( '${repos.elementAt(index).owner.avatarUrl}', width: 40.0, height: 40.0), padding: EdgeInsets.all(10), ), getDetailView(repos.elementAt(index)) ], )); }); } getDetailView(ReposModel repo) { return new Column( crossAxisAlignment: CrossAxisAlignment.start, children: <Widget>[ new Text( '${repo.name}', style: TextStyle( fontStyle: FontStyle.normal, fontSize: 16.0, color: Colors.black), textAlign: TextAlign.start, overflow: TextOverflow.ellipsis, ), new Text('Repo Type: ${(repo.private) ? "Private" : "Public"}', style: TextStyle( fontStyle: FontStyle.italic, fontSize: 14.0, color: Colors.black87), textAlign: TextAlign.start, overflow: TextOverflow.ellipsis) ]); } }
0
mirrored_repositories/FlutterGithubClient/lib
mirrored_repositories/FlutterGithubClient/lib/ui/Utils.dart
import 'dart:convert' show utf8, base64; class Utils { static String encodeCredentials(username, password) { final combinedStr = "$username:$password"; return base64.encode(utf8.encode(combinedStr)); } }
0
mirrored_repositories/FlutterGithubClient/lib
mirrored_repositories/FlutterGithubClient/lib/ui/AppConstants.dart
import 'package:LoginUI/network/Github.dart'; class AppConstants { static String GITHUB_CLIENT_ID = "5eebe59bc6ed95a4f4b1"; static String GITHUB_CALLBACK_URL = "http://localhost:8080/"; static String GITHUB_CLIENT_SECRET = "79b8c8be8b91bdcba4326212648201fe57d4df1d"; }
0
mirrored_repositories/FlutterGithubClient/lib/ui
mirrored_repositories/FlutterGithubClient/lib/ui/repolist/RepoListPageState.dart
import 'dart:async'; import 'package:LoginUI/model/ReposModel.dart'; import 'package:LoginUI/ui/base/BaseStatefulState.dart'; import 'package:LoginUI/ui/repolist/RepoListPage.dart'; import 'package:LoginUI/utils/RepoListProvider.dart'; import 'package:LoginUI/utils/SharedPrefs.dart'; import 'package:flutter/material.dart'; import 'package:http/src/response.dart'; class RepoListPageState extends BaseStatefulState<RepoListPage> with TickerProviderStateMixin { Widget appBarTitle = new Text("My Repos"); String accessToken; StreamSubscription<Response> subscriptionMyRepos; List<ReposModel> repos; int page = 1; ScrollController scrollController; RepoListProvider repoListProvider; @override void initState() { super.initState(); repoListProvider = new RepoListProvider(); scrollController = new ScrollController(); scrollController.addListener(_scrollListener); SharedPrefs().getToken().then((token) { accessToken = token; getMyRepos(); }); } @override void dispose() { if (subscriptionMyRepos != null) { subscriptionMyRepos.cancel(); } scrollController.removeListener(_scrollListener); super.dispose(); } void _scrollListener() { print(scrollController.position.extentAfter); if (scrollController.position.extentAfter == 0 && repos != null) { if (subscriptionMyRepos == null) { getMyRepos(); } } } @override Widget prepareWidget(BuildContext context) { var uiElements = <Widget>[]; uiElements.add(toolbarAndroid()); if (repos != null) { uiElements.add(new Expanded( child: repoListProvider.getReposList(repos, false, scrollController))); } return new Scaffold( key: scaffoldKey, body: new Column( children: uiElements, )); } toolbarAndroid() { return new AppBar( backgroundColor: Colors.black, centerTitle: false, title: appBarTitle, ); } getMyRepos() { showProgress(); if (subscriptionMyRepos != null) { subscriptionMyRepos.cancel(); } subscriptionMyRepos = repoListProvider.getMyRepos(page, 10, accessToken, (repos) { this.setState(() { if (this.repos == null) { this.repos = repos; } else { this.repos.addAll(repos); } }); page = page + 1; hideProgress(); subscriptionMyRepos = null; }); } }
0
mirrored_repositories/FlutterGithubClient/lib/ui
mirrored_repositories/FlutterGithubClient/lib/ui/repolist/RepoListPage.dart
import 'package:LoginUI/ui/repolist/RepoListPageState.dart'; import 'package:flutter/material.dart'; class RepoListPage extends StatefulWidget { RepoListPage({Key key}) : super(key: key); @override RepoListPageState createState() => new RepoListPageState(); }
0
mirrored_repositories/FlutterGithubClient/lib/ui
mirrored_repositories/FlutterGithubClient/lib/ui/repodetails/RepoDetailsPageState.dart
import 'dart:async'; import 'dart:convert'; import 'package:LoginUI/model/ContributorsModel.dart'; import 'package:LoginUI/model/ReposModel.dart'; import 'package:LoginUI/network/Github.dart'; import 'package:LoginUI/ui/base/BaseStatefulState.dart'; import 'package:LoginUI/ui/repodetails/RepoDetailsPage.dart'; import 'package:LoginUI/userprofile/UserProfilePage.dart'; import 'package:LoginUI/utils/SharedPrefs.dart'; import 'package:flutter/material.dart'; import 'package:http/src/response.dart'; import 'package:url_launcher/url_launcher.dart'; class RepoDetailsPageState extends BaseStatefulState<RepoDetailsPage> with TickerProviderStateMixin { String accessToken; String repoId; String loginName; ReposModel repoModel; StreamSubscription<Response> subscriptionContributors; List<ContributorsModel> contributorsModel = new List<ContributorsModel>(); StreamSubscription<Response> subscriptionRepoDetails; RepoDetailsPageState(String loginName, String repoId) { this.repoId = repoId; this.loginName = loginName; } @override void initState() { super.initState(); SharedPrefs().getToken().then((token) { accessToken = token; getMyRepoDetails(); }); } @override void dispose() { if (subscriptionContributors != null) { subscriptionContributors.cancel(); } if (subscriptionRepoDetails != null) { subscriptionRepoDetails.cancel(); } super.dispose(); } @override Widget prepareWidget(BuildContext context) { var uiElements = <Widget>[]; uiElements.add(toolbarAndroid()); if (repoModel != null) { print(repoModel.toJson().toString()); uiElements.add(getRepoDetails()); } if (contributorsModel.isNotEmpty) { uiElements.add(getContributorsList()); } return new Scaffold( key: scaffoldKey, backgroundColor: Colors.black54, body: new CustomScrollView( slivers: [ new SliverList( delegate: new SliverChildListDelegate(uiElements), ), ], )); } toolbarAndroid() { return new AppBar( backgroundColor: Colors.black, centerTitle: false, title: new Text(repoId), ); } void getMyRepoDetails() { if (subscriptionRepoDetails != null) { subscriptionRepoDetails.cancel(); } showProgress(); subscriptionRepoDetails = Github.getApiForUrl(Github.getUserRepoGithub .replaceFirst(Github.USER, loginName) .replaceFirst(Github.REPO, repoId),accessToken) .asStream() .listen((repo) { print(json.decode(repo.body)); repoModel = ReposModel.fromJson(json.decode(repo.body)); setState(() {}); hideProgress(); getContributors(); }); } void getContributors() { if (subscriptionContributors != null) { subscriptionContributors.cancel(); } if (repoModel != null && repoModel.contributorsUrl != null) { showProgress(); subscriptionContributors = Github.getApiForUrl(repoModel.contributorsUrl,accessToken) .asStream() .listen((result) { var list = json.decode(result.body) as List; list.forEach((item) { this.contributorsModel.add(ContributorsModel.fromJson(item)); }); setState(() {}); hideProgress(); }); } } Widget getRepoDetails() { var listWidgets = List<Widget>(); listWidgets.add(Container( margin: EdgeInsets.all(8), child: Image.network(repoModel.owner.avatarUrl, width: 80, height: 80))); listWidgets.add(Container( child: Text( repoModel.fullName, style: TextStyle(fontWeight: FontWeight.bold, fontSize: 18), ), padding: EdgeInsets.all(4.0))); if(repoModel.language.isNotEmpty){ listWidgets.add(Container( child: Text("Language: " + repoModel.language), padding: EdgeInsets.all(4.0), )); } listWidgets.add(Container( child: Text("Issues: " + repoModel.openIssuesCount.toString()), padding: EdgeInsets.all(4.0), )); listWidgets.add(Container( child: Text("Stars: " + repoModel.stargazersCount.toString()), padding: EdgeInsets.all(4.0), )); listWidgets.add(Container( child: Text("Default Branch: " + repoModel.defaultBranch), padding: EdgeInsets.all(4.0), )); listWidgets.add(Container( child: InkWell( onTap: () => launch(repoModel.htmlUrl), child: Text("Github URL: " + repoModel.htmlUrl), ), padding: EdgeInsets.all(4.0), )); return Center(child: Card(child: Column(children: listWidgets))); } getDetailView(ContributorsModel repo) { return new Column( crossAxisAlignment: CrossAxisAlignment.start, children: <Widget>[ new Text( '${repo.login}', style: TextStyle( fontStyle: FontStyle.normal, fontSize: 16.0, color: Colors.black), textAlign: TextAlign.start, overflow: TextOverflow.ellipsis, ), new Text('Site Admin: ${(repo.siteAdmin) ? "Yes" : "No"}', style: TextStyle( fontStyle: FontStyle.italic, fontSize: 14.0, color: Colors.black87), textAlign: TextAlign.start, overflow: TextOverflow.ellipsis) ]); } Widget getContributorsList() { var list = List<Widget>(); if (contributorsModel != null) { list.add(Container( alignment: Alignment.centerLeft, margin: EdgeInsets.all(5), child: Text( "Contributors:", style: TextStyle(fontWeight: FontWeight.bold, fontSize: 18), ), padding: EdgeInsets.all(4.0), )); contributorsModel.forEach((item) { list.add(GestureDetector( onTap: () { Navigator.push( context, MaterialPageRoute( builder: (context) => UserProfilePage(item.login)), ); }, child: new Row( mainAxisAlignment: MainAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.center, children: <Widget>[ new Container( child: new Image.network('${item.avatarUrl}', width: 40.0, height: 40.0), padding: EdgeInsets.all(10), ), getDetailView(item) ], ))); }); } return Center(child: Card(child: Column(children: list),margin: EdgeInsets.all(18),)); } }
0
mirrored_repositories/FlutterGithubClient/lib/ui
mirrored_repositories/FlutterGithubClient/lib/ui/repodetails/RepoDetailsPage.dart
import 'package:LoginUI/ui/repodetails/RepoDetailsPageState.dart'; import 'package:flutter/material.dart'; class RepoDetailsPage extends StatefulWidget { String repoId; String loginName; RepoDetailsPage(String loginName,String repoId, {Key key}) : super(key: key){ this.repoId = repoId; this.loginName = loginName; } @override RepoDetailsPageState createState() => new RepoDetailsPageState(loginName,repoId); }
0
mirrored_repositories/FlutterGithubClient/lib/ui
mirrored_repositories/FlutterGithubClient/lib/ui/notifications/NotificationPageState.dart
import 'dart:async'; import 'dart:convert'; import 'package:LoginUI/model/Issue.dart' as IssueModel; import 'package:LoginUI/model/NotificationModel.dart'; import 'package:LoginUI/model/PullRequest.dart'; import 'package:LoginUI/utils/SharedPrefs.dart'; import 'package:flutter/material.dart'; import 'package:flutter_svg/flutter_svg.dart'; import 'package:http/http.dart' as http; import 'package:intl/intl.dart'; import '../../network/Github.dart'; import '../../utils/Strings.dart'; import '../base/BaseStatefulState.dart'; import 'NotificationsPage.dart'; class NotificationPageState extends BaseStatefulState<NotificationsPage> { Widget appBarTitle = Text("Notifications"); String accessToken; List<NotificationModel> notifications; StreamSubscription<http.Response> subscriptionNotifications; StreamSubscription<List<http.Response>> subscriptionEachNotificaion; @override void initState() { super.initState(); SharedPrefs().getToken().then((token) { accessToken = token; getUserNotifications(); }); } @override void dispose() { clearDisposables(); super.dispose(); } @override Widget prepareWidget(BuildContext context) { var uiElements = <Widget>[toolbarAndroid()]; if (notifications != null) { uiElements.add(Expanded(child: getNotificationListView())); } return Scaffold( key: scaffoldKey, body: Column( children: uiElements, ), ); } toolbarAndroid() { return new AppBar( backgroundColor: Colors.black, centerTitle: false, title: appBarTitle, ); } void getUserNotifications() { showProgress(); var futures = <Future<http.Response>>[]; var stream = Github.getUserNotifications(accessToken).asStream(); clearDisposables(); subscriptionNotifications = stream.listen((response) { var notifications = json.decode(response.body) as List; var notificationsList = List<NotificationModel>(); notifications.forEach((notification) { var notificationModel = NotificationModel.fromJson(notification); if (notificationModel.subject.url != null) { notificationsList.add(notificationModel); futures.add(getNotificationStatus(notificationModel)); } }); setState(() { this.notifications = notificationsList; hideProgress(); }); subscriptionEachNotificaion = Future.wait(futures).asStream().listen((value) { var i = 0; value.forEach((res) { var status = ""; print(res.body); if (res.body.contains(Strings.MERGED_JSON_KEY)) { var pr = PullRequest.fromJson(json.decode(res.body)); if (pr.state == Strings.STATUS_OPEN_JSON_VALUE) { status = Strings.STATUS_PR_OPEN; } else { status = Strings.STATUS_PR_MERGED; } } else { var issue = IssueModel.Issue.fromJson(json.decode(res.body)); if (issue.state == Strings.STATUS_OPEN_JSON_VALUE) { status = Strings.STATUS_ISSUE_OPEN; } else { status = Strings.STATUS_ISSUE_CLOSED; } } notificationsList[i++].status = status; setState(() {}); }); }); }); } Widget getNotificationListView() { return ListView.builder( itemCount: (notifications == null) ? 0 : notifications.length, padding: EdgeInsets.all(12.0), itemBuilder: (context, index) { return Container( margin: EdgeInsets.only(bottom: 12.0), child: Row( mainAxisAlignment: MainAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.center, children: <Widget>[ buildSvgWidget(notifications[index].subject.type), Padding( padding: const EdgeInsets.only(left: 12.0), child: Column( crossAxisAlignment: CrossAxisAlignment.start, mainAxisAlignment: MainAxisAlignment.start, children: <Widget>[ Container( child: Text(notifications[index].subject.title.trim()), margin: EdgeInsets.only(bottom: 4.0), ), Container( child: Text( "Updated at ${formatDate(notifications[index].updatedAt)}", textAlign: TextAlign.start, overflow: TextOverflow.fade, ), margin: EdgeInsets.only(bottom: 4.0), ), Text( notifications[index].status, ) ], ), ) ], ), ); }, ); } String formatDate(String date) { var oldFormat = DateFormat("yyyy-MM-ddTHH:mm:ssZ"); var oldDate = oldFormat.parse(date); var newFormat = DateFormat("MMM dd, yyyy"); return newFormat.format(oldDate); } Widget buildSvgWidget(String type) { String asset = ""; switch (type) { case "PullRequest": asset = "icons/git-pull-request.svg"; break; case "Issue": asset = "icons/issue-opened.svg"; break; default: asset = "icons/bell.svg"; break; } return SvgPicture.asset( asset, width: 28.0, height: 28.0, ); } Future<http.Response> getNotificationStatus(NotificationModel notification) { return Github.getNotificationDetail(notification.subject.url, accessToken); } void clearDisposables() { if (subscriptionNotifications != null) { subscriptionNotifications.cancel(); } if(subscriptionEachNotificaion!=null){ subscriptionEachNotificaion.cancel(); } } }
0
mirrored_repositories/FlutterGithubClient/lib/ui
mirrored_repositories/FlutterGithubClient/lib/ui/notifications/NotificationsPage.dart
import 'package:flutter/material.dart'; import 'NotificationPageState.dart'; class NotificationsPage extends StatefulWidget { @override NotificationPageState createState() => NotificationPageState(); }
0
mirrored_repositories/FlutterGithubClient/lib/ui
mirrored_repositories/FlutterGithubClient/lib/ui/dashboard/DashboardPage.dart
import 'package:LoginUI/ui/dashboard/DashboardPageState.dart'; import 'package:flutter/material.dart'; class DashboardPage extends StatefulWidget { DashboardPage({Key key}) : super(key: key); @override DashboardPageState createState() => new DashboardPageState(); }
0
mirrored_repositories/FlutterGithubClient/lib/ui
mirrored_repositories/FlutterGithubClient/lib/ui/dashboard/DashboardPageState.dart
import 'dart:async'; import 'package:LoginUI/Routes.dart'; import 'package:LoginUI/main.dart'; import 'package:LoginUI/model/ReposModel.dart'; import 'package:LoginUI/model/UserProfile.dart'; import 'package:LoginUI/network/Github.dart'; import 'package:LoginUI/ui/base/BaseStatefulState.dart'; import 'package:LoginUI/ui/dashboard/DashboardPage.dart'; import 'package:LoginUI/userprofile/UserProfileHeader.dart'; import 'package:LoginUI/userprofile/UserProfileHeaderState.dart'; import 'package:LoginUI/utils/RepoListProvider.dart'; import 'package:LoginUI/utils/SharedPrefs.dart'; import 'package:flutter/material.dart'; import 'package:http/src/response.dart'; class DashboardPageState extends BaseStatefulState<DashboardPage> { UserProfile currentUserProfile; String accessToken; StreamSubscription<UserProfile> subscriptionMyProfile; StreamSubscription<Response> subScriptionApiUserProfile; StreamSubscription<Response> subStarredRepos; StreamSubscription subMyRepos; List<ReposModel> starredRepos; List<ReposModel> myRepos; var toolbar = GlobalKey(debugLabel: "toolbar"); RepoListProvider repoListProvider; @override void initState() { super.initState(); repoListProvider = new RepoListProvider(); SharedPrefs().getToken().then((token) { accessToken = token; getMyUserProfile(); }); } @override void dispose() { super.dispose(); subscriptionMyProfile?.cancel(); subScriptionApiUserProfile?.cancel(); } toolbarAndroid() { var userDashboardTitle; if (currentUserProfile != null) { userDashboardTitle = "${currentUserProfile.getName()}'s Dashboard"; } else { userDashboardTitle = "Dashboard"; } return new AppBar( key: toolbar, backgroundColor: Colors.black, centerTitle: false, title: new Text(userDashboardTitle), ); } getDrawer() { return new Drawer( // Add a ListView to the drawer. This ensures the user can scroll // through the options in the Drawer if there isn't enough vertical // space to fit everything. child: ListView( // Important: Remove any padding from the ListView. padding: EdgeInsets.zero, children: <Widget>[ currentUserProfile == null?null: new UserProfileHeader(currentUserProfile), ListTile( title: Text('User Search'), onTap: () { Navigator.pop(context); navigateTo(Routes.dashboardUserSearch); }, ), Divider(color: Colors.grey,), ListTile( title: Text("Notifications"), onTap: () { Navigator.pop(context); navigateTo(Routes.notificationsList); }, ), new Divider(color: Colors.grey,), ListTile( title: Text('My Repo List'), onTap: () { Navigator.pop(context); navigateTo(Routes.dashboardRepoList); }, ), new Divider(color: Colors.grey,), ListTile( title: Text('Logout!'), onTap: () { Navigator.pop(context); logoutUser(); }, ), new Divider(color: Colors.grey,) ], ), ); } void navigateTo(String name) { Application.router.navigateTo(context, name); } void logoutUser() { SharedPrefs().clear().then((onClear) { Application.router.navigateTo(context, Routes.login, clearStack: true); }); } @override Widget prepareWidget(BuildContext context) { var uiElements = <Widget>[toolbarAndroid()]; uiElements.add(getCardMyView(starredRepos, "Starred Repos")); uiElements.add(getCardMyView(myRepos, "Repositories")); return new Scaffold( key: scaffoldKey, backgroundColor: Colors.black87, drawer: getDrawer(), body: new CustomScrollView( slivers: [ new SliverList( delegate: new SliverChildListDelegate( uiElements, ), ), ], )); } void getMyUserProfile() { var stream = SharedPrefs().getCurrentUserProfile().asStream(); if (subscriptionMyProfile != null) { subscriptionMyProfile.cancel(); } subscriptionMyProfile = stream.listen((profile) { if (profile != null) { this.setState(() { currentUserProfile = profile; getMyStarredRepos(); }); } else { getApiUserProfile(); } }); } void getApiUserProfile() { hideProgress(); if (subScriptionApiUserProfile != null) { subScriptionApiUserProfile.cancel(); } showProgress(); var getUserProfile = Github.getMyUserProfile(accessToken).asStream(); subScriptionApiUserProfile = getUserProfile.listen((response) { SharedPrefs().saveCurrentUserProfile(response.body); this.setState(() { getMyUserProfile(); }); hideProgress(); }); } void getMyStarredRepos() { showProgress(); if (subStarredRepos != null) { subStarredRepos.cancel(); } subStarredRepos = repoListProvider.getStarredRepos(5, currentUserProfile.login, (repos) { this.setState(() { this.starredRepos = repos; }); hideProgress(); getMyRepos(); }); } void getMyRepos() { showProgress(); if (subMyRepos != null) { subMyRepos.cancel(); } subMyRepos = repoListProvider.getMyRepos(1, 5, accessToken, (repos) { this.setState(() { this.myRepos = repos; }); hideProgress(); }); } Widget getCardMyView(var repos, String title) { return new Center( child: Card( margin: EdgeInsets.all(10), elevation: 4, child: new Column(children: repoListProvider.reposList(repos, title)), ), ); } }
0
mirrored_repositories/FlutterGithubClient/lib/ui
mirrored_repositories/FlutterGithubClient/lib/ui/login/LoginPage.dart
import 'package:LoginUI/ui/login/LoginPageState.dart'; import 'package:flutter/material.dart'; class LoginPage extends StatefulWidget { LoginPage({Key key}) : super(key: key); @override LoginPageState createState() => new LoginPageState(); }
0
mirrored_repositories/FlutterGithubClient/lib/ui
mirrored_repositories/FlutterGithubClient/lib/ui/login/LoginPageState.dart
import 'dart:async'; import 'dart:convert'; import 'package:LoginUI/Routes.dart'; import 'package:LoginUI/main.dart'; import 'package:LoginUI/ui/login/LoginPage.dart'; import 'package:LoginUI/network/Github.dart'; import 'package:LoginUI/ui/base/BaseStatefulState.dart'; import 'package:LoginUI/ui/dashboard/DashboardPage.dart'; import 'package:LoginUI/utils/SharedPrefs.dart'; import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; import 'package:http/src/response.dart'; import 'package:vector_math/vector_math_64.dart' as Vector; class LoginPageState extends BaseStatefulState<LoginPage> with TickerProviderStateMixin { final GlobalKey<EditableTextState> _usernameState = new GlobalKey<EditableTextState>(); final GlobalKey<EditableTextState> _passwordState = new GlobalKey<EditableTextState>(); FocusNode _focusNode; double centerValue; double LOGO_SIZE = 200.0; bool splashVisible = true; bool animateLogo = false; bool formVisible = false; String usernameText = ""; String passwordText = ""; final usernameTextController = TextEditingController(); final passwordTextController = TextEditingController(); @override void initState() { super.initState(); SharedPrefs().getToken().then((value) { if (value != null && value.isNotEmpty) { debugPrint("fetched SharedPrefrences $value"); fetchedAccessToken(); } else { _focusNode = new FocusNode(); startTime(); } }); } startTime() async { var _duration = new Duration(seconds: 2); return new Timer(_duration, switchState); } void switchState() { setState(() { // This call to setState tells the Flutter framework that something has // changed in this State, which causes it to rerun the build method below // so that the display can reflect the updated values. If we changed // _counter without calling setState(), then the build method would not be // called again, and so nothing would appear to happen. splashVisible = false; animateLogo = true; formVisible = true; }); } @override Widget prepareWidget(BuildContext context) { // This method is rerun every time setState is called, for instance as done // by the _incrementCounter method above. // // The Flutter framework has been optimized to make rerunning build methods // fast, so that you can just rebuild anything that needs updating rather // than having to individually change instances of widgets. centerValue = MediaQuery.of(context).size.height / 2; centerValue = centerValue - (LOGO_SIZE / 2); return new Scaffold( key: scaffoldKey, body: new Stack( children: <Widget>[ blurMask(context), splashScreen(context), logoCenter(context) ], )); } @override void dispose() { usernameTextController.dispose(); passwordTextController.dispose(); super.dispose(); } getEndOffset() { return Offset(0.0, 1.0); } getBeginOffset() { return Offset(0.5, 0.5); } splashScreen(BuildContext context) { return new AnimatedOpacity( opacity: splashVisible ? 1.0 : 0.0, duration: new Duration(seconds: 2), child: new Container( color: Colors.black, height: double.infinity, width: double.infinity)); } blurMask(BuildContext context) { return new Container( color: Colors.black87, height: double.infinity, width: double.infinity); } logoCenter(BuildContext context) { return new AnimatedContainer( child: aesLogoLoginForm(context), curve: Curves.linear, duration: Duration(seconds: 1), transform: new Matrix4.translation( new Vector.Vector3(0.0, animateLogo ? 50.0 : centerValue, 0.0))); } aesLogoLoginForm(BuildContext context) { return new Column( children: <Widget>[aesLogo(), loginForm(context)], ); } aesLogo() { return new FlutterLogo(size: LOGO_SIZE); } loginForm(BuildContext context) { return new AnimatedOpacity( opacity: formVisible ? 1.0 : 0.0, duration: new Duration(seconds: 3), child: new Container( margin: const EdgeInsets.only(top: 20.0), child: new Column(children: <Widget>[ username(context), passwordWidget(context), loginButton(context), loginOauthButton(context) ]), )); } loginButton(BuildContext context) { return new Container( margin: EdgeInsets.all(16.0), foregroundDecoration: ShapeDecoration.fromBoxDecoration(BoxDecoration( color: Colors.white.withOpacity(0.1), borderRadius: BorderRadius.all(Radius.circular(4.0)))), alignment: Alignment.center, child: new SizedBox( width: double.infinity, child: new MaterialButton( onPressed: loginNowBasic, textColor: Colors.white, child: new Text( "Login", style: TextStyle(fontSize: 20.0), )))); } loginOauthButton(BuildContext context) { return new Container( margin: EdgeInsets.all(16.0), foregroundDecoration: ShapeDecoration.fromBoxDecoration(BoxDecoration( color: Colors.white.withOpacity(0.1), borderRadius: BorderRadius.all(Radius.circular(4.0)))), alignment: Alignment.center, child: new MaterialButton( onPressed: loginNow, textColor: Colors.white, child: new Text( "Login via Browser?", style: TextStyle(fontSize: 20.0), ))); } forgotPassword(BuildContext context) { return new Container( margin: EdgeInsets.all(14.0), alignment: Alignment.centerLeft, child: new Text("Forgot User ID or Password?", style: TextStyle(color: Colors.white, fontSize: 16.0), maxLines: 1, textAlign: TextAlign.start)); } username(BuildContext context) { return new Container( margin: EdgeInsets.all(8.0), child: new TextFormField( key: _usernameState, maxLines: 1, controller: usernameTextController, textInputAction: TextInputAction.next, keyboardType: TextInputType.emailAddress, keyboardAppearance: Brightness.light, style: TextStyle(color: Colors.white, fontSize: 20.0), onFieldSubmitted: (String inputText) { FocusScope.of(context).requestFocus(_focusNode); }, decoration: InputDecoration( hintText: 'Username', contentPadding: EdgeInsets.all(10.0), hintStyle: TextStyle(color: Colors.white.withOpacity(0.5))), )); } passwordWidget(BuildContext context) { return new Container( child: new TextFormField( key: _passwordState, focusNode: _focusNode, maxLines: 1, controller: passwordTextController, autocorrect: false, obscureText: true, keyboardType: TextInputType.text, textInputAction: TextInputAction.done, keyboardAppearance: Brightness.light, style: TextStyle(color: Colors.white, fontSize: 20.0), decoration: InputDecoration( hintText: 'Password', contentPadding: EdgeInsets.all(10.0), hintStyle: TextStyle(color: Colors.white.withOpacity(0.5))), ), margin: EdgeInsets.all(8.0)); } loginNowBasic() async { //hides keyboard. FocusScope.of(context).requestFocus(FocusNode()); if (!isValidUsername(usernameTextController.text)) { showErrorInvalidUsername(); return; } if (!isValidPassword(passwordTextController.text)) { showErrorInvalidPassword(); return; } showProgress(); Github.authenticateUsernamePassword( usernameTextController.text.trim(), passwordTextController.text.trim()) .then((response) { print(response.body); var token = json.decode(response.body)['token']; print(token); SharedPrefs().saveToken("$token"); hideProgress(); fetchCurrentUserProfile(token); }); } loginNow() async { //hides keyboard. FocusScope.of(context).requestFocus(FocusNode()); showProgress(); Github.authenticate((token) { SharedPrefs().saveToken(token); hideProgress(); fetchCurrentUserProfile(token); fetchedAccessToken(); }); } void fetchedAccessToken() { Application.router.navigateTo(context, Routes.loginDashboard, clearStack: true); } void fetchCurrentUserProfile(String token) { var stream = Github.getMyUserProfile(token).asStream(); stream.listen((response) { SharedPrefs().saveCurrentUserProfile(response.body); hideProgress(); fetchedAccessToken(); }); } void showProgressBar() { scaffoldKey.currentState.showSnackBar(new SnackBar( content: new Row( children: <Widget>[ new Container( child: new CircularProgressIndicator(), margin: EdgeInsets.all(4.0)), new Container( child: new Text("Signing in..."), margin: EdgeInsets.all(4.0)), ], ), )); } bool isValidUsername(String text) { return text.trim().isNotEmpty; } bool isValidPassword(String text) { return text.isNotEmpty; } void showErrorInvalidUsername() { scaffoldKey.currentState.removeCurrentSnackBar(); scaffoldKey.currentState.showSnackBar(new SnackBar( content: new Row( children: <Widget>[ new Container( child: new Text("Username cannot be blank/empty"), margin: EdgeInsets.all(4.0)), ], ), )); } void showErrorInvalidPassword() { scaffoldKey.currentState.removeCurrentSnackBar(); scaffoldKey.currentState.showSnackBar(new SnackBar( content: new Row( children: <Widget>[ new Container( child: new Text("Password cannot be blank/empty"), margin: EdgeInsets.all(4.0)), ], ), )); } }
0
mirrored_repositories/FlutterGithubClient/lib/ui
mirrored_repositories/FlutterGithubClient/lib/ui/usergists/UserGistsPageState.dart
import 'dart:async'; import 'dart:convert'; import 'package:LoginUI/model/GistModel.dart'; import 'package:LoginUI/network/Github.dart'; import 'package:LoginUI/ui/base/BaseStatefulState.dart'; import 'package:LoginUI/ui/usergists/UserGistsPage.dart'; import 'package:LoginUI/utils/SharedPrefs.dart'; import 'package:flutter/material.dart'; import 'package:http/src/response.dart'; class UserGistsPageState extends BaseStatefulState<UserGistsPage> with TickerProviderStateMixin { double USER_IMAGE_SIZE = 200.0; List<GistModel> gists; StreamSubscription<Response> subscription; ScrollController scrollController; var page = 1; String loginName; String accessToken; UserGistsPageState(@required this.loginName); @override void initState() { super.initState(); scrollController = new ScrollController(); scrollController.addListener(_scrollListener); SharedPrefs().getToken().then((token) { accessToken = token; getGists(); }); } @override void dispose() { if (subscription != null) { subscription.cancel(); } scrollController.removeListener(_scrollListener); super.dispose(); } @override Widget prepareWidget(BuildContext context) { return new Scaffold( key: scaffoldKey, body: new Column( children: <Widget>[toolbarAndroid(), listVIew()], )); } toolbarAndroid() { return new AppBar( backgroundColor: Colors.black, centerTitle: false, title: Text("$loginName's Gist's"), ); } listVIew() { return new Expanded( child: new ListView.builder( controller: scrollController, shrinkWrap: true, padding: new EdgeInsets.all(8.0), itemCount: gists == null ? 0 : gists.length, itemBuilder: (BuildContext context, int index) { return new GestureDetector( child: Column( children: <Widget>[ Row( mainAxisAlignment: MainAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start, children: <Widget>[ Container( padding: EdgeInsets.all(8), child: new Image.network( gists[index].owner.avatarUrl, width: 50.0, height: 50.0), ), Expanded( child: Column( crossAxisAlignment: CrossAxisAlignment.start, mainAxisAlignment: MainAxisAlignment.start, children: <Widget>[ Container( child: Text( '${gists[index].getDescription()}', overflow: TextOverflow.ellipsis, maxLines: 3, ), ), Text( '${gists[index].getLangFileInfo()}', overflow: TextOverflow.ellipsis, ) ], ), ) ], ), Divider() ], ), onTap: () => moveToGistDetailScreen(gists[index]), ); })); } moveToGistDetailScreen(GistModel gist) { /* Navigator.push( context, MaterialPageRoute(builder: (context) =>), );*/ } void _scrollListener() { print(scrollController.position.extentAfter); if (scrollController.position.extentAfter == 0 && gists != null) { if (subscription == null) { getGists(); } } } void getGists() { showProgress(); if (subscription != null) { subscription.cancel(); } subscription = Github.getGistsForUser(loginName, 10, page) .asStream() .listen((response) { this.setState(() { if (this.gists == null) { this.gists = parseGists(response.body); } else { this.gists.addAll(parseGists(response.body)); } }); page = page + 1; hideProgress(); subscription = null; }); } } // A function that will convert a response body into a List<User> List<GistModel> parseGists(String responseBody) { var gists = json.decode(responseBody) as List; var gistsList = List<GistModel>(); gists.forEach((json) { gistsList.add(GistModel.fromJson(json)); }); return gistsList; }
0
mirrored_repositories/FlutterGithubClient/lib/ui
mirrored_repositories/FlutterGithubClient/lib/ui/usergists/UserGistsPage.dart
import 'package:LoginUI/ui/usergists/UserGistsPageState.dart'; import 'package:flutter/material.dart'; class UserGistsPage extends StatefulWidget { String loginName; UserGistsPage(String username, {Key key}) : super(key: key){ this.loginName = username; } @override UserGistsPageState createState() => new UserGistsPageState(loginName); }
0
mirrored_repositories/FlutterGithubClient/lib/ui
mirrored_repositories/FlutterGithubClient/lib/ui/base/BaseStatefulState.dart
import 'package:flutter/material.dart'; abstract class BaseStatefulState<StatefulWidget> extends State { final GlobalKey<ScaffoldState> scaffoldKey = new GlobalKey<ScaffoldState>(); final SnackBar snackBar = new SnackBar( content: new Row( children: <Widget>[ new Container( child: new CircularProgressIndicator(), margin: EdgeInsets.all(4.0)), new Container( child: new Text("Loading..."), margin: EdgeInsets.all(4.0)), ], ), ); bool isVisible = false; @override Widget build(BuildContext context) { return prepareWidget(context); } void showProgress() { if(!isVisible){ scaffoldKey.currentState.showSnackBar(snackBar); } isVisible = true; } void hideProgress() { if(isVisible){ scaffoldKey.currentState.hideCurrentSnackBar(); } isVisible = false; } Widget prepareWidget(BuildContext context); }
0
mirrored_repositories/FlutterGithubClient/lib/ui
mirrored_repositories/FlutterGithubClient/lib/ui/searchusers/UserSearchPageState.dart
import 'dart:async'; import 'dart:convert'; import 'package:LoginUI/model/UserProfile.dart'; import 'package:LoginUI/network/Github.dart'; import 'package:LoginUI/ui/base/BaseStatefulState.dart'; import 'package:LoginUI/ui/searchusers/UserSearchPage.dart'; import 'package:LoginUI/userprofile/UserProfilePage.dart'; import 'package:LoginUI/utils/SharedPrefs.dart'; import 'package:flutter/material.dart'; import 'package:http/src/response.dart'; class UserSearchPageState extends BaseStatefulState<UserSearchPage> with TickerProviderStateMixin { double USER_IMAGE_SIZE = 200.0; dynamic getUserResponse; List<UserProfile> users; Icon actionIcon = new Icon(Icons.search); Widget appBarTitle = new Text("Search Github Users..."); StreamSubscription<Response> subscription; String accessToken; ScrollController scrollController; var page = 1; String searchString; @override void initState() { super.initState(); scrollController = new ScrollController(); scrollController.addListener(_scrollListener); SharedPrefs().getToken().then((token) { accessToken = token; }); } @override void dispose() { if (subscription != null) { subscription.cancel(); } scrollController.removeListener(_scrollListener); super.dispose(); } @override Widget prepareWidget(BuildContext context) { // This method is rerun every time setState is called, for instance as done // by the _incrementCounter method above. // // The Flutter framework has been optimized to make rerunning build methods // fast, so that you can just rebuild anything that needs updating rather // than having to individually change instances of widgets. return new Scaffold( key: scaffoldKey, body: new Column( children: <Widget>[toolbarAndroid(), listVIew()], )); } listVIew() { return new Expanded( child: new ListView.builder( controller: scrollController, padding: new EdgeInsets.all(8.0), itemCount: users == null ? 0 : users.length, itemBuilder: (BuildContext context, int index) { return new GestureDetector( child: new Row( children: <Widget>[ new Container( child: new Image.network(users[index].avatarUrl, width: 50.0, height: 50.0), padding: EdgeInsets.all(10), ), new Container( margin: EdgeInsets.all(10), child: new Text('${users[index].login}')) ], ), onTap: () => moveToUserScreen(users[index]), ); })); } moveToUserScreen(UserProfile user) { Navigator.push( context, MaterialPageRoute(builder: (context) => UserProfilePage(user.login)), ); } toolbarAndroid() { return new AppBar( centerTitle: false, backgroundColor: Colors.black, title: appBarTitle, actions: <Widget>[ new IconButton(icon: actionIcon, onPressed: () => onClickToolbar()) ], ); } searchUser(String string) { if (this.searchString != null && searchString.compareTo(string) != 0) { setState(() { page = 1; this.users = null; }); } this.searchString = string; if (subscription != null) { subscription.cancel(); } showProgress(); var stream = Github.getUsersBySearch(accessToken, string, page).asStream(); subscription = stream.listen((response) { print("Response " + response.body); var parsedData = json.decode(response.body); if (parsedData['message'].toString() != "Validation Failed") { setState(() { if (users == null) { users = parseUsers(response.body); } else { users.addAll(parseUsers(response.body)); } page = page + 1; }); } hideProgress(); subscription = null; }); } onClickToolbar() { setState(() { if (this.actionIcon.icon == Icons.search) { this.actionIcon = new Icon(Icons.close); this.appBarTitle = new TextField( onChanged: (string) => searchUser(string), style: new TextStyle( color: Colors.white, ), decoration: new InputDecoration( prefixIcon: new Icon(Icons.search, color: Colors.white), hintText: "Search...", hintStyle: new TextStyle(color: Colors.white)), ); } else { this.actionIcon = new Icon(Icons.search); if (this.subscription != null) { this.subscription.cancel(); } this.users = null; this.appBarTitle = new Text("Search Github Users..."); } }); } void _scrollListener() { print(scrollController.position.extentAfter); if (scrollController.position.extentAfter == 0 && users != null) { if (subscription == null) { searchUser(searchString); } } } } // A function that will convert a response body into a List<User> List<UserProfile> parseUsers(String responseBody) { var parsedData = json.decode(responseBody); var users = parsedData['items'] as List<dynamic>; var userProfiles = new List<UserProfile>(); users.forEach((object) { print(object); userProfiles.add(UserProfile.fromJson(object)); }); return userProfiles; }
0
mirrored_repositories/FlutterGithubClient/lib/ui
mirrored_repositories/FlutterGithubClient/lib/ui/searchusers/UserSearchPage.dart
import 'package:LoginUI/ui/searchusers/UserSearchPageState.dart'; import 'package:flutter/material.dart'; class UserSearchPage extends StatefulWidget { UserSearchPage({Key key}) : super(key: key); @override UserSearchPageState createState() => new UserSearchPageState(); }
0
mirrored_repositories/FlutterGithubClient
mirrored_repositories/FlutterGithubClient/test/app_test.dart
import 'package:flutter_test/flutter_test.dart'; import 'package:LoginUI/main.dart'; void main() { testWidgets("App should work", (WidgetTester tester) async { tester.pumpWidget(AppGithubClient()); }); }
0
mirrored_repositories/flutter_bmi_calculator_app
mirrored_repositories/flutter_bmi_calculator_app/lib/main.dart
import 'package:bmi_calculator/ui/splash.dart'; import 'package:flutter/material.dart'; void main() => runApp(MyApp()); class MyApp extends StatelessWidget { @override Widget build(BuildContext context) { return MaterialApp( debugShowCheckedModeBanner: false, home: SplashScreen(), ); } }
0
mirrored_repositories/flutter_bmi_calculator_app/lib
mirrored_repositories/flutter_bmi_calculator_app/lib/ui/splash.dart
import 'package:bmi_calculator/ui/home.dart'; import 'package:flutter/material.dart'; import 'dart:async'; import 'package:flutter/services.dart'; class SplashScreen extends StatefulWidget { @override _SplashScreenState createState() => _SplashScreenState(); } class _SplashScreenState extends State<SplashScreen> { @override void initState() { super.initState(); SystemChrome.setPreferredOrientations([ DeviceOrientation.portraitUp, DeviceOrientation.portraitDown, ]); Timer(Duration(seconds: 3), () { Navigator.of(context).pushReplacement(MaterialPageRoute( builder: (context) => HomePage(), )); }); } @override void dispose() { super.dispose(); SystemChrome.setPreferredOrientations([ DeviceOrientation.portraitUp, DeviceOrientation.portraitDown, ]); } @override Widget build(BuildContext context) { return Scaffold( backgroundColor: Colors.white, body: Center( child: Text( "BMI Calculator App", style: new TextStyle( fontSize: 30.0, color: Colors.black, fontFamily: 'PoppinsExBold'), ), ), ); } }
0
mirrored_repositories/flutter_bmi_calculator_app/lib
mirrored_repositories/flutter_bmi_calculator_app/lib/ui/home.dart
import 'package:flutter/material.dart'; class HomePage extends StatefulWidget { @override _HomePageState createState() => _HomePageState(); } class _HomePageState extends State<HomePage> { String result = ''; double height = 0; double weight = 0; int resultIndex = 0; // declare a custom radio button int currentIndex = 0; // declare inputController to get input value TextEditingController heightController = TextEditingController(); TextEditingController weightController = TextEditingController(); // make function to calculate BMI void calculateBMI(double height, double weight) { double finalResult = weight / (height * (height / 10000)); String bmi = finalResult.toStringAsFixed(2); resultIndex = finalResult.toInt(); setState(() { result = bmi; }); } // declare function to change value index while pressed void changeIndex(int index) { setState(() { currentIndex = index; }); } // result text Widget resultText(resultIndex) { if (resultIndex <= 16 && resultIndex > 0) { return Center( child: Text("UnderWeight", style: TextStyle( fontSize: 18.0, fontFamily: 'PoppinsExBold', color: (resultIndex <= 16 || resultIndex >= 27) ? Colors.red : Colors.green)), ); } if (resultIndex >= 27) { return Center( child: Text("OverWeight", style: TextStyle( fontSize: 18.0, fontFamily: 'PoppinsExBold', color: (resultIndex <= 16 || resultIndex >= 27) ? Colors.red : Colors.green)), ); } if (resultIndex == 0) { return Text("a", style: TextStyle(color: Colors.white)); } else { return Center( child: Text("Normal", style: TextStyle( fontSize: 18.0, fontFamily: 'PoppinsExBold', color: (resultIndex <= 16 || resultIndex >= 27) ? Colors.red : Colors.green)), ); } } // make a custom widget Widget radioButton(String value, Color color, int index) { return Expanded( child: Container( height: MediaQuery.of(context).size.height / 8, margin: EdgeInsets.symmetric(horizontal: 12.0), child: FlatButton( onPressed: () { // button when clicked get currentIndex == index changeIndex(index); }, // change colors when the button clicked color: currentIndex == index ? color : Colors.grey[200], shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(10.0)), child: Text(value, style: TextStyle( color: currentIndex == index ? Colors.white : color, fontFamily: 'PoppinsBold')), ), ), ); } @override Widget build(BuildContext context) { return Scaffold( backgroundColor: Colors.white, appBar: AppBar( title: Center( child: Text("BMI Calculator", style: TextStyle( color: Colors.black, fontFamily: 'PoppinsExBold'))), backgroundColor: Colors.white, elevation: 0, ), body: GestureDetector( onTap: () => FocusScope.of(context).unfocus(), child: SingleChildScrollView( child: Column( mainAxisAlignment: MainAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start, children: [ Row( children: [ radioButton("Man", Colors.blue, 0), radioButton("Woman", Colors.pink, 1), ], ), SizedBox(height: 15), Padding( padding: const EdgeInsets.only(left: 15.0), child: RichText( text: TextSpan( children: <TextSpan>[ TextSpan( text: 'Height', style: TextStyle( fontSize: 18, color: Colors.black, fontFamily: 'PoppinsBold')), TextSpan( text: '(CM)', style: TextStyle( fontSize: 12, color: Colors.grey, fontFamily: 'PoppinsReg')), ], ), )), SizedBox(height: 5), TextField( keyboardType: TextInputType.number, textAlign: TextAlign.center, // add controller controller: heightController, decoration: InputDecoration( hintText: "Your Height in CM", fillColor: Colors.grey[200], border: OutlineInputBorder( borderRadius: BorderRadius.circular(10.0), borderSide: BorderSide.none, ), ), ), SizedBox(height: 10), Padding( padding: const EdgeInsets.only(left: 15.0), child: RichText( text: TextSpan( children: <TextSpan>[ TextSpan( text: 'Weight', style: TextStyle( fontSize: 18, color: Colors.black, fontFamily: 'PoppinsBold')), TextSpan( text: '(KG)', style: TextStyle( fontSize: 12, color: Colors.grey, fontFamily: 'PoppinsReg')), ], ), )), SizedBox(height: 5), TextField( keyboardType: TextInputType.number, textAlign: TextAlign.center, // add controller controller: weightController, decoration: InputDecoration( hintText: "Your Weight in KG", fillColor: Colors.grey[200], border: OutlineInputBorder( borderRadius: BorderRadius.circular(10.0), borderSide: BorderSide.none, ), ), ), SizedBox(height: 10), Padding( padding: const EdgeInsets.only(left: 15.0, right: 15.0), child: Container( width: double.infinity, height: MediaQuery.of(context).size.height / 14, child: FlatButton( onPressed: () { setState(() { height = double.parse(heightController.value.text); weight = double.parse(weightController.value.text); }); calculateBMI(height, weight); }, color: Colors.blue, shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(10.0)), child: Text("Calculate", style: TextStyle( color: Colors.white, fontFamily: 'PoppinsBold'))), ), ), SizedBox(height: 10), Center( child: Text('Your Result: ', style: TextStyle( fontSize: 24.0, fontFamily: 'PoppinsBold'))), SizedBox(height: 10), Center( child: Text('$result', style: TextStyle( fontSize: 68.0, fontFamily: 'PoppinsExBold', color: (resultIndex <= 16 || resultIndex >= 27) ? Colors.red : Colors.green))), SizedBox(height: 5), resultText(resultIndex), ], ), ), ), ); } }
0
mirrored_repositories/flutter_bmi_calculator_app
mirrored_repositories/flutter_bmi_calculator_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:bmi_calculator/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/cash_recorder
mirrored_repositories/cash_recorder/lib/injection.dart
import 'package:cash_recorderv2/database/database.isar.dart'; import 'package:cash_recorderv2/repository/db_repository.dart'; import 'package:get/get.dart'; import 'package:isar/isar.dart'; import 'package:path_provider/path_provider.dart'; Future<Isar> getIsarInstance() async { final dir = await getApplicationDocumentsDirectory(); return await Isar.open( [BillSchema], directory: dir.path, ); } Future<void> dependencyInjection() async { final isar = await getIsarInstance(); Get.put(DatabaseRepository(isar)); }
0
mirrored_repositories/cash_recorder
mirrored_repositories/cash_recorder/lib/main.dart
import 'package:cash_recorderv2/features/home/home_view.dart'; import 'package:cash_recorderv2/injection.dart'; import 'package:flutter/material.dart'; void main() async { WidgetsFlutterBinding.ensureInitialized(); await dependencyInjection(); runApp(const MyApp()); } class MyApp extends StatelessWidget { const MyApp({super.key}); @override Widget build(BuildContext context) { return MaterialApp( debugShowCheckedModeBanner: false, title: 'Cash Recorder', theme: ThemeData( appBarTheme: const AppBarTheme( iconTheme: IconThemeData(color: Colors.white), titleTextStyle: TextStyle( color: Colors.white, fontSize: 18, ), ), colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple), useMaterial3: true, ), home: const HomeView(), ); } }
0
mirrored_repositories/cash_recorder/lib
mirrored_repositories/cash_recorder/lib/repository/db_repository.dart
import 'dart:async'; import 'package:cash_recorderv2/core/util/db_ext.dart'; import 'package:cash_recorderv2/database/database.isar.dart'; import 'package:isar/isar.dart'; class DatabaseRepository { Isar isarInstance; DatabaseRepository(this.isarInstance); Stream<List<Bill>> get billStream => isarInstance.bills .filter() .parentBillIsNull() .watch(fireImmediately: true); Future<void> addBill(Bill bill) async { await isarInstance.writeTxn(() async { return isarInstance.bills.put(bill); }); } Future<void> addBillWithParent(Bill bill) async { await isarInstance.writeTxn(() async { await isarInstance.bills.put(bill); await bill.parentBill.save(); }); } Stream<Bill> getBillContent(Id id) { StreamController<Bill> billStreamController = StreamController<Bill>(); isarInstance.bills .filter() .idEqualTo(id) .watch(fireImmediately: true) .listen( (event) { if (event.isEmpty) return; billStreamController.add(event.first); }, onDone: () { billStreamController.close(); }, ); return billStreamController.stream; } Stream<List<Bill>> getSubBills(Id id) { StreamController<List<Bill>> subBillStreamController = StreamController<List<Bill>>(); isarInstance.bills .filter() .parentBill((q) => q.idEqualTo(id)) .watch(fireImmediately: true) .listen( (event) { subBillStreamController.add(event); }, onDone: () { subBillStreamController.close(); }, ); return subBillStreamController.stream; } addParticular(Id id, Particular particular) { isarInstance.writeTxn(() async { return isarInstance.bills.where().idEqualTo(id).findFirst().then((bill) { bill!.content = [...bill.content, particular]; return isarInstance.bills.put(bill); }); }); } Future<void> deleteParticular(Id id, Particular particular) async { await isarInstance.writeTxn(() async { return isarInstance.bills.where().idEqualTo(id).findFirst().then((bill) { final contentList = List<Particular>.from(bill!.content); contentList.removeWhere( (element) => element.isEqual(particular), ); bill.content = contentList; return isarInstance.bills.put(bill); }); }); } Future<int> getDescendants(Id id) async { int count = 0; await isarInstance.bills .filter() .parentBill((q) => q.idEqualTo(id)) .build() .findAll() .then((value) async { count += value.length; for (final bill in value) { count += await getDescendants(bill.id); } }); return count; } Future<void> deleteBill(Id id) async { await isarInstance.writeTxn(() async { return await _deleteBillRecursive(id); }); } Future<void> _deleteBillRecursive(Id id) async { return isarInstance.bills .where() .idEqualTo(id) .findFirst() .then((bill) async { final childBills = await isarInstance.bills .filter() .parentBill((q) => q.idEqualTo(id)) .build() .findAll(); for (final childBill in childBills) { await _deleteBillRecursive(childBill.id); } await isarInstance.bills.delete(bill!.id); }); } }
0
mirrored_repositories/cash_recorder/lib/features
mirrored_repositories/cash_recorder/lib/features/home/home_view.dart
import 'package:cash_recorderv2/core/util/widget_ext.dart'; import 'package:cash_recorderv2/database/database.isar.dart'; import 'package:cash_recorderv2/features/bill/bill_view.dart'; import 'package:cash_recorderv2/features/home/home_bloc.dart'; import 'package:cash_recorderv2/repository/db_repository.dart'; import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:get/get.dart'; class HomeView extends StatelessWidget { const HomeView({super.key}); @override Widget build(BuildContext context) { return BlocProvider( create: (context) => HomeCubit(Get.find()), child: const HomePage(), ); } } class HomePage extends StatelessWidget { const HomePage({super.key}); @override Widget build(BuildContext context) { return SafeArea( child: Scaffold( appBar: AppBar( title: const Text( 'All Bills', style: TextStyle( color: Colors.white, ), ), backgroundColor: Colors.deepPurple, ), body: BlocBuilder<HomeCubit, HomeState>( builder: (context, state) { if (state.status == HomeStatus.loading) { return const Center( child: CircularProgressIndicator(), ); } else { return ListView.builder( itemCount: state.bills.length, itemBuilder: (context, index) { return BillWidget( bill: state.bills[index], ); }, ); } }, ), floatingActionButton: FloatingActionButton( onPressed: () { final ctrl = TextEditingController(); AlertDialog( title: const Text('Add Bill'), content: Column( mainAxisSize: MainAxisSize.min, children: [ TextField( controller: ctrl, autofocus: true, ), ], ), actions: [ TextButton( onPressed: () { Navigator.of(context).pop(); }, child: const Text('Cancel'), ), TextButton( onPressed: () { final bill = Bill(); bill.billName = ctrl.text; Get.find<DatabaseRepository>().addBill(bill); Navigator.of(context).pop(); }, child: const Text('Add'), ), ], ).showDialogBlocExt<HomeCubit>(context: context); }, child: const Icon(Icons.add), ), ), ); } } class BillWidget extends StatelessWidget { const BillWidget({ super.key, required this.bill, }); final Bill bill; @override Widget build(BuildContext context) { return InkWell( onTap: () { Navigator.of(context).push(MaterialPageRoute( builder: (context) => BillView( bill: bill, ), )); }, child: Container( margin: const EdgeInsets.symmetric( horizontal: 10, vertical: 10, ), padding: const EdgeInsets.all(16.0), decoration: BoxDecoration( borderRadius: BorderRadius.circular(10.0), ), child: Row( children: [ Expanded( child: Text( bill.billName, style: const TextStyle(fontSize: 15.0), ), ), const Icon( Icons.arrow_forward, color: Colors.grey, ), ], ), ), ); } }
0
mirrored_repositories/cash_recorder/lib/features
mirrored_repositories/cash_recorder/lib/features/home/home_bloc.dart
import 'dart:async'; import 'package:cash_recorderv2/database/database.isar.dart'; import 'package:cash_recorderv2/repository/db_repository.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; enum HomeStatus { loading, loaded, } class HomeState { final HomeStatus status; final List<Bill> bills; HomeState({this.status = HomeStatus.loading, this.bills = const []}); HomeState.initial() : status = HomeStatus.loading, bills = const []; HomeState copyWith({HomeStatus? status, List<Bill>? bills}) { return HomeState(status: status ?? this.status, bills: bills ?? this.bills); } } class HomeCubit extends Cubit<HomeState> { DatabaseRepository databaseRepository; StreamSubscription? _subscription; HomeCubit(this.databaseRepository) : super(HomeState.initial()) { _subscription = databaseRepository.billStream.listen((bills) { emit(state.copyWith(status: HomeStatus.loaded, bills: bills)); }); } @override Future<void> close() { _subscription?.cancel(); return super.close(); } }
0
mirrored_repositories/cash_recorder/lib/features
mirrored_repositories/cash_recorder/lib/features/bill/bill_view.dart
import 'dart:async'; import 'package:cash_recorderv2/core/util/db_ext.dart'; import 'package:cash_recorderv2/core/util/format_ext.dart'; import 'package:cash_recorderv2/core/util/widget_ext.dart'; import 'package:cash_recorderv2/database/database.isar.dart'; import 'package:cash_recorderv2/features/bill/bill_bloc.dart'; import 'package:cash_recorderv2/features/bill/widgets/bill_dialog_widget.dart'; import 'package:cash_recorderv2/features/bill/widgets/particular_dialog_widget.dart'; import 'package:cash_recorderv2/features/home/home_view.dart'; import 'package:cash_recorderv2/repository/db_repository.dart'; import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:get/get.dart'; class BillView extends StatelessWidget { const BillView({super.key, required this.bill}); final Bill bill; @override Widget build(BuildContext context) { return BlocProvider( create: (context) => BillCubit( Get.find(), bill, ), child: const BillPage(), ); } } class BillPage extends StatefulWidget { const BillPage({super.key}); @override State<BillPage> createState() => _BillPageState(); } class _BillPageState extends State<BillPage> with SingleTickerProviderStateMixin { late TabController _tabController; @override void initState() { _tabController = TabController( length: 2, vsync: this, ); super.initState(); } @override Widget build(BuildContext context) { final billState = context.watch<BillCubit>().state; if (billState.status == BillStatus.loading) { return const SafeArea( child: Scaffold( body: Center( child: CircularProgressIndicator(), ), ), ); } return SafeArea( child: Scaffold( appBar: AppBar( backgroundColor: Colors.deepPurple, title: FittedBox( child: Text( '${context.read<BillCubit>().bill.parentString}bill', style: const TextStyle( color: Colors.white, ), ), ), actions: [ IconButton( onPressed: () { Get.find<DatabaseRepository>() .getDescendants(context.read<BillCubit>().bill.id) .then((value) { AlertDialog( title: const Text('Delete Bill'), content: Text( 'Are you sure you want to delete this bill and its $value sub bills?', ), actions: [ TextButton( onPressed: () { Navigator.of(context).pop(); }, child: const Text('Cancel'), ), TextButton( onPressed: () { Get.find<DatabaseRepository>() .deleteBill(context.read<BillCubit>().bill.id); Navigator.of(context).pop(); Navigator.of(context).pop(); }, child: const Text('Delete'), ), ], ).showDialogExt(context: context); }); }, icon: const Icon( Icons.delete, color: Colors.white, ), ), ], bottom: TabBar( labelColor: Colors.white, unselectedLabelColor: Colors.white.withOpacity(0.5), indicatorColor: Colors.white, controller: _tabController, tabs: const [ Tab(text: 'Records'), Tab(text: 'Sub Bills'), ], ), ), body: TabBarView( controller: _tabController, children: [ billState.particulars.isEmpty ? const Center( child: Text( "Empty", style: TextStyle(fontSize: 15), ), ) : CustomScrollView( slivers: [ TotalWidget(totalAmount: billState.totalAmount), SliverList.builder( itemBuilder: (context, index) { final item = billState.particulars[index]; return RecordWidget(particular: item); }, itemCount: billState.particulars.length, ), SliverToBoxAdapter( child: 60.hBox, ) ], ), billState.subBills.isEmpty ? const Center( child: Text( "Empty", style: TextStyle(fontSize: 15), ), ) : CustomScrollView( slivers: [ SliverList.builder( itemBuilder: (context, index) { return BillWidget(bill: billState.subBills[index]); }, itemCount: billState.subBills.length, ) ], ), ], ), floatingActionButtonLocation: FloatingActionButtonLocation.centerFloat, floatingActionButton: Row( mainAxisAlignment: MainAxisAlignment.center, children: [ FloatingActionButton.extended( heroTag: "btn1", label: const Text("Add Record"), onPressed: () { ParticularDialog() .showDialogBlocExt<BillCubit>(context: context); }, icon: const Icon(Icons.add), ), 10.wBox, FloatingActionButton.extended( heroTag: "btn2", label: const Text("Add Bill"), onPressed: () { BillDialog().showDialogBlocExt<BillCubit>(context: context); }, icon: const Icon(Icons.add), ), ], ), ), ); } } class TotalWidget extends StatelessWidget { const TotalWidget({ super.key, required this.totalAmount, }); final double totalAmount; @override Widget build(BuildContext context) { return SliverToBoxAdapter( child: Container( decoration: const BoxDecoration( border: Border( bottom: BorderSide( color: Colors.grey, width: 1, ), ), ), padding: const EdgeInsets.symmetric(horizontal: 15, vertical: 10), child: Column( children: [ const Text( "Total", style: TextStyle(fontSize: 15), ), 5.hBox, Text( totalAmount.indianFormat, style: const TextStyle(fontSize: 20), ), ], ), ), ); } } class RecordWidget extends StatelessWidget { const RecordWidget({ super.key, required this.particular, }); final Particular particular; @override Widget build(BuildContext context) { return Dismissible( key: UniqueKey(), onDismissed: (direction) async { final id = context.read<BillCubit>().bill.id; await Get.find<DatabaseRepository>().deleteParticular(id, particular); }, background: Container( color: Colors.red, child: const Icon( Icons.delete, color: Colors.white, ), ), confirmDismiss: (direction) async { final Completer<bool> completer = Completer<bool>(); AlertDialog( title: const Text("Are you sure?"), content: const Text("Do you want to delete this record?"), actions: [ TextButton( onPressed: () { completer.complete(false); Navigator.of(context).pop(); }, child: const Text("No"), ), TextButton( onPressed: () { completer.complete(true); Navigator.of(context).pop(); }, child: const Text("Yes"), ), ], ).showDialogBlocExt<BillCubit>(context: context); return completer.future; }, child: ListTile( title: Text(particular.particularName), subtitle: Text(particular.amount.indianFormat), ), ); } }
0
mirrored_repositories/cash_recorder/lib/features
mirrored_repositories/cash_recorder/lib/features/bill/bill_bloc.dart
import 'dart:async'; import 'package:cash_recorderv2/database/database.isar.dart'; import 'package:cash_recorderv2/repository/db_repository.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:rxdart/rxdart.dart'; import 'package:cash_recorderv2/core/util/total_calc_ext.dart'; enum BillStatus { loading, loaded, } class BillState { final BillStatus status; final List<Particular> particulars; final List<Bill> subBills; final double totalAmount; BillState({ this.status = BillStatus.loading, this.particulars = const [], this.subBills = const [], this.totalAmount = 0, }); BillState.initial() : status = BillStatus.loading, particulars = const [], subBills = const [], totalAmount = 0; BillState copyWith({ BillStatus? status, List<Particular>? particulars, List<Bill>? subBills, double? totalAmount, }) { return BillState( status: status ?? this.status, particulars: particulars ?? this.particulars, subBills: subBills ?? this.subBills, totalAmount: totalAmount ?? this.totalAmount, ); } } class BillCubit extends Cubit<BillState> { final DatabaseRepository databaseRepository; final Bill bill; StreamSubscription? _subscription; BillCubit(this.databaseRepository, this.bill) : super(BillState.initial()) { final contentStream = databaseRepository.getBillContent(bill.id); final subBillStream = databaseRepository.getSubBills(bill.id); _subscription = Rx.combineLatest2(contentStream, subBillStream, (a, b) => (a, b)) .listen( (event) { emit( state.copyWith( status: BillStatus.loaded, particulars: event.$1.content, subBills: event.$2, totalAmount: event.$1.content.total, ), ); }, onDone: () {}, ); } @override Future<void> close() { _subscription?.cancel(); return super.close(); } }
0
mirrored_repositories/cash_recorder/lib/features/bill
mirrored_repositories/cash_recorder/lib/features/bill/widgets/particular_dialog_widget.dart
import 'package:cash_recorderv2/database/database.isar.dart'; import 'package:cash_recorderv2/features/bill/bill_bloc.dart'; import 'package:cash_recorderv2/repository/db_repository.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:flutter/widgets.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:get/get.dart'; class ParticularDialog extends StatelessWidget { ParticularDialog({super.key}); final ctrl1 = TextEditingController(); final ctrl2 = TextEditingController(); @override Widget build(BuildContext context) { return AlertDialog( title: const Text('Add Record'), content: Column( mainAxisSize: MainAxisSize.min, children: [ TextField( decoration: const InputDecoration( labelText: 'Record Name', ), controller: ctrl1, autofocus: true, ), TextField( decoration: const InputDecoration( labelText: 'Amount', ), inputFormatters: [ FilteringTextInputFormatter.allow(RegExp(r'^\d+\.?\d{0,2}')), ], controller: ctrl2, ), ], ), actions: [ TextButton( onPressed: () { Navigator.pop(context); }, child: const Text('Cancel'), ), TextButton( onPressed: () { final id = context.read<BillCubit>().bill.id; final particular = Particular(); particular.particularName = ctrl1.text; particular.amount = double.tryParse(ctrl2.text) ?? 0; particular.date = DateTime.now(); Get.find<DatabaseRepository>().addParticular(id, particular); Navigator.pop(context); }, child: const Text('Add'), ), ], ); } }
0
mirrored_repositories/cash_recorder/lib/features/bill
mirrored_repositories/cash_recorder/lib/features/bill/widgets/bill_dialog_widget.dart
import 'package:cash_recorderv2/database/database.isar.dart'; import 'package:cash_recorderv2/features/bill/bill_bloc.dart'; import 'package:cash_recorderv2/repository/db_repository.dart'; import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:get/get.dart'; class BillDialog extends StatelessWidget { BillDialog({super.key}); final ctrl = TextEditingController(); @override Widget build(BuildContext context) { return AlertDialog( title: Text('Add Bill'), content: Column( mainAxisSize: MainAxisSize.min, children: [ TextField( controller: ctrl, autofocus: true, // Add this line to focus on the text field from the start ), ], ), actions: [ TextButton( onPressed: () { Navigator.of(context).pop(); }, child: Text('Cancel'), ), TextButton( onPressed: () { final bill = Bill(); bill.billName = ctrl.text; final b = context.read<BillCubit>().bill; bill.parentBill.value = b; Get.find<DatabaseRepository>().addBillWithParent(bill); Navigator.of(context).pop(); }, child: Text('Add'), ), ], ); } }
0
mirrored_repositories/cash_recorder/lib
mirrored_repositories/cash_recorder/lib/database/database.isar.g.dart
// GENERATED CODE - DO NOT MODIFY BY HAND part of 'database.isar.dart'; // ************************************************************************** // IsarCollectionGenerator // ************************************************************************** // coverage:ignore-file // ignore_for_file: duplicate_ignore, non_constant_identifier_names, constant_identifier_names, invalid_use_of_protected_member, unnecessary_cast, prefer_const_constructors, lines_longer_than_80_chars, require_trailing_commas, inference_failure_on_function_invocation, unnecessary_parenthesis, unnecessary_raw_strings, unnecessary_null_checks, join_return_with_assignment, prefer_final_locals, avoid_js_rounded_ints, avoid_positional_boolean_parameters, always_specify_types extension GetBillCollection on Isar { IsarCollection<Bill> get bills => this.collection(); } const BillSchema = CollectionSchema( name: r'Bill', id: 7031121081258233164, properties: { r'billName': PropertySchema( id: 0, name: r'billName', type: IsarType.string, ), r'content': PropertySchema( id: 1, name: r'content', type: IsarType.objectList, target: r'Particular', ) }, estimateSize: _billEstimateSize, serialize: _billSerialize, deserialize: _billDeserialize, deserializeProp: _billDeserializeProp, idName: r'id', indexes: {}, links: { r'parentBill': LinkSchema( id: -7852874788767372768, name: r'parentBill', target: r'Bill', single: true, ) }, embeddedSchemas: {r'Particular': ParticularSchema}, getId: _billGetId, getLinks: _billGetLinks, attach: _billAttach, version: '3.1.0+1', ); int _billEstimateSize( Bill object, List<int> offsets, Map<Type, List<int>> allOffsets, ) { var bytesCount = offsets.last; bytesCount += 3 + object.billName.length * 3; bytesCount += 3 + object.content.length * 3; { final offsets = allOffsets[Particular]!; for (var i = 0; i < object.content.length; i++) { final value = object.content[i]; bytesCount += ParticularSchema.estimateSize(value, offsets, allOffsets); } } return bytesCount; } void _billSerialize( Bill object, IsarWriter writer, List<int> offsets, Map<Type, List<int>> allOffsets, ) { writer.writeString(offsets[0], object.billName); writer.writeObjectList<Particular>( offsets[1], allOffsets, ParticularSchema.serialize, object.content, ); } Bill _billDeserialize( Id id, IsarReader reader, List<int> offsets, Map<Type, List<int>> allOffsets, ) { final object = Bill(); object.billName = reader.readString(offsets[0]); object.content = reader.readObjectList<Particular>( offsets[1], ParticularSchema.deserialize, allOffsets, Particular(), ) ?? []; object.id = id; return object; } P _billDeserializeProp<P>( IsarReader reader, int propertyId, int offset, Map<Type, List<int>> allOffsets, ) { switch (propertyId) { case 0: return (reader.readString(offset)) as P; case 1: return (reader.readObjectList<Particular>( offset, ParticularSchema.deserialize, allOffsets, Particular(), ) ?? []) as P; default: throw IsarError('Unknown property with id $propertyId'); } } Id _billGetId(Bill object) { return object.id; } List<IsarLinkBase<dynamic>> _billGetLinks(Bill object) { return [object.parentBill]; } void _billAttach(IsarCollection<dynamic> col, Id id, Bill object) { object.id = id; object.parentBill.attach(col, col.isar.collection<Bill>(), r'parentBill', id); } extension BillQueryWhereSort on QueryBuilder<Bill, Bill, QWhere> { QueryBuilder<Bill, Bill, QAfterWhere> anyId() { return QueryBuilder.apply(this, (query) { return query.addWhereClause(const IdWhereClause.any()); }); } } extension BillQueryWhere on QueryBuilder<Bill, Bill, QWhereClause> { QueryBuilder<Bill, Bill, QAfterWhereClause> idEqualTo(Id id) { return QueryBuilder.apply(this, (query) { return query.addWhereClause(IdWhereClause.between( lower: id, upper: id, )); }); } QueryBuilder<Bill, Bill, QAfterWhereClause> idNotEqualTo(Id id) { return QueryBuilder.apply(this, (query) { if (query.whereSort == Sort.asc) { return query .addWhereClause( IdWhereClause.lessThan(upper: id, includeUpper: false), ) .addWhereClause( IdWhereClause.greaterThan(lower: id, includeLower: false), ); } else { return query .addWhereClause( IdWhereClause.greaterThan(lower: id, includeLower: false), ) .addWhereClause( IdWhereClause.lessThan(upper: id, includeUpper: false), ); } }); } QueryBuilder<Bill, Bill, QAfterWhereClause> idGreaterThan(Id id, {bool include = false}) { return QueryBuilder.apply(this, (query) { return query.addWhereClause( IdWhereClause.greaterThan(lower: id, includeLower: include), ); }); } QueryBuilder<Bill, Bill, QAfterWhereClause> idLessThan(Id id, {bool include = false}) { return QueryBuilder.apply(this, (query) { return query.addWhereClause( IdWhereClause.lessThan(upper: id, includeUpper: include), ); }); } QueryBuilder<Bill, Bill, QAfterWhereClause> idBetween( Id lowerId, Id upperId, { bool includeLower = true, bool includeUpper = true, }) { return QueryBuilder.apply(this, (query) { return query.addWhereClause(IdWhereClause.between( lower: lowerId, includeLower: includeLower, upper: upperId, includeUpper: includeUpper, )); }); } } extension BillQueryFilter on QueryBuilder<Bill, Bill, QFilterCondition> { QueryBuilder<Bill, Bill, QAfterFilterCondition> billNameEqualTo( String value, { bool caseSensitive = true, }) { return QueryBuilder.apply(this, (query) { return query.addFilterCondition(FilterCondition.equalTo( property: r'billName', value: value, caseSensitive: caseSensitive, )); }); } QueryBuilder<Bill, Bill, QAfterFilterCondition> billNameGreaterThan( String value, { bool include = false, bool caseSensitive = true, }) { return QueryBuilder.apply(this, (query) { return query.addFilterCondition(FilterCondition.greaterThan( include: include, property: r'billName', value: value, caseSensitive: caseSensitive, )); }); } QueryBuilder<Bill, Bill, QAfterFilterCondition> billNameLessThan( String value, { bool include = false, bool caseSensitive = true, }) { return QueryBuilder.apply(this, (query) { return query.addFilterCondition(FilterCondition.lessThan( include: include, property: r'billName', value: value, caseSensitive: caseSensitive, )); }); } QueryBuilder<Bill, Bill, QAfterFilterCondition> billNameBetween( String lower, String upper, { bool includeLower = true, bool includeUpper = true, bool caseSensitive = true, }) { return QueryBuilder.apply(this, (query) { return query.addFilterCondition(FilterCondition.between( property: r'billName', lower: lower, includeLower: includeLower, upper: upper, includeUpper: includeUpper, caseSensitive: caseSensitive, )); }); } QueryBuilder<Bill, Bill, QAfterFilterCondition> billNameStartsWith( String value, { bool caseSensitive = true, }) { return QueryBuilder.apply(this, (query) { return query.addFilterCondition(FilterCondition.startsWith( property: r'billName', value: value, caseSensitive: caseSensitive, )); }); } QueryBuilder<Bill, Bill, QAfterFilterCondition> billNameEndsWith( String value, { bool caseSensitive = true, }) { return QueryBuilder.apply(this, (query) { return query.addFilterCondition(FilterCondition.endsWith( property: r'billName', value: value, caseSensitive: caseSensitive, )); }); } QueryBuilder<Bill, Bill, QAfterFilterCondition> billNameContains(String value, {bool caseSensitive = true}) { return QueryBuilder.apply(this, (query) { return query.addFilterCondition(FilterCondition.contains( property: r'billName', value: value, caseSensitive: caseSensitive, )); }); } QueryBuilder<Bill, Bill, QAfterFilterCondition> billNameMatches( String pattern, {bool caseSensitive = true}) { return QueryBuilder.apply(this, (query) { return query.addFilterCondition(FilterCondition.matches( property: r'billName', wildcard: pattern, caseSensitive: caseSensitive, )); }); } QueryBuilder<Bill, Bill, QAfterFilterCondition> billNameIsEmpty() { return QueryBuilder.apply(this, (query) { return query.addFilterCondition(FilterCondition.equalTo( property: r'billName', value: '', )); }); } QueryBuilder<Bill, Bill, QAfterFilterCondition> billNameIsNotEmpty() { return QueryBuilder.apply(this, (query) { return query.addFilterCondition(FilterCondition.greaterThan( property: r'billName', value: '', )); }); } QueryBuilder<Bill, Bill, QAfterFilterCondition> contentLengthEqualTo( int length) { return QueryBuilder.apply(this, (query) { return query.listLength( r'content', length, true, length, true, ); }); } QueryBuilder<Bill, Bill, QAfterFilterCondition> contentIsEmpty() { return QueryBuilder.apply(this, (query) { return query.listLength( r'content', 0, true, 0, true, ); }); } QueryBuilder<Bill, Bill, QAfterFilterCondition> contentIsNotEmpty() { return QueryBuilder.apply(this, (query) { return query.listLength( r'content', 0, false, 999999, true, ); }); } QueryBuilder<Bill, Bill, QAfterFilterCondition> contentLengthLessThan( int length, { bool include = false, }) { return QueryBuilder.apply(this, (query) { return query.listLength( r'content', 0, true, length, include, ); }); } QueryBuilder<Bill, Bill, QAfterFilterCondition> contentLengthGreaterThan( int length, { bool include = false, }) { return QueryBuilder.apply(this, (query) { return query.listLength( r'content', length, include, 999999, true, ); }); } QueryBuilder<Bill, Bill, QAfterFilterCondition> contentLengthBetween( int lower, int upper, { bool includeLower = true, bool includeUpper = true, }) { return QueryBuilder.apply(this, (query) { return query.listLength( r'content', lower, includeLower, upper, includeUpper, ); }); } QueryBuilder<Bill, Bill, QAfterFilterCondition> idEqualTo(Id value) { return QueryBuilder.apply(this, (query) { return query.addFilterCondition(FilterCondition.equalTo( property: r'id', value: value, )); }); } QueryBuilder<Bill, Bill, QAfterFilterCondition> idGreaterThan( Id value, { bool include = false, }) { return QueryBuilder.apply(this, (query) { return query.addFilterCondition(FilterCondition.greaterThan( include: include, property: r'id', value: value, )); }); } QueryBuilder<Bill, Bill, QAfterFilterCondition> idLessThan( Id value, { bool include = false, }) { return QueryBuilder.apply(this, (query) { return query.addFilterCondition(FilterCondition.lessThan( include: include, property: r'id', value: value, )); }); } QueryBuilder<Bill, Bill, QAfterFilterCondition> idBetween( Id lower, Id upper, { bool includeLower = true, bool includeUpper = true, }) { return QueryBuilder.apply(this, (query) { return query.addFilterCondition(FilterCondition.between( property: r'id', lower: lower, includeLower: includeLower, upper: upper, includeUpper: includeUpper, )); }); } } extension BillQueryObject on QueryBuilder<Bill, Bill, QFilterCondition> { QueryBuilder<Bill, Bill, QAfterFilterCondition> contentElement( FilterQuery<Particular> q) { return QueryBuilder.apply(this, (query) { return query.object(q, r'content'); }); } } extension BillQueryLinks on QueryBuilder<Bill, Bill, QFilterCondition> { QueryBuilder<Bill, Bill, QAfterFilterCondition> parentBill( FilterQuery<Bill> q) { return QueryBuilder.apply(this, (query) { return query.link(q, r'parentBill'); }); } QueryBuilder<Bill, Bill, QAfterFilterCondition> parentBillIsNull() { return QueryBuilder.apply(this, (query) { return query.linkLength(r'parentBill', 0, true, 0, true); }); } } extension BillQuerySortBy on QueryBuilder<Bill, Bill, QSortBy> { QueryBuilder<Bill, Bill, QAfterSortBy> sortByBillName() { return QueryBuilder.apply(this, (query) { return query.addSortBy(r'billName', Sort.asc); }); } QueryBuilder<Bill, Bill, QAfterSortBy> sortByBillNameDesc() { return QueryBuilder.apply(this, (query) { return query.addSortBy(r'billName', Sort.desc); }); } } extension BillQuerySortThenBy on QueryBuilder<Bill, Bill, QSortThenBy> { QueryBuilder<Bill, Bill, QAfterSortBy> thenByBillName() { return QueryBuilder.apply(this, (query) { return query.addSortBy(r'billName', Sort.asc); }); } QueryBuilder<Bill, Bill, QAfterSortBy> thenByBillNameDesc() { return QueryBuilder.apply(this, (query) { return query.addSortBy(r'billName', Sort.desc); }); } QueryBuilder<Bill, Bill, QAfterSortBy> thenById() { return QueryBuilder.apply(this, (query) { return query.addSortBy(r'id', Sort.asc); }); } QueryBuilder<Bill, Bill, QAfterSortBy> thenByIdDesc() { return QueryBuilder.apply(this, (query) { return query.addSortBy(r'id', Sort.desc); }); } } extension BillQueryWhereDistinct on QueryBuilder<Bill, Bill, QDistinct> { QueryBuilder<Bill, Bill, QDistinct> distinctByBillName( {bool caseSensitive = true}) { return QueryBuilder.apply(this, (query) { return query.addDistinctBy(r'billName', caseSensitive: caseSensitive); }); } } extension BillQueryProperty on QueryBuilder<Bill, Bill, QQueryProperty> { QueryBuilder<Bill, int, QQueryOperations> idProperty() { return QueryBuilder.apply(this, (query) { return query.addPropertyName(r'id'); }); } QueryBuilder<Bill, String, QQueryOperations> billNameProperty() { return QueryBuilder.apply(this, (query) { return query.addPropertyName(r'billName'); }); } QueryBuilder<Bill, List<Particular>, QQueryOperations> contentProperty() { return QueryBuilder.apply(this, (query) { return query.addPropertyName(r'content'); }); } } // ************************************************************************** // IsarEmbeddedGenerator // ************************************************************************** // coverage:ignore-file // ignore_for_file: duplicate_ignore, non_constant_identifier_names, constant_identifier_names, invalid_use_of_protected_member, unnecessary_cast, prefer_const_constructors, lines_longer_than_80_chars, require_trailing_commas, inference_failure_on_function_invocation, unnecessary_parenthesis, unnecessary_raw_strings, unnecessary_null_checks, join_return_with_assignment, prefer_final_locals, avoid_js_rounded_ints, avoid_positional_boolean_parameters, always_specify_types const ParticularSchema = Schema( name: r'Particular', id: -1522864590791142818, properties: { r'amount': PropertySchema( id: 0, name: r'amount', type: IsarType.double, ), r'date': PropertySchema( id: 1, name: r'date', type: IsarType.dateTime, ), r'particularName': PropertySchema( id: 2, name: r'particularName', type: IsarType.string, ) }, estimateSize: _particularEstimateSize, serialize: _particularSerialize, deserialize: _particularDeserialize, deserializeProp: _particularDeserializeProp, ); int _particularEstimateSize( Particular object, List<int> offsets, Map<Type, List<int>> allOffsets, ) { var bytesCount = offsets.last; bytesCount += 3 + object.particularName.length * 3; return bytesCount; } void _particularSerialize( Particular object, IsarWriter writer, List<int> offsets, Map<Type, List<int>> allOffsets, ) { writer.writeDouble(offsets[0], object.amount); writer.writeDateTime(offsets[1], object.date); writer.writeString(offsets[2], object.particularName); } Particular _particularDeserialize( Id id, IsarReader reader, List<int> offsets, Map<Type, List<int>> allOffsets, ) { final object = Particular(); object.amount = reader.readDouble(offsets[0]); object.date = reader.readDateTime(offsets[1]); object.particularName = reader.readString(offsets[2]); return object; } P _particularDeserializeProp<P>( IsarReader reader, int propertyId, int offset, Map<Type, List<int>> allOffsets, ) { switch (propertyId) { case 0: return (reader.readDouble(offset)) as P; case 1: return (reader.readDateTime(offset)) as P; case 2: return (reader.readString(offset)) as P; default: throw IsarError('Unknown property with id $propertyId'); } } extension ParticularQueryFilter on QueryBuilder<Particular, Particular, QFilterCondition> { QueryBuilder<Particular, Particular, QAfterFilterCondition> amountEqualTo( double value, { double epsilon = Query.epsilon, }) { return QueryBuilder.apply(this, (query) { return query.addFilterCondition(FilterCondition.equalTo( property: r'amount', value: value, epsilon: epsilon, )); }); } QueryBuilder<Particular, Particular, QAfterFilterCondition> amountGreaterThan( double value, { bool include = false, double epsilon = Query.epsilon, }) { return QueryBuilder.apply(this, (query) { return query.addFilterCondition(FilterCondition.greaterThan( include: include, property: r'amount', value: value, epsilon: epsilon, )); }); } QueryBuilder<Particular, Particular, QAfterFilterCondition> amountLessThan( double value, { bool include = false, double epsilon = Query.epsilon, }) { return QueryBuilder.apply(this, (query) { return query.addFilterCondition(FilterCondition.lessThan( include: include, property: r'amount', value: value, epsilon: epsilon, )); }); } QueryBuilder<Particular, Particular, QAfterFilterCondition> amountBetween( double lower, double upper, { bool includeLower = true, bool includeUpper = true, double epsilon = Query.epsilon, }) { return QueryBuilder.apply(this, (query) { return query.addFilterCondition(FilterCondition.between( property: r'amount', lower: lower, includeLower: includeLower, upper: upper, includeUpper: includeUpper, epsilon: epsilon, )); }); } QueryBuilder<Particular, Particular, QAfterFilterCondition> dateEqualTo( DateTime value) { return QueryBuilder.apply(this, (query) { return query.addFilterCondition(FilterCondition.equalTo( property: r'date', value: value, )); }); } QueryBuilder<Particular, Particular, QAfterFilterCondition> dateGreaterThan( DateTime value, { bool include = false, }) { return QueryBuilder.apply(this, (query) { return query.addFilterCondition(FilterCondition.greaterThan( include: include, property: r'date', value: value, )); }); } QueryBuilder<Particular, Particular, QAfterFilterCondition> dateLessThan( DateTime value, { bool include = false, }) { return QueryBuilder.apply(this, (query) { return query.addFilterCondition(FilterCondition.lessThan( include: include, property: r'date', value: value, )); }); } QueryBuilder<Particular, Particular, QAfterFilterCondition> dateBetween( DateTime lower, DateTime upper, { bool includeLower = true, bool includeUpper = true, }) { return QueryBuilder.apply(this, (query) { return query.addFilterCondition(FilterCondition.between( property: r'date', lower: lower, includeLower: includeLower, upper: upper, includeUpper: includeUpper, )); }); } QueryBuilder<Particular, Particular, QAfterFilterCondition> particularNameEqualTo( String value, { bool caseSensitive = true, }) { return QueryBuilder.apply(this, (query) { return query.addFilterCondition(FilterCondition.equalTo( property: r'particularName', value: value, caseSensitive: caseSensitive, )); }); } QueryBuilder<Particular, Particular, QAfterFilterCondition> particularNameGreaterThan( String value, { bool include = false, bool caseSensitive = true, }) { return QueryBuilder.apply(this, (query) { return query.addFilterCondition(FilterCondition.greaterThan( include: include, property: r'particularName', value: value, caseSensitive: caseSensitive, )); }); } QueryBuilder<Particular, Particular, QAfterFilterCondition> particularNameLessThan( String value, { bool include = false, bool caseSensitive = true, }) { return QueryBuilder.apply(this, (query) { return query.addFilterCondition(FilterCondition.lessThan( include: include, property: r'particularName', value: value, caseSensitive: caseSensitive, )); }); } QueryBuilder<Particular, Particular, QAfterFilterCondition> particularNameBetween( String lower, String upper, { bool includeLower = true, bool includeUpper = true, bool caseSensitive = true, }) { return QueryBuilder.apply(this, (query) { return query.addFilterCondition(FilterCondition.between( property: r'particularName', lower: lower, includeLower: includeLower, upper: upper, includeUpper: includeUpper, caseSensitive: caseSensitive, )); }); } QueryBuilder<Particular, Particular, QAfterFilterCondition> particularNameStartsWith( String value, { bool caseSensitive = true, }) { return QueryBuilder.apply(this, (query) { return query.addFilterCondition(FilterCondition.startsWith( property: r'particularName', value: value, caseSensitive: caseSensitive, )); }); } QueryBuilder<Particular, Particular, QAfterFilterCondition> particularNameEndsWith( String value, { bool caseSensitive = true, }) { return QueryBuilder.apply(this, (query) { return query.addFilterCondition(FilterCondition.endsWith( property: r'particularName', value: value, caseSensitive: caseSensitive, )); }); } QueryBuilder<Particular, Particular, QAfterFilterCondition> particularNameContains(String value, {bool caseSensitive = true}) { return QueryBuilder.apply(this, (query) { return query.addFilterCondition(FilterCondition.contains( property: r'particularName', value: value, caseSensitive: caseSensitive, )); }); } QueryBuilder<Particular, Particular, QAfterFilterCondition> particularNameMatches(String pattern, {bool caseSensitive = true}) { return QueryBuilder.apply(this, (query) { return query.addFilterCondition(FilterCondition.matches( property: r'particularName', wildcard: pattern, caseSensitive: caseSensitive, )); }); } QueryBuilder<Particular, Particular, QAfterFilterCondition> particularNameIsEmpty() { return QueryBuilder.apply(this, (query) { return query.addFilterCondition(FilterCondition.equalTo( property: r'particularName', value: '', )); }); } QueryBuilder<Particular, Particular, QAfterFilterCondition> particularNameIsNotEmpty() { return QueryBuilder.apply(this, (query) { return query.addFilterCondition(FilterCondition.greaterThan( property: r'particularName', value: '', )); }); } } extension ParticularQueryObject on QueryBuilder<Particular, Particular, QFilterCondition> {}
0
mirrored_repositories/cash_recorder/lib
mirrored_repositories/cash_recorder/lib/database/database.isar.dart
import 'package:isar/isar.dart'; part 'database.isar.g.dart'; @collection class Bill { Id id = Isar.autoIncrement; final parentBill = IsarLink<Bill>(); late String billName; List<Particular> content = []; } @embedded class Particular { late String particularName; late double amount; late DateTime date; }
0
mirrored_repositories/cash_recorder/lib/core
mirrored_repositories/cash_recorder/lib/core/util/db_ext.dart
import 'package:cash_recorderv2/database/database.isar.dart'; extension Equality on Particular { bool isEqual(Particular particular) { return particularName == particular.particularName && amount == particular.amount && date == particular.date; } } extension ParentString on Bill { String get parentString { Bill? temp = this; String ans = ''; while (temp != null) { ans = '> ${temp.billName} $ans'; temp = temp.parentBill.value; } ans = ans.substring(1); return ans; } }
0
mirrored_repositories/cash_recorder/lib/core
mirrored_repositories/cash_recorder/lib/core/util/format_ext.dart
import 'package:intl/intl.dart'; extension IndianFormat on double { String get indianFormat { final formatter = NumberFormat.simpleCurrency(locale: "en_IN", decimalDigits: 0); return formatter.format(this); } }
0
mirrored_repositories/cash_recorder/lib/core
mirrored_repositories/cash_recorder/lib/core/util/widget_ext.dart
import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; extension DialogExt on Widget { Future<T?> showDialogBlocExt<T extends Cubit>({ required BuildContext context, bool barrierDismissible = false, }) async { return showDialog( context: context, barrierDismissible: barrierDismissible, builder: (context1) => BlocProvider.value( value: context.read<T>(), child: this, ), ); } Future<T?> showDialogExt<T>({ required BuildContext context, bool barrierDismissible = false, }) async { return showDialog( context: context, barrierDismissible: barrierDismissible, builder: (context1) => this, ); } } extension GapBox on int { Widget get hBox => SizedBox(height: this.toDouble()); Widget get wBox => SizedBox(width: this.toDouble()); }
0
mirrored_repositories/cash_recorder/lib/core
mirrored_repositories/cash_recorder/lib/core/util/total_calc_ext.dart
import 'package:cash_recorderv2/database/database.isar.dart'; extension BillListExt on List<Bill> { double get total { return fold<double>( 0, (previousValue, element) => previousValue + element.content.fold( 0, (previousValue, element1) => previousValue + element1.amount, ), ); } } extension ParticularListExt on List<Particular> { double get total { return fold<double>( 0, (previousValue, element) => previousValue + element.amount, ); } }
0
mirrored_repositories/cash_recorder
mirrored_repositories/cash_recorder/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:cash_recorderv2/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/FacebookCloneApp
mirrored_repositories/FacebookCloneApp/lib/main.dart
import 'package:flutter/material.dart'; import 'Screens/home.dart'; void main() { runApp(MyApp()); } class MyApp extends StatelessWidget { @override Widget build(BuildContext context) { return MaterialApp( debugShowCheckedModeBanner: false, home: Home(), ); } }
0
mirrored_repositories/FacebookCloneApp/lib
mirrored_repositories/FacebookCloneApp/lib/Screens/Group.dart
import 'package:flutter/material.dart'; class Group extends StatelessWidget { @override Widget build(BuildContext context) { return Column( children: [ Row( children: [ Text("Group Page"), ], ) ], ); } } class Watch extends StatelessWidget { @override Widget build(BuildContext context) { return Column( children: [ Row( children: [ Text("Watch Page"), ], ) ], ); } } class Account extends StatelessWidget { @override Widget build(BuildContext context) { return Column( children: [ Row( children: [ Text("Accoung Page"), ], ) ], ); } } class Notifications extends StatelessWidget { @override Widget build(BuildContext context) { return Column( children: [ Row( children: [ Text("Notification Page"), ], ) ], ); } } class More extends StatelessWidget { @override Widget build(BuildContext context) { return Container(); } }
0
mirrored_repositories/FacebookCloneApp/lib
mirrored_repositories/FacebookCloneApp/lib/Screens/feed.dart
import 'package:facebook_clone/DATA/Data.dart'; import 'package:flutter/material.dart'; import 'package:font_awesome_flutter/font_awesome_flutter.dart'; import 'package:ionicons/ionicons.dart'; class Feedpage extends StatelessWidget { @override Widget build(BuildContext context) { return Column( children: [ SizedBox( height: 15, ), Padding( padding: const EdgeInsets.symmetric(horizontal: 15.0), child: Container( height: 110, child: Column( children: [ Row( children: [ Image.asset( 'assets/profiles/5.png', width: 55, ), SizedBox( width: 15, ), Expanded( child: TextField( decoration: InputDecoration( labelText: 'What\'s on your mind', labelStyle: TextStyle( color: Colors.black, ), border: OutlineInputBorder( borderRadius: BorderRadius.circular(100), ), contentPadding: EdgeInsets.symmetric(horizontal: 20), ), ), ), ], ), Divider( thickness: 2, ), SizedBox( height: 3, ), Row( mainAxisAlignment: MainAxisAlignment.spaceEvenly, children: [ Row( children: [ Icon( Ionicons.videocam, color: Colors.red, ), SizedBox( width: 5, ), Text( 'Live', style: TextStyle(fontFamily: 'Nunito'), ), ], ), Container( height: 20, width: 2, color: Colors.grey.withOpacity(0.4), ), //2nd Row( children: [ Icon( Icons.photo_album, color: Colors.green, ), SizedBox( width: 5, ), Text( 'Photos', style: TextStyle(fontFamily: 'Nunito'), ), ], ), //3rd Container( height: 20, width: 2, color: Colors.grey.withOpacity(0.4), ), Row( children: [ Icon( Icons.camera_alt_outlined, color: Colors.blue, ), SizedBox( width: 5, ), Text( 'Short Videos', style: TextStyle(fontFamily: 'Nunito'), ), ], ), ], ), ], ), ), ), Container( height: 15, color: Colors.grey[400].withOpacity(0.6), ), Padding( padding: const EdgeInsets.all(8.0), child: Container( height: 230, child: ListView.builder( shrinkWrap: true, itemCount: Data.dataList.length, scrollDirection: Axis.horizontal, itemBuilder: (context, index) => storyCard(index: index), ), ), ), Container( height: 15, color: Colors.grey[400].withOpacity(0.6), ), SizedBox( height: 15, ), Container( //height: 320, // padding: EdgeInsets.all(15.0), child: ListView.builder( physics: NeverScrollableScrollPhysics(), shrinkWrap: true, itemCount: Data.dataList.length, itemBuilder: (context, index) => post(index: index), ), ), ], ); } Widget post({int index}) { return Data.dataList[index].isCreate ? Container() : Container( padding: EdgeInsets.symmetric(vertical: 12), child: Column( children: [ Padding( padding: const EdgeInsets.symmetric(horizontal: 15), child: Row( crossAxisAlignment: CrossAxisAlignment.start, mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Row( children: [ Image.asset( Data.dataList[index].imgPath, width: 40, ), SizedBox( width: 10, ), Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( Data.dataList[index].userName, style: TextStyle( fontWeight: FontWeight.bold, fontSize: 20, ), ), Padding( padding: const EdgeInsets.all(3.0), child: Row( children: [ Text( Data.dataList[index].hour, style: TextStyle( fontSize: 14, color: Colors.grey[700], ), ), SizedBox( width: 10, ), Icon( FontAwesomeIcons.globeAsia, color: Colors.grey[700], size: 20, ), ], ), ), ], ), ], ), Icon( Icons.more_horiz, color: Colors.grey[700], ), ], ), ), SizedBox( height: 15, ), Container( child: Image.asset(Data.dataList[index].postImage), ), Container( height: 50, child: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Row( children: [ SizedBox( width: 10, ), Icon( FontAwesomeIcons.solidThumbsUp, color: Colors.blue[700], size: 20, ), SizedBox( width: 2, ), Icon( FontAwesomeIcons.solidHeart, color: Colors.red, size: 20, ), SizedBox( width: 5, ), Text( '100', style: TextStyle( fontWeight: FontWeight.bold, ), ), ], ), Row( children: [ Text( '10 Comments', style: TextStyle( fontWeight: FontWeight.bold, ), ), SizedBox( width: 10, ), Padding( padding: const EdgeInsets.all(8.0), child: Text( '5 Shares', style: TextStyle( fontWeight: FontWeight.bold, ), ), ), ], ), ], ), ), Divider( thickness: 1, ), Padding( padding: const EdgeInsets.all(8.0), child: Row( mainAxisAlignment: MainAxisAlignment.spaceEvenly, children: [ Row( children: [ Icon(FontAwesomeIcons.thumbsUp), SizedBox( width: 5, ), Text('Like'), ], ), SizedBox( width: 10, ), Row( children: [ Icon(FontAwesomeIcons.comment), SizedBox( width: 5, ), Text('Comment'), ], ), SizedBox( width: 10, ), Row( children: [ Icon(FontAwesomeIcons.share), SizedBox( width: 5, ), Text('Share'), ], ), ], ), ), Divider( thickness: 1, ), ], ), ); } Widget storyCard({int index}) { return Data.dataList[index].isCreate ? Padding( padding: EdgeInsets.all(5), child: Container( width: 130, decoration: BoxDecoration( borderRadius: BorderRadius.circular(20), color: Colors.grey.withOpacity(0.2), border: Border.all( color: Colors.grey.withOpacity(0.7), ), ), child: Stack( children: [ Column( children: [ Container( height: 150, decoration: BoxDecoration( borderRadius: BorderRadius.only( topLeft: Radius.circular(20), topRight: Radius.circular(20)), image: DecorationImage( image: AssetImage(Data.dataList[index].imgPath), fit: BoxFit.cover, ), ), ), SizedBox( height: 14, ), Text( 'Add to Story', textAlign: TextAlign.center, style: TextStyle( color: Colors.black, fontFamily: 'Nunito', fontSize: 17, ), ), ], ), Positioned( top: 10, left: 0, right: 70, child: Center( child: Container( height: 45, width: 45, decoration: BoxDecoration( color: Colors.white.withOpacity(0.6), borderRadius: BorderRadius.circular(100), ), child: Container( child: Container( height: 45, width: 45, decoration: BoxDecoration( color: Colors.white, borderRadius: BorderRadius.circular(100), ), child: Center( child: Icon( Icons.add, color: Colors.blue, size: 30, ), ), ), ), ), ), ), ], ), ), ) : Padding( padding: EdgeInsets.all(5), child: Container( //height: 130, width: 130, decoration: BoxDecoration( color: Colors.blue, borderRadius: BorderRadius.circular(20), image: DecorationImage( image: AssetImage(Data.dataList[index].postImage), fit: BoxFit.cover, ), ), child: Stack( children: [ Container( height: 230, width: 130, decoration: BoxDecoration( borderRadius: BorderRadius.circular(20), gradient: LinearGradient( colors: [ Colors.black.withOpacity(0.5), Colors.transparent, ], begin: FractionalOffset.bottomCenter, end: FractionalOffset.topCenter, ), ), ), Positioned( top: 8, left: 8, child: CircleAvatar( child: Padding( padding: const EdgeInsets.all(2.0), child: Image.asset(Data.dataList[index].imgPath), ), ), ), Positioned( bottom: 8, left: 8, child: Text( Data.dataList[index].userName, style: TextStyle(color: Colors.white, fontFamily: 'Nunito'), ), ), ], ), ), ); } }
0
mirrored_repositories/FacebookCloneApp/lib
mirrored_repositories/FacebookCloneApp/lib/Screens/home.dart
import 'package:facebook_clone/Screens/feed.dart'; import 'package:flutter/material.dart'; import 'package:scroll_app_bar/scroll_app_bar.dart'; import 'package:font_awesome_flutter/font_awesome_flutter.dart'; import 'package:ionicons/ionicons.dart'; import 'Group.dart'; //import 'Group.dart'; class Home extends StatefulWidget { @override _HomeState createState() => _HomeState(); } class _HomeState extends State<Home> with SingleTickerProviderStateMixin { final controller = ScrollController(); TabController tabController; @override void initState() { super.initState(); tabController = TabController(length: 6, vsync: this); } @override Widget build(BuildContext context) { return Scaffold( appBar: ScrollAppBar( controller: controller, backgroundColor: Colors.white, title: Text( 'facebook', style: TextStyle( fontFamily: 'Nunito', color: Colors.blue[700], fontSize: 30, ), ), actions: [ Row( children: [ _appBarAction(FontAwesomeIcons.search), _appBarAction(FontAwesomeIcons.facebookMessenger), ], ) ], ), body: Column( children: [ Container( child: TabBar( controller: tabController, labelPadding: EdgeInsets.all(1), tabs: [ Tab( icon: Icon( Ionicons.home, color: Colors.blue, size: 30, ), ), Tab( icon: Icon( Ionicons.tv_outline, color: Colors.grey[700], size: 30, ), ), Tab( icon: Icon( Ionicons.people_circle_outline, color: Colors.grey[700], size: 30, ), ), Tab( icon: Icon( Icons.house_outlined, color: Colors.grey[700], size: 30, ), ), Tab( icon: Icon( Ionicons.notifications_outline, color: Colors.grey[700], size: 30, ), ), Tab( icon: Icon( Icons.menu, color: Colors.grey[700], size: 30, ), ), ], ), ), Expanded( child: Container( child: TabBarView(controller: tabController, children: [ SingleChildScrollView( controller: controller, child: Feedpage()), Group(), //Home(), Watch(), Account(), Notifications(), More(), ]), ), ), ], ), ); } } Widget _appBarAction(IconData icon) { return Padding( padding: const EdgeInsets.all(8.0), child: Container( decoration: BoxDecoration( borderRadius: BorderRadius.circular(100), color: Colors.grey.withOpacity(0.2), ), child: Padding( padding: const EdgeInsets.all(8.0), child: Icon( icon, color: Colors.black, ), ), ), ); }
0
mirrored_repositories/FacebookCloneApp/lib
mirrored_repositories/FacebookCloneApp/lib/DATA/Data.dart
import 'package:facebook_clone/MODELS/Post.dart'; class Data { static List<Post> dataList = [ Post( userName: '', hour: '', imgPath: 'assets/post/1.jpg', postImage: '', isCreate: true, ), Post( userName: 'Katherine Langford', hour: '2h', imgPath: 'assets/profiles/1.png', postImage: 'assets/post/1.jpg', isCreate: false, ), Post( userName: 'Johnny Depp', hour: '8h', imgPath: 'assets/profiles/2.png', postImage: 'assets/post/2.jpg', isCreate: false, ), Post( userName: 'Vijay Deverkonda', hour: '1h', imgPath: 'assets/profiles/3.png', postImage: 'assets/post/3.jpg', isCreate: false, ), Post( userName: 'Christian Bale', hour: '1min', imgPath: 'assets/profiles/4.png', postImage: 'assets/post/4.jpg', isCreate: false, ), Post( userName: 'Robert Browney Jr', hour: '35min', imgPath: 'assets/profiles/5.png', postImage: 'assets/post/5.jpg', isCreate: false, ), ]; }
0
mirrored_repositories/FacebookCloneApp/lib
mirrored_repositories/FacebookCloneApp/lib/MODELS/Post.dart
class Post { String userName; bool isCreate; String hour; String imgPath; String postImage; Post({this.userName, this.hour, this.imgPath, this.isCreate, this.postImage}); }
0
mirrored_repositories/FacebookCloneApp
mirrored_repositories/FacebookCloneApp/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:facebook_clone/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/inCOV
mirrored_repositories/inCOV/lib/main.dart
import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:shared_preferences/shared_preferences.dart'; import 'model/anim_bloc/anim_bloc.dart'; import './view/main_menu.dart'; import 'model/api_menu_bloc/api_menu_bloc.dart'; void main() async { WidgetsFlutterBinding.ensureInitialized(); SharedPreferences prefs = await SharedPreferences.getInstance(); String tanggalPref = prefs.getString('tanggal') ?? "-"; List totalIndoPref = prefs.getStringList('datatotalindo') ?? ["-", "-", "-", "-"]; List vaksinasiPref = prefs.getStringList('datavaksinasi') ?? ["-", "-", "-", "-", "-", "-", "-"]; runApp(MyApp(tanggalPref, totalIndoPref, vaksinasiPref)); } // ignore: must_be_immutable class MyApp extends StatelessWidget { String tanggalPref; List totalIndoPref; List vaksinasiPref; MyApp(this.tanggalPref, this.totalIndoPref, this.vaksinasiPref); @override Widget build(BuildContext context) { return MultiBlocProvider( providers: [ BlocProvider<SetApiBloc>(create: (context) => SetApiBloc()), BlocProvider<SetAnimBloc>(create: (context) => SetAnimBloc()), BlocProvider<SetAnim2Bloc>(create: (context) => SetAnim2Bloc()), ], child: MaterialApp( title: "inCOV", home: MainMenu(tanggalPref, totalIndoPref, vaksinasiPref), debugShowCheckedModeBanner: false, ), ); } }
0
mirrored_repositories/inCOV/lib
mirrored_repositories/inCOV/lib/view/main_menu.dart
import 'package:flutter/material.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:info_covid/model/api_menu_bloc/api_menu_bloc.dart'; import 'package:info_covid/view/cari_rs/cari_provinsi.dart'; import 'package:info_covid/view/data_covid/dunia.dart'; import 'package:intl/intl.dart'; import 'data_covid/provinsi.dart'; // ignore: must_be_immutable class MainMenu extends StatelessWidget { String tanggalPref; List totalIndoPref; List vaksinasiPref; MainMenu(this.tanggalPref, this.totalIndoPref, this.vaksinasiPref); var formatter = NumberFormat('###,###,###,000'); @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( title: Container( padding: EdgeInsets.fromLTRB(20, 8, 20, 8), decoration: BoxDecoration( borderRadius: BorderRadius.circular(10), color: Colors.white, ), child: Image.asset('assets/images/logo.png', scale: 2), ), backgroundColor: Color(0xffDFF1F3), centerTitle: true, toolbarHeight: 75, elevation: 0, ), body: SingleChildScrollView( child: Container( color: Color(0xFFDFF1F3), child: Padding( padding: const EdgeInsets.fromLTRB(20, 10, 20, 20), child: Column( crossAxisAlignment: CrossAxisAlignment.stretch, children: [ Container( decoration: BoxDecoration( color: Color(0xffb2dfe4), borderRadius: BorderRadius.circular(10), boxShadow: [ BoxShadow( color: Colors.black.withOpacity(0.2), blurRadius: 6, offset: Offset(1, 1), ) ], ), child: Column( mainAxisAlignment: MainAxisAlignment.spaceEvenly, children: [ Container( margin: EdgeInsets.only(top: 7, bottom: 7), child: Row( mainAxisAlignment: MainAxisAlignment.spaceEvenly, children: [ Column( mainAxisAlignment: MainAxisAlignment.spaceAround, crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( "Total Kasus di Indonesia", style: TextStyle( fontSize: 16, fontFamily: "Poppins", ), ), BlocBuilder<SetApiBloc, SetApiState>( builder: (context, state) { return Text( state is SetApiValue ? state.tanggal : tanggalPref, style: TextStyle( fontSize: 16, fontFamily: "Poppins", ), ); }, ), ], ), GestureDetector( onTap: () async { context.read<SetApiBloc>().add(Update()); //Future.delayed(Duration(seconds: 5)); }, child: Icon( Icons.rotate_right, size: 40, ), ), ], ), ), Container( margin: EdgeInsets.only(left: 5, right: 5, bottom: 5), padding: EdgeInsets.all(10), decoration: BoxDecoration( color: Color(0xffffffff), borderRadius: BorderRadius.circular(10), ), child: BlocBuilder<SetApiBloc, SetApiState>( builder: (context, state) { return Column( mainAxisAlignment: MainAxisAlignment.spaceEvenly, children: [ Row( children: [ lineColumn( "Positif", state is SetApiValue ? formatter .format(state.data.positif) .toString() : totalIndoPref[0], Colors.orange, ), lineColumn( "Meninggal", state is SetApiValue ? formatter .format(state.data.meninggal) .toString() : totalIndoPref[1], Colors.red, ), ], ), Row( children: [ lineColumn( "Dirawat", state is SetApiValue ? formatter .format(state.data.dirawat) .toString() : totalIndoPref[2], Color(0xffC35ee5), ), lineColumn( "Sembuh", state is SetApiValue ? formatter .format(state.data.sembuh) .toString() : totalIndoPref[3], Colors.green, ), ], ), ], ); }, ), ), ], ), ), headingTitle("Data Covid Lain"), Container( padding: EdgeInsets.fromLTRB(10, 10, 10, 0), decoration: BoxDecoration( color: Color(0xffb2dfe4), borderRadius: BorderRadius.circular(10), boxShadow: [ BoxShadow( color: Colors.black.withOpacity(0.2), blurRadius: 6, offset: Offset(1, 1), ) ], ), child: Column( mainAxisAlignment: MainAxisAlignment.spaceEvenly, children: [ locCard(context, ProvPage(), "Provinsi", "assets/images/map.jpg", 0), locCard(context, WorldPage(), "Dunia", "assets/images/map-world.jpg", 1), ], ), ), headingTitle("Info Ketersediaan Rumah Sakit"), Container( padding: EdgeInsets.fromLTRB(10, 10, 10, 10), decoration: BoxDecoration( color: Color(0xffb2dfe4), borderRadius: BorderRadius.circular(10), boxShadow: [ BoxShadow( color: Colors.black.withOpacity(0.2), blurRadius: 6, offset: Offset(1, 1), ) ], ), child: getDataLocButton( context, "Cek Disini", () { Navigator.push( context, MaterialPageRoute( builder: (context) => FindByProv())); }, Color(0xffD35045), ), ), headingTitle("Total Vaksinasi"), Container( decoration: BoxDecoration( color: Color(0xffb2dfe4), borderRadius: BorderRadius.circular(10), boxShadow: [ BoxShadow( color: Colors.black.withOpacity(0.2), blurRadius: 6, offset: Offset(1, 1), ) ], ), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ ShaderMask( shaderCallback: (rectangle) { return LinearGradient( colors: [Colors.black, Colors.transparent], begin: Alignment.topCenter, end: Alignment.bottomCenter, ).createShader(Rect.fromLTRB( 0, 0, rectangle.width, rectangle.height)); }, blendMode: BlendMode.dstIn, child: ClipRRect( borderRadius: BorderRadius.circular(10), child: Image.asset('assets/images/vaccine.jpg'), ), ), Container( margin: EdgeInsets.only(top: 5, bottom: 5), child: BlocBuilder<SetApiBloc, SetApiState>( builder: (context, state) { return Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ rowVaksinasi( "Total Sasaran: ", state is SetApiValue ? formatter .format(state.data2.totalSasaran) .toString() : vaksinasiPref[0], ), rowVaksinasi( "Sasaran Vaksin SDMK: ", state is SetApiValue ? formatter .format(state.data2.smdk) .toString() : vaksinasiPref[1], ), rowVaksinasi( "Sasaran Vaksin Lansia: ", state is SetApiValue ? formatter .format(state.data2.lansia) .toString() : vaksinasiPref[2], ), rowVaksinasi( "Sasaran Vaksin Petugas Publik: ", state is SetApiValue ? formatter .format(state.data2.petugasPublik) .toString() : vaksinasiPref[3], ), rowVaksinasi( "Vaksinasi 1: ", state is SetApiValue ? formatter .format(state.data2.vac1) .toString() : vaksinasiPref[4], color: Colors.red.shade800, ), rowVaksinasi( "Vaksinasi 2: ", state is SetApiValue ? formatter .format(state.data2.vac2) .toString() : vaksinasiPref[5], color: Colors.green.shade800, ), rowVaksinasi( "Last Update: ", state is SetApiValue ? state.data2.lastUpdate.toString() : vaksinasiPref[6], ), ], ); }, ), ), ], ), ), ], ), ), ), ), ); } } Expanded lineColumn(String stat, String total, Color color) { return Expanded( child: Column( children: [ Text( stat, style: TextStyle( fontSize: 15, fontFamily: "Poppins", fontWeight: FontWeight.w500, ), ), Text( total, style: TextStyle( fontSize: 17, fontFamily: "Poppins", color: color, fontWeight: FontWeight.w600, ), ), ], ), ); } Padding headingTitle(String title) { return Padding( padding: const EdgeInsets.only(bottom: 15, top: 15), child: Align( alignment: Alignment.centerLeft, child: Text( title, style: TextStyle( fontSize: 16, fontFamily: "Poppins", fontWeight: FontWeight.w600, ), ), ), ); } Container getDataLocButton( BuildContext context, String loc, Function() page, Color color) { return Container( height: 45, child: ElevatedButton( child: Text( loc, style: TextStyle(fontSize: 20), ), onPressed: page, style: ElevatedButton.styleFrom(primary: color), ), ); } Container rowVaksinasi(String info, String total, {color = const Color(0xff000000)}) { return Container( margin: EdgeInsets.fromLTRB(10, 3, 10, 3), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( info, style: TextStyle( fontFamily: "Poppins", fontSize: 16, ), ), Text( total, style: TextStyle( fontFamily: "Poppins", fontSize: 17, color: color, fontWeight: FontWeight.w500, ), ) ], ), ); } Container locCard(BuildContext context, Widget func, String nameLoc, String assetLoc, int index) { return Container( padding: EdgeInsets.only(bottom: 10), child: Material( color: Colors.transparent, child: InkWell( onTap: () { Navigator.push( context, MaterialPageRoute(builder: (context) => func)); }, splashColor: Colors.white, borderRadius: BorderRadius.circular(10), child: Stack( children: [ ShaderMask( shaderCallback: (rectangle) { return LinearGradient( colors: [Colors.white, Colors.transparent], begin: Alignment.topCenter, end: Alignment.bottomCenter, ).createShader( Rect.fromLTRB(0, 0, rectangle.width, rectangle.height)); }, blendMode: BlendMode.dstIn, child: ClipRRect( borderRadius: BorderRadius.circular(10), child: Image.asset(assetLoc), ), ), Container( padding: EdgeInsets.fromLTRB(15, 10, 15, 0), //height: 140, child: Align( alignment: (index == 0) ? Alignment.centerRight : Alignment.centerLeft, child: Column( crossAxisAlignment: (index == 0) ? CrossAxisAlignment.end : CrossAxisAlignment.start, children: [ Text( nameLoc, style: TextStyle( fontFamily: "poppins", color: (index == 0) ? Colors.black : Colors.white, fontWeight: FontWeight.w600, fontSize: 17, ), ), Text( (index == 0) ? "data.covid19.go.id" : 'api.kawalcorona.com', style: TextStyle( fontFamily: "poppins", color: (index == 0) ? Colors.black : Colors.white, fontWeight: FontWeight.w600, fontSize: 15, ), ), ], ), ), ), ], ), ), ), ); } // // ignore: must_be_immutable // class MainMenu extends StatefulWidget { // String tanggalPref; // List totalIndoPref; // List vaksinasiPref; // MainMenu(this.tanggalPref, this.totalIndoPref, this.vaksinasiPref); // @override // _MainMenuState createState() => // _MainMenuState(tanggalPref, totalIndoPref, vaksinasiPref); // } // class _MainMenuState extends State<MainMenu> { // String tanggalPref; // List totalIndoPref; // List vaksinasiPref; // _MainMenuState(this.tanggalPref, this.totalIndoPref, this.vaksinasiPref); // var formatter = NumberFormat('###,###,###,000');
0
mirrored_repositories/inCOV/lib/view
mirrored_repositories/inCOV/lib/view/cari_rs/cari_rs.dart
import 'dart:convert'; import 'package:flutter/material.dart'; import 'package:info_covid/model/connect_api/connect_rs_api.dart'; import 'package:url_launcher/url_launcher.dart'; import 'package:http/http.dart' as http; // ignore: must_be_immutable class FindByKecamatan extends StatefulWidget { String idKecamatan; String idProv; String kecamatan; String prov; FindByKecamatan(this.idKecamatan, this.kecamatan, this.prov, this.idProv); @override _FindByKecamatanState createState() => _FindByKecamatanState(idKecamatan, idProv, kecamatan, prov); } class _FindByKecamatanState extends State<FindByKecamatan> { String idKecamatan; String kecamatan; String idProv; String prov; _FindByKecamatanState( this.idKecamatan, this.idProv, this.kecamatan, this.prov); @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( title: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( kecamatan, style: TextStyle(fontFamily: "Poppins"), ), Text( prov, style: TextStyle(fontFamily: "Poppins", fontSize: 17), ), ], ), backgroundColor: Color(0xff55b9d3), toolbarHeight: 75, ), body: Container( color: Color(0xFFDFF1F3), child: Padding( padding: const EdgeInsets.only(top: 20, left: 20, right: 20), child: Column( children: [ Row( mainAxisAlignment: MainAxisAlignment.spaceEvenly, children: [ Icon( Icons.warning_amber_rounded, size: 50, ), Align( alignment: Alignment.center, child: Text( "Data mungkin terjadi kesalahan\ndikarenakan data pusat sering\nterjadi perubahan!", style: TextStyle(fontSize: 16), ), ), ], ), Divider(), Expanded( child: FutureBuilder( future: RumahSakit.connectToAPI(idProv, idKecamatan), builder: (context, snapshot) { if (snapshot.hasData) { List<RumahSakit> dataRS = snapshot.data as List<RumahSakit>; if (dataRS.length != 0) { return ListView.builder( shrinkWrap: true, itemCount: dataRS.length, itemBuilder: (context, index) { return listRs( context, index, dataRS[index].id, dataRS[index].name, dataRS[index].address, dataRS[index].bedAvailable, dataRS[index].phone, dataRS[index].queue, dataRS[index].info, ); }, ); } else { return Center( child: Text( "Rumah sakit tidak ditemukan", style: TextStyle( fontFamily: "Poppins", fontSize: 18, ), ), ); } } else { return Center( child: CircularProgressIndicator(), ); } }, ), ), ], ), ), ), ); } } Container listRs(BuildContext context, int index, String id, String name, String address, int bedAvail, String phone, int queue, String info) { return Container( margin: EdgeInsets.only(bottom: 15), decoration: BoxDecoration( color: Color(0xffC8E3F4), borderRadius: BorderRadius.circular(10), boxShadow: [ BoxShadow( color: Colors.black.withOpacity(0.5), blurRadius: 6, offset: Offset(0, 5), ), ], ), padding: EdgeInsets.all(10), width: MediaQuery.of(context).size.width, //height: 185, child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( name, style: TextStyle( fontFamily: "Poppins", fontSize: 16, fontWeight: FontWeight.bold, ), ), Row( children: [ Container( margin: EdgeInsets.only(right: 5), child: Icon(Icons.location_on), ), Flexible( child: Text( address, //maxLines: 1, style: TextStyle(fontFamily: "Poppins", fontSize: 15), ), ), ], ), Row( children: [ Container( margin: EdgeInsets.only(right: 5), child: Icon(Icons.local_phone), ), GestureDetector( onTap: () async { await launch('tel:$phone'); }, child: Text( phone + " (Kilk untuk Panggilan)", style: TextStyle(fontFamily: "Poppins", fontSize: 15), ), ), ], ), Row( children: [ Container( margin: EdgeInsets.only(right: 5), child: Icon(Icons.map), ), GestureDetector( onTap: () async { String address = await getAddress(id); launch(address); }, child: Text( "Buka Google Maps", style: TextStyle(fontFamily: "Poppins", fontSize: 15), ), ), ], ), Divider(thickness: 3), Text( "Antrian: " + queue.toString(), style: TextStyle(fontFamily: "Poppins", fontSize: 15), ), Text( "Tempat tidur tersedia: " + bedAvail.toString(), style: TextStyle(fontFamily: "Poppins", fontSize: 15), ), Text( info, style: TextStyle(fontFamily: "Poppins", fontSize: 15), ), ], ), ); } getAddress(String id) async { String apiURL = 'https://rs-bed-covid-api.vercel.app/api/get-hospital-map?hospitalid=$id'; var result = await http.get(Uri.parse(apiURL)); var jsonObject = json.decode(result.body); String address = (jsonObject as Map<String, dynamic>)['data']['gmaps']; return address; }
0
mirrored_repositories/inCOV/lib/view
mirrored_repositories/inCOV/lib/view/cari_rs/cari_provinsi.dart
import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:info_covid/model/anim_bloc/anim_bloc.dart'; import 'package:info_covid/model/connect_api/connect_rs_api.dart'; import 'dart:math' as math; import 'package:info_covid/view/cari_rs/cari_rs.dart'; class FindByProv extends StatefulWidget { const FindByProv({Key? key}) : super(key: key); @override _FindByProvState createState() => _FindByProvState(); } class _FindByProvState extends State<FindByProv> { @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( title: Text( "Info Ketersediaan Rumah Sakit", style: TextStyle(fontFamily: "Poppins"), ), backgroundColor: Color(0xff55b9d3), centerTitle: true, ), body: Container( color: Color(0xFFDFF1F3), child: Padding( padding: const EdgeInsets.only(left: 20, right: 20), child: FutureBuilder( future: ProvinsiRS.connectToAPI(), builder: (context, snapshot) { if (snapshot.hasData) { List<ProvinsiRS> dataProv = snapshot.data as List<ProvinsiRS>; return ListView.builder( itemCount: dataProv.length, itemBuilder: (context, index) { return Column( children: [ listProvRs( context, index, dataProv[index].id, dataProv[index].name, ), ], ); }, ); } else { return Center(child: CircularProgressIndicator()); } }, ), ), ), ); } } Column listProvRs( BuildContext context, int index, String idProv, String nameProv) { return Column( children: [ Container( margin: EdgeInsets.only(top: (index == 0) ? 15 : 0, bottom: 15), padding: EdgeInsets.all(10), width: MediaQuery.of(context).size.width, //height: 100, decoration: BoxDecoration( color: Color(0xff0ABDB6), borderRadius: BorderRadius.circular(10), ), child: Column( children: [ Align( alignment: Alignment.centerLeft, child: Text( nameProv, style: TextStyle( fontFamily: "Poppins", fontSize: 17, color: Colors.white, fontWeight: FontWeight.w500, ), ), ), GestureDetector( onTap: () async { context.read<SetAnim2Bloc>().add(SlideFindProv(idProv)); }, child: Row( mainAxisAlignment: MainAxisAlignment.end, children: [ Text( "Kota/Kabupaten", style: TextStyle( fontFamily: "Poppins", fontSize: 16, color: Colors.white, fontWeight: FontWeight.w500, ), ), Divider(), BlocBuilder<SetAnim2Bloc, SetAnimState>( builder: (context, state) { return AnimatedContainer( duration: Duration(milliseconds: 130), child: Transform.rotate( angle: (state is SetAnim2Value) ? ((state.provId == idProv) ? math.pi : 0) : 0, child: Icon( Icons.arrow_drop_down_circle_outlined, color: Colors.white, size: 30, ), ), ); }, ), ], ), ) ], ), ), BlocBuilder<SetAnim2Bloc, SetAnimState>( builder: (context, state) { return Align( alignment: Alignment.center, child: AnimatedContainer( duration: Duration(milliseconds: 100), margin: EdgeInsets.only(bottom: 15), width: MediaQuery.of(context).size.width * 0.87, decoration: BoxDecoration( color: Color(0xffEAF3DD), borderRadius: BorderRadius.circular(10), boxShadow: [ BoxShadow( blurRadius: 5, //offset: Offset(1, 1), ) ], ), child: (state is SetAnim2Value) ? ((state.provId == idProv) ? FutureBuilder( future: KotaKabRS.connectToAPI(idProv), builder: (context, snapshot) { if (snapshot.hasData) { List<KotaKabRS> dataKotaKab = snapshot.data as List<KotaKabRS>; return ListView.builder( //scrollDirection: Axis.vertical, physics: NeverScrollableScrollPhysics(), shrinkWrap: true, itemCount: dataKotaKab.length, itemBuilder: (context, index) { return Container( padding: EdgeInsets.all(10), child: listKotaKab( context, dataKotaKab[index].id, dataKotaKab[index].name, nameProv, idProv, ), ); }, ); } else { return LinearProgressIndicator( minHeight: 5, ); } }, ) : null) : null, ), ); }, ), ], ); } GestureDetector listKotaKab(BuildContext context, String idKecamatan, String kec, String nameProv, String idProv) { return GestureDetector( onTap: () { Navigator.push( context, MaterialPageRoute( builder: (context) => FindByKecamatan(idKecamatan, kec, nameProv, idProv))); }, child: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Text( kec, style: TextStyle( fontFamily: "Poppins", fontSize: 16, fontWeight: FontWeight.w500, ), ), Transform.rotate( angle: -(math.pi / 2), child: Icon( Icons.arrow_drop_down_circle_outlined, size: 30, ), ), ], ), ); }
0
mirrored_repositories/inCOV/lib/view
mirrored_repositories/inCOV/lib/view/data_covid/provinsi.dart
import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:info_covid/model/anim_bloc/anim_bloc.dart'; import 'package:info_covid/model/connect_api/connect_api.dart'; import 'package:intl/intl.dart'; import 'dart:math' as math; class ProvPage extends StatefulWidget { const ProvPage({Key? key}) : super(key: key); @override _ProvPageState createState() => _ProvPageState(); } class _ProvPageState extends State<ProvPage> { @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( title: Text( "Data Covid Provinsi", style: TextStyle(fontFamily: "Poppins"), ), backgroundColor: Color(0xff55b9d3), centerTitle: true, ), body: Container( color: Color(0xFFDFF1F3), child: Padding( padding: const EdgeInsets.only(left: 20, right: 20), child: FutureBuilder( future: TotalProv.connectToAPI(), builder: (context, snapshot) { if (snapshot.hasData) { List<TotalProv> dataCovid = snapshot.data as List<TotalProv>; return ListView.builder( itemCount: dataCovid.length - 1, itemBuilder: (context, index) { return listCity( context, dataCovid[index].provinsi, dataCovid[index].positif, dataCovid[index].sembuh, dataCovid[index].meninggal, dataCovid[index].dirawat, dataCovid[index].jenisKelamin, dataCovid[index].kelompokUmur, index, ); }, ); } else { return Center(child: CircularProgressIndicator()); } }, ), ), ), ); } } Stack listCity(BuildContext context, String prov, int pos, int sem, int men, int rawat, List jenisKelamin, List kelompokUmur, int indexList) { var formatter = NumberFormat('###,###,###,000'); Map<String, dynamic> jkLk = jenisKelamin[0]; Map<String, dynamic> jkPr = jenisKelamin[1]; Map<String, dynamic> kel1 = kelompokUmur[0]; Map<String, dynamic> kel2 = kelompokUmur[1]; Map<String, dynamic> kel3 = kelompokUmur[2]; Map<String, dynamic> kel4 = kelompokUmur[3]; Map<String, dynamic> kel5 = kelompokUmur[4]; Map<String, dynamic> kel6 = kelompokUmur[5]; return Stack( children: [ BlocBuilder<SetAnimBloc, SetAnimState>( builder: (context, state) { return AnimatedContainer( padding: EdgeInsets.only(bottom: 5), duration: Duration(milliseconds: 125), margin: EdgeInsets.only(top: (indexList == 0) ? 15 : 0, bottom: 15), width: MediaQuery.of(context).size.width, height: (state is SetAnimValue) ? ((state.index == indexList) ? 320 : 175) : 175, decoration: BoxDecoration( borderRadius: BorderRadius.circular(10), border: Border.all(width: 1), color: Color(0xffDBE5CD), boxShadow: [ BoxShadow( color: Colors.black.withOpacity(0.5), blurRadius: 6, //offset: Offset(5, 5), ) ], ), child: (state is SetAnimValue) ? ((state.index == indexList) ? Column( mainAxisAlignment: MainAxisAlignment.end, children: [ Row( mainAxisAlignment: MainAxisAlignment.spaceEvenly, children: [ Column( children: [ Text( "Laki-Laki: ", style: TextStyle( fontFamily: "Poppins", fontWeight: FontWeight.w600, ), ), Text( formatter .format(jkLk['doc_count']) .toString(), style: TextStyle( fontFamily: "Poppins", fontWeight: FontWeight.w600, fontSize: 16, ), ), ], ), Column( children: [ Text( "Perempuan: ", style: TextStyle( fontFamily: "Poppins", fontWeight: FontWeight.w600, ), ), Text( formatter .format(jkPr['doc_count']) .toString(), style: TextStyle( fontFamily: "Poppins", fontWeight: FontWeight.w600, fontSize: 16, ), ), ], ), ], ), Divider(thickness: 3), Row( mainAxisAlignment: MainAxisAlignment.spaceEvenly, children: [ Column( children: [ Text( "Umur 0-5: " + formatter .format(kel1['doc_count']) .toString(), style: TextStyle( fontFamily: "Poppins", fontWeight: FontWeight.w600, ), ), Text( "Umur 6-18: " + formatter .format(kel2['doc_count']) .toString(), style: TextStyle( fontFamily: "Poppins", fontWeight: FontWeight.w600, ), ), Text( "Umur 19-30: " + formatter .format(kel3['doc_count']) .toString(), style: TextStyle( fontFamily: "Poppins", fontWeight: FontWeight.w600, ), ), ], ), Column( children: [ Text( "Umur 31-45: " + formatter .format(kel4['doc_count']) .toString(), style: TextStyle( fontFamily: "Poppins", fontWeight: FontWeight.w600, ), ), Text( "Umur 46-59: " + formatter .format(kel5['doc_count']) .toString(), style: TextStyle( fontFamily: "Poppins", fontWeight: FontWeight.w600, ), ), Text( "Umur >= 60: " + formatter .format(kel6['doc_count']) .toString(), style: TextStyle( fontFamily: "Poppins", fontWeight: FontWeight.w600, ), ), ], ), ], ), ], ) : null) : null, ); }, ), Container( margin: EdgeInsets.only(top: (indexList == 0) ? 15 : 0, bottom: 15), padding: EdgeInsets.all(10), width: MediaQuery.of(context).size.width, height: 175, decoration: BoxDecoration( color: Color(0xff0ABDB6), borderRadius: BorderRadius.circular(10), ), //height: 90, child: Column( mainAxisAlignment: MainAxisAlignment.spaceEvenly, children: [ Text( prov, style: TextStyle( fontFamily: "Poppins", color: Colors.white, fontWeight: FontWeight.w500, fontSize: 16, ), ), Container( margin: EdgeInsets.only(top: 5), padding: EdgeInsets.all(10), decoration: BoxDecoration( color: Color(0xffEBE5E5), borderRadius: BorderRadius.circular(7), ), child: Row( mainAxisAlignment: MainAxisAlignment.spaceEvenly, children: [ Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ dataCovid("Positif: ", Colors.orange, pos), dataCovid("Sembuh: ", Colors.green, sem), dataCovid("Meninggal: ", Colors.red, men), dataCovid("Dirawat: ", Color(0xffC35ee5), rawat), ], ), GestureDetector( onTap: () { context.read<SetAnimBloc>().add(Slide(indexList)); }, child: Container( child: Row( children: [ Text("Info Detail", style: TextStyle( fontFamily: "Poppins", fontSize: 15, )), BlocBuilder<SetAnimBloc, SetAnimState>( builder: (context, state) { return AnimatedContainer( duration: Duration(milliseconds: 130), child: Transform.rotate( angle: (state is SetAnimValue) ? ((state.index == indexList) ? math.pi : 0) : 0, child: Icon( Icons.arrow_drop_down_circle_outlined, size: 30, ), ), ); }, ) ], ), ), ) ], ), ) ], ), ), ], ); } Row dataCovid(String dataName, Color color, int value) { var formatter = NumberFormat('###,###,###,000'); return Row( children: [ Text( dataName, style: TextStyle( fontFamily: "Poppins", //color: Colors.white, fontWeight: FontWeight.w500, fontSize: 15, ), ), Text( formatter.format(value).toString(), style: TextStyle( fontFamily: "Poppins", color: color, fontWeight: FontWeight.w600, fontSize: 16, ), ) ], ); }
0