Skip to content

Instantly share code, notes, and snippets.

View VB10's full-sized avatar
🏠
Working from home

Veli Bacik VB10

🏠
Working from home
View GitHub Profile
@VB10
VB10 / settings.json
Last active December 22, 2024 23:11
My IDE setting json for general (cursor-vscode)
{
"dart.lineLength": 80,
"docwriter.hotkey.mac": "⌥ + .",
"editor.formatOnSave": true,
"editor.formatOnPaste": true,
"editor.fontFamily": "JetBrains Mono",
"explorer.fileNesting.patterns": {
"pubspec.yaml": ".flutter-plugins, .packages, .dart_tool, .flutter-plugins-dependencies, .metadata, .packages, pubspec.lock, build.yaml, analysis_options.yaml, all_lint_rules.yaml",
".gitignore": ".gitattributes, .gitmodules, .gitmessage, .mailmap, .git-blame*",
"readme.*": "authors, backers.md, changelog*, citation*, code_of_conduct.md, codeowners, contributing.md, contributors, copying, credits, governance.md, history.md, license*, maintainers, readme*, security.md, sponsors.md",
@VB10
VB10 / main.dart
Created April 5, 2022 09:45
Upload product to firebase
import 'package:http/http.dart' as http;
import 'dart:convert';
void main() {
addProduct(Product(description: 'vb10',
id: '123',
imageUrl: 'vb.png',
isFavorite: true,
price: '1200',
title: 'Solution'
@VB10
VB10 / base_firebase_model.dart
Last active January 8, 2022 16:20
Firebase Service Helper
class BaseFirebaseModel<T> {
final String id;
final T? data;
BaseFirebaseModel({
required this.id,
required this.data,
});
}
@VB10
VB10 / pubspec.yaml
Last active January 2, 2022 12:24
Start project yaml for flutter
name: vb10
description: A new Flutter project.
publish_to: "none" # Remove this line if you wish to publish to pub.dev
version: 1.0.0+1
environment:
sdk: ">=2.15.0 <3.0.0"
dependencies:
class User {
final String firstName;
User(this.firstName);
static List<User> dummyUsers() {
return [
User('veli'),
User('bora'),
];
{
Future<void> controlUser(String email, String password) async {
if (!_changeValidateModel()) return;
_changeLoading();
final response = await loginService.controlUser(model: LoginRequestModel(email: email, password: password));
_changeLoading();
await keepLocalUserResponse(response);
_navigatePage(response);
}
Scaffold(
appBar: AppBar(backgroundColor: Colors.transparent, elevation: 0, systemOverlayStyle: SystemUiOverlayStyle.dark),
body: Padding(
padding: context.paddingMedium,
child: Form(
key: formValidateKey,
autovalidateMode: isAutoValidate ? AutovalidateMode.always : AutovalidateMode.disabled,
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
class UserView2 extends StatelessWidget {
const UserView2({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return BlocProvider<UserCubit2>(
create: (context) => UserCubit2(context, userService: FirebaseUserSerivice()),
child: BlocConsumer<UserCubit2, UserState2>(
listener: (context, state) {
if (state.response != null) {
import 'dart:async';
import 'package:flutter/material.dart';
import 'package:lottie/lottie.dart';
class NotiferChanges<T> {
final StreamController<T> _fetchDoneController = StreamController.broadcast();
changeNavigate(T data) {
_fetchDoneController.add(data); // send an arbitrary event
class SearchField extends StatefulWidget {
final void Function(String value) onChanged;
const SearchField({Key? key, required this.onChanged}) : super(key: key);
@override
_SearchFieldState createState() => _SearchFieldState();
}
class _SearchFieldState extends State<SearchField> {
late CancelableOperation<void> cancellableOperation;