Skip to content

Commit

Permalink
Merge pull request #108 from flutterturkey/null-safety
Browse files Browse the repository at this point in the history
Null safety
  • Loading branch information
bgoktugozdemir-dev committed Mar 4, 2022
2 parents ef86be7 + 7352069 commit 44257fc
Show file tree
Hide file tree
Showing 51 changed files with 1,369 additions and 622 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -82,3 +82,4 @@ unlinked_spec.ds
!/packages/flutter_tools/test/data/dart_dependencies_test/**/.packages
# Web
web/index.html
node_modules
19 changes: 8 additions & 11 deletions lib/activity_flow/activity_flow_view.dart
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
import 'package:flutter/material.dart';

import 'package:festival_flutterturkiye_org/activity_flow/activity_flow_widget.dart';
import 'package:festival_flutterturkiye_org/core/model/activity_flow.dart';
import 'package:festival_flutterturkiye_org/core/ui/section_title.dart';
import 'package:festival_flutterturkiye_org/core/utils/theme_helper.dart';
import 'package:festival_flutterturkiye_org/activity_flow/activity_flow_widget.dart';
import 'package:flutter/material.dart';

class ActivityFlowView extends StatelessWidget {
const ActivityFlowView({
@required this.activityFlowList,
Key key,
}) : assert(activityFlowList != null),
super(key: key);
required this.activityFlowList,
Key? key,
}) : super(key: key);

final List<ActivityFlow> activityFlowList;

Expand Down Expand Up @@ -38,10 +36,9 @@ class ActivityFlowView extends StatelessWidget {

class _ActivityFlowListView extends StatelessWidget {
const _ActivityFlowListView({
@required this.activityFlowList,
Key key,
}) : assert(activityFlowList != null),
super(key: key);
required this.activityFlowList,
Key? key,
}) : super(key: key);

final List<ActivityFlow> activityFlowList;

Expand Down
74 changes: 29 additions & 45 deletions lib/activity_flow/activity_flow_widget.dart
Original file line number Diff line number Diff line change
@@ -1,23 +1,16 @@
import 'package:festival_flutterturkiye_org/core/utils/assets.dart';
import 'package:flutter/material.dart';

import 'package:festival_flutterturkiye_org/core/utils/image_assets.dart';
import 'package:festival_flutterturkiye_org/core/utils/theme_helper.dart';
import 'package:flutter/material.dart';

class ActivityFlowWidget extends StatelessWidget {
const ActivityFlowWidget({
@required this.title,
@required this.subtitle,
@required this.iconPath,
@required this.index,
@required this.isLastIndex,
Key key,
}) : assert(title != null),
assert(subtitle != null),
assert(iconPath != null),
assert(index != null),
assert(isLastIndex != null),
super(key: key);
required this.title,
required this.subtitle,
required this.iconPath,
required this.index,
required this.isLastIndex,
Key? key,
}) : super(key: key);

final String title;
final String subtitle;
Expand Down Expand Up @@ -50,14 +43,11 @@ class ActivityFlowWidget extends StatelessWidget {

class _BuildRowHeader extends StatelessWidget {
const _BuildRowHeader({
@required this.iconPath,
@required this.index,
@required this.isLastIndex,
Key key,
}) : assert(iconPath != null),
assert(index != null),
assert(isLastIndex != null),
super(key: key);
required this.iconPath,
required this.index,
required this.isLastIndex,
Key? key,
}) : super(key: key);

final String iconPath;
final int index;
Expand All @@ -80,12 +70,10 @@ class _BuildRowHeader extends StatelessWidget {

class _ActivityFlowTitle extends StatelessWidget {
const _ActivityFlowTitle({
@required this.title,
required this.title,
this.isTitle = true,
Key key,
}) : assert(title != null),
assert(isTitle != null),
super(key: key);
Key? key,
}) : super(key: key);

final String title;
final bool isTitle;
Expand All @@ -110,10 +98,9 @@ class _ActivityFlowTitle extends StatelessWidget {

class _ActivityFlowIcon extends StatelessWidget {
const _ActivityFlowIcon({
@required this.iconPath,
Key key,
}) : assert(iconPath != null),
super(key: key);
required this.iconPath,
Key? key,
}) : super(key: key);

final String iconPath;

Expand All @@ -127,12 +114,10 @@ class _ActivityFlowIcon extends StatelessWidget {

class _ActivityFlowLineIndicatorBuilder extends StatelessWidget {
const _ActivityFlowLineIndicatorBuilder({
@required this.index,
@required this.isLastIndex,
Key key,
}) : assert(index != null),
assert(isLastIndex != null),
super(key: key);
required this.index,
required this.isLastIndex,
Key? key,
}) : super(key: key);

final int index;
final bool isLastIndex;
Expand All @@ -142,12 +127,12 @@ class _ActivityFlowLineIndicatorBuilder extends StatelessWidget {
if (isLastIndex) {
return const SizedBox.shrink();
} else if (index.isEven) {
return _ActivityFlowLineIndicator(
'${const ImageAsset(ImageAssets.lineIndicatorTop)}',
return const _ActivityFlowLineIndicator(
ImageAssets.lineIndicatorTop,
);
} else if (index.isOdd) {
return _ActivityFlowLineIndicator(
'${const ImageAsset(ImageAssets.lineIndicatorBottom)}',
return const _ActivityFlowLineIndicator(
ImageAssets.lineIndicatorBottom,
);
} else {
return const SizedBox.shrink();
Expand All @@ -158,9 +143,8 @@ class _ActivityFlowLineIndicatorBuilder extends StatelessWidget {
class _ActivityFlowLineIndicator extends StatelessWidget {
const _ActivityFlowLineIndicator(
this.assetsPath, {
Key key,
}) : assert(assetsPath != null),
super(key: key);
Key? key,
}) : super(key: key);

final String assetsPath;

Expand Down
3 changes: 1 addition & 2 deletions lib/core/logic/database_repository.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@ import 'package:flutter/foundation.dart';

abstract class DatabaseRepository<DatabaseModel> {
DatabaseRepository(String collection)
: assert(collection != null),
_collection = collection,
: _collection = collection,
_firestore = FirebaseFirestore.instance;

/// Firebase Collection Name
Expand Down
4 changes: 1 addition & 3 deletions lib/core/logic/faq_repository.dart
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,7 @@ class FaqRepository extends DatabaseRepository<FAQ> {
for (final documentSnapshot in querySnapshot.docs) {
final faq = FAQ.fromSnapshot(documentSnapshot);

if (faq != null) {
_faqs.add(faq);
}
_faqs.add(faq);
}
return _faqs;
}
Expand Down
4 changes: 1 addition & 3 deletions lib/core/logic/session_repository.dart
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,7 @@ class SessionRepository extends DatabaseRepository<Session> {
for (final documentSnapshot in querySnapshot.docs) {
final session = Session.fromSnapshot(documentSnapshot);

if (session != null) {
_sessions.add(session);
}
_sessions.add(session);
}
return _sessions;
}
Expand Down
4 changes: 1 addition & 3 deletions lib/core/logic/speaker_repository.dart
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,7 @@ class SpeakerRepository extends DatabaseRepository<Speaker> {
for (final documentSnapshot in querySnapshot.docs) {
final speaker = Speaker.fromSnapshot(documentSnapshot);

if (speaker != null) {
_speakers.add(speaker);
}
_speakers.add(speaker);
}
return _speakers;
}
Expand Down
4 changes: 1 addition & 3 deletions lib/core/logic/sponsor_repository.dart
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,7 @@ class SponsorRepository extends DatabaseRepository<Sponsor> {
for (final documentSnapshot in querySnapshot.docs) {
final sponsor = Sponsor.fromSnapshot(documentSnapshot);

if (sponsor != null) {
_sponsors.add(sponsor);
}
_sponsors.add(sponsor);
}
return _sponsors;
}
Expand Down
4 changes: 1 addition & 3 deletions lib/core/model/activity_flow.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,7 @@ class ActivityFlow extends Equatable {
this.title,
this.subtitle,
this.iconPath,
) : assert(title != null),
assert(subtitle != null),
assert(iconPath != null);
);

final String title;
final String subtitle;
Expand Down
14 changes: 5 additions & 9 deletions lib/core/model/calendar.dart
Original file line number Diff line number Diff line change
@@ -1,16 +1,12 @@
import 'package:equatable/equatable.dart';
import 'package:flutter/material.dart';

class Calendar extends Equatable {
const Calendar({
@required this.title,
@required this.description,
@required this.startingTime,
@required this.endingTime,
}) : assert(title != null),
assert(description != null),
assert(startingTime != null),
assert(endingTime != null);
required this.title,
required this.description,
required this.startingTime,
required this.endingTime,
});

final String title;
final String description;
Expand Down
13 changes: 5 additions & 8 deletions lib/core/model/navigation_action.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,12 @@ import 'package:flutter/material.dart';

class NavigationAction extends Equatable {
const NavigationAction({
@required this.title,
@required this.icon,
@required this.focusNode,
required this.onPressed,
required this.title,
required this.icon,
required this.focusNode,
this.isFilled = false,
this.onPressed,
}) : assert(title != null),
assert(icon != null),
assert(focusNode != null),
assert(isFilled != null);
});

final String title;
final IconData icon;
Expand Down
37 changes: 16 additions & 21 deletions lib/core/model/session.dart
Original file line number Diff line number Diff line change
@@ -1,25 +1,20 @@
import 'package:cloud_firestore/cloud_firestore.dart';
import 'package:meta/meta.dart';

import 'package:festival_flutterturkiye_org/core/model/database_model.dart';

enum SessionStatus { waiting, active, passed }

class Session extends DatabaseModel {
const Session({
@required this.title,
@required this.startingTime,
@required this.endingTime,
@required this.presentation,
@required this.reference,
this.title,
this.startingTime,
this.endingTime,
this.presentation,
this.reference,
this.speakers,
}) : assert(title != null),
assert(startingTime != null),
assert(endingTime != null),
assert(reference != null);
});

factory Session.fromSnapshot(DocumentSnapshot snapshot) {
final data = snapshot.data();
final data = snapshot.data() as Map<String, dynamic>;
return Session(
reference: snapshot.reference,
speakers: data['speakers'] != null
Expand All @@ -34,19 +29,19 @@ class Session extends DatabaseModel {
);
}

final String title;
final DateTime startingTime;
final DateTime endingTime;
final List<DocumentReference> speakers;
final String presentation;
final DocumentReference reference;
final String? title;
final DateTime? startingTime;
final DateTime? endingTime;
final List<DocumentReference>? speakers;
final String? presentation;
final DocumentReference? reference;

SessionStatus get status {
final currentDate = DateTime.now();
final isStarted = currentDate.compareTo(startingTime);
final isStarted = currentDate.compareTo(startingTime!);

if (isStarted >= 0) {
final isEnded = currentDate.compareTo(endingTime);
final isEnded = currentDate.compareTo(endingTime!);

if (isEnded < 0) {
return SessionStatus.active;
Expand All @@ -58,7 +53,7 @@ class Session extends DatabaseModel {
}

@override
List<Object> get props => [
List<Object?> get props => [
title,
startingTime,
endingTime,
Expand Down
Loading

0 comments on commit 44257fc

Please sign in to comment.