Skip to content

Commit

Permalink
fix dart errors and warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
mmalkindi committed Dec 1, 2023
1 parent 6df114d commit 9de753c
Show file tree
Hide file tree
Showing 13 changed files with 65 additions and 68 deletions.
50 changes: 25 additions & 25 deletions lib/catalog/models/book.dart
Original file line number Diff line number Diff line change
@@ -1,29 +1,29 @@
import 'dart:ffi';

// sekedar buat test

// ignore_for_file: non_constant_identifier_names

class Book {
int isbn13;
String title;
String authors;
String categories;
String thumbnail;
String description;
int published_year;
int page_count;
int overall_rating; //sementara int dulu, gatau kenapa kalo pake Float dia tu parameternya error
int favorites_count;
int isbn13;
String title;
String authors;
String categories;
String thumbnail;
String description;
int published_year;
int page_count;
int overall_rating; //sementara int dulu, gatau kenapa kalo pake Float dia tu parameternya error
int favorites_count;

Book(
this.isbn13,
this.title,
this.authors,
this.categories,
this.thumbnail,
this.description,
this.published_year,
this.page_count,
this.overall_rating,
this.favorites_count,
);
}
Book(
this.isbn13,
this.title,
this.authors,
this.categories,
this.thumbnail,
this.description,
this.published_year,
this.page_count,
this.overall_rating,
this.favorites_count,
);
}
2 changes: 1 addition & 1 deletion lib/catalog/screens/catalog_home.dart
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class CatalogHome extends StatefulWidget {
const CatalogHome({Key? key}) : super(key: key);

@override
_CatalogHomeState createState() => _CatalogHomeState();
State<CatalogHome> createState() => _CatalogHomeState();
}

class _CatalogHomeState extends State<CatalogHome> {
Expand Down
8 changes: 4 additions & 4 deletions lib/catalog/screens/detail_book.dart
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class DetailBookPage extends StatelessWidget {
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Center(
child: Container(
child: SizedBox(
width: 200,
child: AspectRatio(
aspectRatio: AppData().bookAspectRatio,
Expand All @@ -46,7 +46,7 @@ class DetailBookPage extends StatelessWidget {
),
const SizedBox(height: 15.0),
Text(
'Authors: ${book.authors.split(';').map((author) => "$author").join(', ')}',
'Authors: ${book.authors.split(';').map((author) => author).join(', ')}',
style: const TextStyle(fontSize: 18.0),
),
const SizedBox(height: 15.0),
Expand Down Expand Up @@ -85,9 +85,9 @@ class DetailBookPage extends StatelessWidget {
),
),
const SizedBox(height: 15.0),
Text(
const Text(
'Description:',
style: const TextStyle(fontSize: 18.0),
style: TextStyle(fontSize: 18.0),
),
const SizedBox(height: 8.0),
Text(
Expand Down
8 changes: 4 additions & 4 deletions lib/catalog/widgets/book_tile.dart
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class BookTile extends StatelessWidget {
padding: const EdgeInsets.all(15.0),
child: Row(
children: [
Container(
SizedBox(
width: 70,
child: AspectRatio(
aspectRatio: AppData().bookAspectRatio,
Expand All @@ -33,17 +33,17 @@ class BookTile extends StatelessWidget {
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
"${book.title}",
book.title,
style: const TextStyle(
fontSize: 18.0,
fontWeight: FontWeight.bold,
),
),
const SizedBox(height: 10),
Text(
"by ${book.authors.split(';').map((author) => "$author").join(', ')}"),
"by ${book.authors.split(';').map((author) => author).join(', ')}"),
const SizedBox(height: 10),
Text("${book.categories}"),
Text(book.categories),
],
),
))
Expand Down
2 changes: 0 additions & 2 deletions lib/library/models/librarybook.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
import 'dart:convert';

class LibraryBook {}
2 changes: 1 addition & 1 deletion lib/library/screens/library_add.dart
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@ class _LibraryAddFormState extends State<LibraryAddForm> {
Widget build(BuildContext context) {
final request = context.watch<CookieRequest>();

return Scaffold();
return const Scaffold();
}
}
2 changes: 1 addition & 1 deletion lib/library/screens/library_detail.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import 'package:flutter/material.dart';
import 'package:letterbookd/library/models/librarybook.dart';
// import 'package:letterbookd/library/models/librarybook.dart';
import 'package:letterbookd/library/widgets/library_detail_actions.dart';
import 'package:letterbookd/library/widgets/library_detail_header.dart';

Expand Down
2 changes: 1 addition & 1 deletion lib/library/screens/library_home.dart
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ class LibraryHome extends StatelessWidget {
childAspectRatio: AppData().bookAspectRatio,
crossAxisCount: 3,
),
itemCount: 18,
itemCount: 12,
itemBuilder: (context, index) {
return const LibraryTile();
}),
Expand Down
17 changes: 9 additions & 8 deletions lib/reader/screens/reader_home.dart
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class ReaderHome extends StatelessWidget {
padding: const EdgeInsets.all(16.0),
child: ListView(
children: [
Center(
const Center(
child: CircleAvatar(
radius: 50,
backgroundImage: AssetImage('assets/images/pfp_0.jpg'),
Expand All @@ -30,7 +30,7 @@ class ReaderHome extends StatelessWidget {
_buildUserInfoCard('Username', reader['username']!),
_buildUserInfoCard('Name', reader['name']!),
_buildUserInfoCard('Bio', reader['bio']!),
SizedBox(height: 16),
const SizedBox(height: 16),
ElevatedButton(
onPressed: () {
Navigator.push(
Expand All @@ -42,13 +42,13 @@ class ReaderHome extends StatelessWidget {
style: Theme.of(context).elevatedButtonTheme.style,
child: const Text('Edit Profile'),
),
SizedBox(height: 24),
const SizedBox(height: 24),
const Text(
'Library',
style: TextStyle(fontSize: 22, fontWeight: FontWeight.bold),
),
_buildGridSection(4), // Library cards
SizedBox(height: 24),
const SizedBox(height: 24),
const Text(
'Review',
style: TextStyle(fontSize: 22, fontWeight: FontWeight.bold),
Expand All @@ -62,20 +62,21 @@ class ReaderHome extends StatelessWidget {

Widget _buildUserInfoCard(String title, String content) {
return Card(
margin: EdgeInsets.symmetric(vertical: 8.0),
margin: const EdgeInsets.symmetric(vertical: 8.0),
child: ListTile(
title: Text(title),
subtitle: Text(content),
contentPadding: EdgeInsets.symmetric(horizontal: 16.0, vertical: 10.0),
contentPadding:
const EdgeInsets.symmetric(horizontal: 16.0, vertical: 10.0),
),
);
}

Widget _buildGridSection(int itemCount) {
return GridView.builder(
shrinkWrap: true,
physics: NeverScrollableScrollPhysics(),
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
physics: const NeverScrollableScrollPhysics(),
gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: 2,
crossAxisSpacing: 10,
mainAxisSpacing: 10,
Expand Down
4 changes: 2 additions & 2 deletions lib/reader/screens/reader_settings.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ class EditProfileScreen extends StatefulWidget {
const EditProfileScreen({Key? key}) : super(key: key);

@override
_EditProfileScreenState createState() => _EditProfileScreenState();
State<EditProfileScreen> createState() => _EditProfileScreenState();
}

class _EditProfileScreenState extends State<EditProfileScreen> {
Expand Down Expand Up @@ -37,7 +37,7 @@ class _EditProfileScreenState extends State<EditProfileScreen> {
setState(() => shareReviews = newValue);
},
),
SizedBox(height: 20),
const SizedBox(height: 20),
ElevatedButton(
onPressed: () {
Navigator.pop(context);
Expand Down
26 changes: 13 additions & 13 deletions lib/review/models/review.dart
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
// ignore_for_file: non_constant_identifier_names

class Review{
int stars_rating;
int total_rating;
String status_on_review;
String review_text;
class Review {
int stars_rating;
int total_rating;
String status_on_review;
String review_text;


Review(
this.stars_rating,
this.total_rating,
this.status_on_review,
this.review_text,
);
}
Review(
this.stars_rating,
this.total_rating,
this.status_on_review,
this.review_text,
);
}
8 changes: 3 additions & 5 deletions lib/review/screens/review_add.dart
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import 'dart:convert';
// import 'dart:convert';
import 'package:flutter/material.dart';
import 'package:pbp_django_auth/pbp_django_auth.dart';
import 'package:provider/provider.dart';


class ShopFormPage extends StatefulWidget {
const ShopFormPage({super.key});

Expand Down Expand Up @@ -113,8 +112,7 @@ class _ShopFormPageState extends State<ShopFormPage> {
padding: const EdgeInsets.all(8.0),
child: ElevatedButton(
style: ButtonStyle(
backgroundColor:
MaterialStateProperty.all(Colors.indigo),
backgroundColor: MaterialStateProperty.all(Colors.indigo),
),
onPressed: () {
if (_formKey.currentState!.validate()) {}
Expand All @@ -131,4 +129,4 @@ class _ShopFormPageState extends State<ShopFormPage> {
),
);
}
}
}
2 changes: 1 addition & 1 deletion lib/review/screens/review_home.dart
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ class ReviewItem {
class ReviewCard extends StatelessWidget {
final ReviewItem item;

const ReviewCard(this.item);
const ReviewCard(this.item, {super.key});

@override
Widget build(BuildContext context) {
Expand Down

0 comments on commit 9de753c

Please sign in to comment.