Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create server using dart frog #2

Open
wants to merge 9 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,5 @@ app.*.map.json
/android/app/release

*.env
*.vscode
.git-blame-ignore-revs
2 changes: 1 addition & 1 deletion ios/Flutter/AppFrameworkInfo.plist
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@
<key>CFBundleVersion</key>
<string>1.0</string>
<key>MinimumOSVersion</key>
<string>11.0</string>
<string>12.0</string>
</dict>
</plist>
2 changes: 1 addition & 1 deletion ios/Podfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Uncomment this line to define a global platform for your project
# platform :ios, '11.0'
# platform :ios, '12.0'

# CocoaPods analytics sends network stats synchronously affecting flutter build latency.
ENV['COCOAPODS_DISABLE_STATS'] = 'true'
Expand Down
6 changes: 3 additions & 3 deletions ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,13 @@ EXTERNAL SOURCES:

SPEC CHECKSUMS:
app_links: 5ef33d0d295a89d9d16bb81b0e3b0d5f70d6c875
Flutter: f04841e97a9d0b0a8025694d0796dd46242b2854
Flutter: e0871f40cf51350855a761d2e70bf5af5b9b5de7
path_provider_foundation: 29f094ae23ebbca9d3d0cec13889cd9060c0e943
shared_preferences_foundation: 5b919d13b803cadd15ed2dc053125c68730e5126
sign_in_with_apple: f3bf75217ea4c2c8b91823f225d70230119b8440
url_launcher_ios: bf5ce03e0e2088bad9cc378ea97fa0ed5b49673b
webview_flutter_wkwebview: 2e2d318f21a5e036e2c3f26171342e95908bd60a

PODFILE CHECKSUM: 70d9d25280d0dd177a5f637cdb0f0b0b12c6a189
PODFILE CHECKSUM: 819463e6a0290f5a72f145ba7cde16e8b6ef0796

COCOAPODS: 1.12.1
COCOAPODS: 1.14.3
1 change: 1 addition & 0 deletions lib/services/api_client.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
class ApiClient {}
29 changes: 29 additions & 0 deletions packages/models/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Miscellaneous
*.class
*.log
*.pyc
*.swp
.DS_Store
.atom/
.buildlog/
.history
.svn/
migrate_working_dir/

# IntelliJ related
*.iml
*.ipr
*.iws
.idea/

# The .vscode folder contains launch configuration and tasks you configure in
# VS Code which you may wish to be included in version control, so this line
# is commented out by default.
#.vscode/

# Flutter/Dart/Pub related
# Libraries should not include pubspec.lock, per https://dart.dev/guides/libraries/private-files#pubspeclock.
/pubspec.lock
**/doc/api/
.dart_tool/
build/
10 changes: 10 additions & 0 deletions packages/models/.metadata
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# This file tracks properties of this Flutter project.
# Used by Flutter tool to assess capabilities and perform upgrades etc.
#
# This file should be version controlled and should not be manually edited.

version:
revision: "41456452f29d64e8deb623a3c927524bcf9f111b"
channel: "stable"

project_type: package
3 changes: 3 additions & 0 deletions packages/models/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
## 0.0.1

* TODO: Describe initial release.
1 change: 1 addition & 0 deletions packages/models/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
TODO: Add your license here.
39 changes: 39 additions & 0 deletions packages/models/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<!--
This README describes the package. If you publish this package to pub.dev,
this README's contents appear on the landing page for your package.
For information about how to write a good package README, see the guide for
[writing package pages](https://dart.dev/guides/libraries/writing-package-pages).
For general information about developing packages, see the Dart guide for
[creating packages](https://dart.dev/guides/libraries/create-library-packages)
and the Flutter guide for
[developing packages and plugins](https://flutter.dev/developing-packages).
-->

TODO: Put a short description of the package here that helps potential users
know whether this package might be useful for them.

## Features

TODO: List what your package can do. Maybe include images, gifs, or videos.

## Getting started

TODO: List prerequisites and provide or point to information on how to
start using the package.

## Usage

TODO: Include short and useful examples for package users. Add longer examples
to `/example` folder.

```dart
const like = 'sample';
```

## Additional information

TODO: Tell users more about the package: where to find more information, how to
contribute to the package, how to file issues, what response they can expect
from the package authors, and more.
4 changes: 4 additions & 0 deletions packages/models/analysis_options.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
include: package:flutter_lints/flutter.yaml

# Additional information about this file can be found at
# https://dart.dev/guides/language/analysis-options
3 changes: 3 additions & 0 deletions packages/models/lib/models.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
library models;

export 'src/models.dart';
48 changes: 48 additions & 0 deletions packages/models/lib/src/category.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import 'package:equatable/equatable.dart';

import 'category_item.dart';

class Category extends Equatable {
final int id;
final String name;
final List<CategoryItem> categoryItems;
const Category({
required this.categoryItems,
required this.name,
required this.id,
});

Category copy({
String? name,
List<CategoryItem>? categoryItems,
int? id,
}) =>
Category(
id: id ?? this.id,
name: name ?? this.name,
categoryItems: categoryItems ?? this.categoryItems,
);

Map<String, dynamic> toJson() => {
'id': id,
'name': name,
'categories': categoryItems,
};

factory Category.fromJson(Map<String, dynamic> json) {
var jsonCategoryItems = json['category_items'];
return Category(
id: json['id'],
name: json['name'],
categoryItems: (jsonCategoryItems is List)
? jsonCategoryItems
.map<CategoryItem>(
(categoryItem) => CategoryItem.fromJson(categoryItem))
.toList()
: <CategoryItem>[],
);
}

@override
List<Object?> get props => [id, name, categoryItems];
}
41 changes: 41 additions & 0 deletions packages/models/lib/src/category_item.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import 'package:equatable/equatable.dart';

class CategoryItem extends Equatable {
final int id;
final int categoryId;
final String name;
final bool checked;
const CategoryItem({
required this.name,
this.checked = false,
required this.id,
required this.categoryId,
});

CategoryItem copy({String? name, bool? checked, int? id, int? categoryId}) =>
CategoryItem(
id: id ?? this.id,
categoryId: categoryId ?? this.categoryId,
name: name ?? this.name,
checked: checked ?? this.checked,
);

Map<String, dynamic> toJson() => {
'id': id,
'category_id': categoryId,
'name': name,
'checked': checked,
};

factory CategoryItem.fromJson(Map<String, dynamic> json) {
return CategoryItem(
id: json['id'],
categoryId: json['category_id'],
name: json['name'],
checked: json['checked'],
);
}

@override
List<Object?> get props => [id, categoryId, name, checked];
}
3 changes: 3 additions & 0 deletions packages/models/lib/src/models.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export 'category.dart';
export 'category_item.dart';
export 'user.dart';
40 changes: 40 additions & 0 deletions packages/models/lib/src/user.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import 'package:equatable/equatable.dart';

class User extends Equatable {
final String id;
final String firstName;
final String lastName;
const User({
required this.id,
required this.firstName,
required this.lastName,
});

User copy({
String? id,
String? firstName,
String? lastName,
}) =>
User(
id: id ?? this.id,
firstName: firstName ?? this.firstName,
lastName: lastName ?? this.lastName,
);

Map<String, dynamic> toJson() => {
'id': id,
'first_name': firstName,
'last_name': lastName,
};

factory User.fromJson(Map<String, dynamic> json) {
return User(
id: json['id'],
firstName: json['first_name'],
lastName: json['last_name'],
);
}

@override
List<Object?> get props => [id, firstName, lastName];
}
55 changes: 55 additions & 0 deletions packages/models/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
name: models
description: "A new Flutter package project."
version: 0.0.1
homepage:

environment:
sdk: '>=3.2.6 <4.0.0'
flutter: ">=1.17.0"

dependencies:
flutter:
sdk: flutter
equatable: ^2.0.0

dev_dependencies:
flutter_test:
sdk: flutter
flutter_lints: ^2.0.0

# For information on the generic Dart part of this file, see the
# following page: https://dart.dev/tools/pub/pubspec

# The following section is specific to Flutter packages.
flutter:

# To add assets to your package, add an assets section, like this:
# assets:
# - images/a_dot_burr.jpeg
# - images/a_dot_ham.jpeg
#
# For details regarding assets in packages, see
# https://flutter.dev/assets-and-images/#from-packages
#
# An image asset can refer to one or more resolution-specific "variants", see
# https://flutter.dev/assets-and-images/#resolution-aware

# To add custom fonts to your package, add a fonts section here,
# in this "flutter" section. Each entry in this list should have a
# "family" key with the font family name, and a "fonts" key with a
# list giving the asset and other descriptors for the font. For
# example:
# fonts:
# - family: Schyler
# fonts:
# - asset: fonts/Schyler-Regular.ttf
# - asset: fonts/Schyler-Italic.ttf
# style: italic
# - family: Trajan Pro
# fonts:
# - asset: fonts/TrajanPro.ttf
# - asset: fonts/TrajanPro_Bold.ttf
# weight: 700
#
# For details regarding fonts in packages, see
# https://flutter.dev/custom-fonts/#from-packages
12 changes: 12 additions & 0 deletions packages/models/test/models_test.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import 'package:flutter_test/flutter_test.dart';

import 'package:models/models.dart';

// void main() {
// test('adds one to input values', () {
// final calculator = Calculator();
// expect(calculator.addOne(2), 3);
// expect(calculator.addOne(-7), -6);
// expect(calculator.addOne(0), 1);
// });
// }
Loading