Skip to content

Instantly share code, notes, and snippets.

View mariopepe's full-sized avatar

Mario Pepe mariopepe

View GitHub Profile
@mariopepe
mariopepe / squircle.dart
Created February 14, 2022 00:42 — forked from slightfoot/squircle.dart
Flutter Squircle Shape
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return new MaterialApp(
title: 'Squircle',
home: new Scaffold(
@mariopepe
mariopepe / posts_list_page.dart
Created January 23, 2022 15:27
posts_list_page.dart
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:functional_error_handling/features/post/presentation/widgets/custom_list_tile.dart';
import 'package:functional_error_handling/features/post/presentation/widgets/error_dialog.dart';
import 'bloc/posts_list.dart';
class PostPage extends StatelessWidget {
const PostPage({Key? key}) : super(key: key);
@mariopepe
mariopepe / posts_list_bloc.dart
Last active January 23, 2022 15:26
posts_list_bloc.dart
import 'package:bloc/bloc.dart';
import 'package:dartz/dartz.dart';
import 'package:freezed_annotation/freezed_annotation.dart';
import 'package:functional_error_handling/core/error_handling/error_handling.dart';
import 'package:functional_error_handling/features/post/domain/entities/post_entity.dart';
import 'package:functional_error_handling/features/post/domain/repositories/posts_repository.dart';
part 'posts_list.freezed.dart';
@mariopepe
mariopepe / posts_repository_impl.dart
Created January 23, 2022 15:22
posts_repository_impl.dart
import 'package:dartz/dartz.dart';
import 'package:http/http.dart' as http;
import 'package:functional_error_handling/core/error_handling/error_handling.dart';
import 'package:functional_error_handling/features/post/data/datasources/json_placeholder_v1.dart';
import 'package:functional_error_handling/features/post/domain/entities/post_entity.dart';
import 'package:functional_error_handling/features/post/domain/repositories/posts_repository.dart';
class PostsRepositoryImpl implements PostsRepository {
@override
@mariopepe
mariopepe / json_placeholder_v1.dart
Created January 23, 2022 15:21
json_placeholder_v1.dart
import 'dart:convert';
import 'package:functional_error_handling/core/error_handling/error_handling.dart';
import 'package:functional_error_handling/features/post/data/models/post_model.dart';
import 'package:http/http.dart' as http;
class JsonPlaceholderV1 {
JsonPlaceholderV1({
required this.httpClient,
});
@mariopepe
mariopepe / error_object.dart
Created January 23, 2022 15:16
error_object.dart
import 'package:equatable/equatable.dart';
import 'failures.dart';
class ErrorObject extends Equatable {
const ErrorObject({
required this.title,
required this.message,
});
@mariopepe
mariopepe / failures.dart
Created January 23, 2022 15:14
failures.dart
import 'package:freezed_annotation/freezed_annotation.dart';
part 'failures.freezed.dart';
@freezed
class FailureEntity with _$FailureEntity {
const FailureEntity._(); // This constructor is needed to have custom methods in Freezed.
const factory FailureEntity.serverFailure() = ServerFailure;
const factory FailureEntity.dataParsingFailure() = DataParsingFailure;
const factory FailureEntity.noConnectionFailure() = NoConnectionFailure;
@mariopepe
mariopepe / exceptions.dart
Created January 23, 2022 15:13
exceptions.dart
class ServerException implements Exception {}
class DataParsingException implements Exception {}
class NoConnectionException implements Exception {}
@mariopepe
mariopepe / main.dart
Created April 1, 2020 14:33
Class exploration in Dart - skinny dude section 2 up until video 25
/// Main
void main() {
final personOne = Person(name: "Mario", age: 23, height: 1.83);
print(personOne.describePerson());
final employeeOne = Employee(
name: "Mario",
age: 23,
height: 1.83,
@mariopepe
mariopepe / 05ListOverlap.py
Created January 21, 2017 14:06
05 List Overlap
# and write a program that returns a list that contains only the elements that are common between the
# lists (without duplicates). Make sure your program works on two lists of different sizes.
# exercise from http://www.practicepython.org/exercise/2014/03/05/05-list-overlap.html
a = [1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89]
b = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]
c = []
# Create list c
for num in a: