Skip to content

Commit

Permalink
refactor: update widget constructors to use 'super.key' syntax and im…
Browse files Browse the repository at this point in the history
…prove code structure
  • Loading branch information
nitin-787 committed Dec 25, 2024
1 parent 6fa736f commit 5428c8c
Show file tree
Hide file tree
Showing 45 changed files with 860 additions and 477 deletions.
34 changes: 17 additions & 17 deletions .metadata
Original file line number Diff line number Diff line change
@@ -1,38 +1,38 @@
# 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.
# This file should be version controlled and should not be manually edited.

version:
revision: f1875d570e39de09040c8f79aa13cc56baab8db1
channel: stable
revision: "17025dd88227cd9532c33fa78f5250d548d87e9a"
channel: "stable"

project_type: app

# Tracks metadata for the flutter migrate command
migration:
platforms:
- platform: root
create_revision: f1875d570e39de09040c8f79aa13cc56baab8db1
base_revision: f1875d570e39de09040c8f79aa13cc56baab8db1
create_revision: 17025dd88227cd9532c33fa78f5250d548d87e9a
base_revision: 17025dd88227cd9532c33fa78f5250d548d87e9a
- platform: android
create_revision: f1875d570e39de09040c8f79aa13cc56baab8db1
base_revision: f1875d570e39de09040c8f79aa13cc56baab8db1
create_revision: 17025dd88227cd9532c33fa78f5250d548d87e9a
base_revision: 17025dd88227cd9532c33fa78f5250d548d87e9a
- platform: ios
create_revision: f1875d570e39de09040c8f79aa13cc56baab8db1
base_revision: f1875d570e39de09040c8f79aa13cc56baab8db1
create_revision: 17025dd88227cd9532c33fa78f5250d548d87e9a
base_revision: 17025dd88227cd9532c33fa78f5250d548d87e9a
- platform: linux
create_revision: f1875d570e39de09040c8f79aa13cc56baab8db1
base_revision: f1875d570e39de09040c8f79aa13cc56baab8db1
create_revision: 17025dd88227cd9532c33fa78f5250d548d87e9a
base_revision: 17025dd88227cd9532c33fa78f5250d548d87e9a
- platform: macos
create_revision: f1875d570e39de09040c8f79aa13cc56baab8db1
base_revision: f1875d570e39de09040c8f79aa13cc56baab8db1
create_revision: 17025dd88227cd9532c33fa78f5250d548d87e9a
base_revision: 17025dd88227cd9532c33fa78f5250d548d87e9a
- platform: web
create_revision: f1875d570e39de09040c8f79aa13cc56baab8db1
base_revision: f1875d570e39de09040c8f79aa13cc56baab8db1
create_revision: 17025dd88227cd9532c33fa78f5250d548d87e9a
base_revision: 17025dd88227cd9532c33fa78f5250d548d87e9a
- platform: windows
create_revision: f1875d570e39de09040c8f79aa13cc56baab8db1
base_revision: f1875d570e39de09040c8f79aa13cc56baab8db1
create_revision: 17025dd88227cd9532c33fa78f5250d548d87e9a
base_revision: 17025dd88227cd9532c33fa78f5250d548d87e9a

# User provided section

Expand Down
3 changes: 2 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{
"java.configuration.updateBuildConfiguration": "automatic"
"java.configuration.updateBuildConfiguration": "automatic",
"cmake.ignoreCMakeListsMissing": true
}
19 changes: 8 additions & 11 deletions android/app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
plugins {
id "com.android.application"
id "kotlin-android"
id "dev.flutter.flutter-gradle-plugin"
}

def localProperties = new Properties()
def localPropertiesFile = rootProject.file('local.properties')
if (localPropertiesFile.exists()) {
Expand All @@ -6,11 +12,6 @@ if (localPropertiesFile.exists()) {
}
}

def flutterRoot = localProperties.getProperty('flutter.sdk')
if (flutterRoot == null) {
throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.")
}

def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
if (flutterVersionCode == null) {
flutterVersionCode = '1'
Expand All @@ -24,14 +25,11 @@ if (flutterVersionName == null) {


apply plugin : 'com.google.gms.google-services'
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"



android {
compileSdkVersion 33
compileSdkVersion 34
ndkVersion flutter.ndkVersion

compileOptions {
Expand All @@ -44,7 +42,7 @@ android {
applicationId "com.nitin.mynotes"
// You can update the following values to match your application needs.
// For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-build-configuration.
minSdkVersion 28
minSdkVersion 21
targetSdkVersion flutter.targetSdkVersion
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
Expand All @@ -64,7 +62,6 @@ flutter {
}

dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
implementation platform('com.google.firebase:firebase-bom:30.4.1')
implementation("com.squareup.okhttp3:okhttp:4.9.3")
implementation 'com.google.firebase:firebase-analytics'
Expand Down
5 changes: 5 additions & 0 deletions android/app/src/main/kotlin/com/nitin/mynotes/MainActivity.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package com.nitin.mynotes

import io.flutter.embedding.android.FlutterActivity

class MainActivity: FlutterActivity()
Binary file added android/app/src/main/res/mipmap-hdpi/ic_launcher.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added android/app/src/main/res/mipmap-mdpi/ic_launcher.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
18 changes: 18 additions & 0 deletions android/app/src/main/res/values-night/styles.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<!-- Theme applied to the Android Window while the process is starting when the OS's Dark Mode setting is on -->
<style name="LaunchTheme" parent="@android:style/Theme.Black.NoTitleBar">
<!-- Show a splash screen on the activity. Automatically removed when
the Flutter engine draws its first frame -->
<item name="android:windowBackground">@drawable/launch_background</item>
</style>
<!-- Theme applied to the Android Window as soon as the process has started.
This theme determines the color of the Android Window while your
Flutter UI initializes, as well as behind your Flutter UI while its
running.
This Theme is only used starting with V2 of Flutter's Android embedding. -->
<style name="NormalTheme" parent="@android:style/Theme.Black.NoTitleBar">
<item name="android:windowBackground">?android:colorBackground</item>
</style>
</resources>
18 changes: 5 additions & 13 deletions android/build.gradle
Original file line number Diff line number Diff line change
@@ -1,17 +1,9 @@
buildscript {
ext.kotlin_version = '1.6.10'
repositories {
google()
mavenCentral()
}

dependencies {
classpath 'com.android.tools.build:gradle:7.1.2'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath 'com.google.gms:google-services:4.3.13'
}
dependencies {
classpath "com.android.tools.build:gradle:8.1.2"
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.7.10"
}


allprojects {
repositories {
google()
Expand All @@ -29,4 +21,4 @@ subprojects {

tasks.register("clean", Delete) {
delete rootProject.buildDir
}
}
2 changes: 1 addition & 1 deletion android/gradle.properties
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
org.gradle.jvmargs=-Xmx1536M
android.useAndroidX=true
android.enableJetifier=true
android.enableJetifier=true
2 changes: 1 addition & 1 deletion android/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.2.1-all.zip
23 changes: 13 additions & 10 deletions android/settings.gradle
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
include ':app'
pluginManagement {
repositories {
gradlePluginPortal()
google()
mavenCentral()
}
plugins {
id "com.android.application" version "8.1.2" apply false
id "org.jetbrains.kotlin.android" version "1.7.10" apply false
id "dev.flutter.flutter-plugin-loader" version "1.0.0"
}
}

def localPropertiesFile = new File(rootProject.projectDir, "local.properties")
def properties = new Properties()

assert localPropertiesFile.exists()
localPropertiesFile.withReader("UTF-8") { reader -> properties.load(reader) }

def flutterSdkPath = properties.getProperty("flutter.sdk")
assert flutterSdkPath != null, "flutter.sdk not set in local.properties"
apply from: "$flutterSdkPath/packages/flutter_tools/gradle/app_plugin_loader.gradle"
include ":app"
12 changes: 12 additions & 0 deletions ios/RunnerTests/RunnerTests.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import Flutter
import UIKit
import XCTest

class RunnerTests: XCTestCase {

func testExample() {
// If you add code to the Runner application, consider adding tests here.
// See https://developer.apple.com/documentation/xctest for more information about using XCTest.
}

}
8 changes: 4 additions & 4 deletions lib/helper/loading/shimmer_loading.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import '/constants/colors.dart';

class SkeletonNotes extends StatelessWidget {
const SkeletonNotes({
Key? key,
}) : super(key: key);
super.key,
});

@override
Widget build(BuildContext context) {
Expand Down Expand Up @@ -131,10 +131,10 @@ class ShimmerWidget extends StatelessWidget {

class Skeleton extends StatelessWidget {
const Skeleton({
Key? key,
super.key,
required this.height,
required this.width,
}) : super(key: key);
});

final double? height, width;
@override
Expand Down
2 changes: 1 addition & 1 deletion lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ void main() {
}

class HomePage extends StatelessWidget {
const HomePage({Key? key}) : super(key: key);
const HomePage({super.key});

@override
Widget build(BuildContext context) {
Expand Down
29 changes: 13 additions & 16 deletions lib/services/auth/bloc/auth_state.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ abstract class AuthState {
}

class AuthStateUnitialized extends AuthState {
const AuthStateUnitialized({required bool isLoading})
: super(isLoading: isLoading);
const AuthStateUnitialized({required super.isLoading});
}

class AuthStateRegistering extends AuthState {
final Exception? exception;
// ignore: use_super_parameters
const AuthStateRegistering({
required this.exception,
required isLoading,
Expand All @@ -32,40 +32,37 @@ class AuthStateForgotPassword extends AuthState {
const AuthStateForgotPassword({
required this.exception,
required this.hasSentEmail,
required bool isLoading,
}) : super(isLoading: isLoading);
required super.isLoading,
});
}

class AuthStateLoggedIn extends AuthState {
final AuthUser user;
const AuthStateLoggedIn({
required this.user,
required bool isLoading,
}) : super(isLoading: isLoading);
required super.isLoading,
});
}

class AuthStateLoggedInWithGmail extends AuthState {
const AuthStateLoggedInWithGmail({
required bool isLoading,
}) : super(isLoading: isLoading);
required super.isLoading,
});
}

class AuthStateNeedsVerification extends AuthState {
const AuthStateNeedsVerification({
required bool isLoading,
}) : super(isLoading: isLoading);
required super.isLoading,
});
}

class AuthStateLoggedOut extends AuthState with EquatableMixin {
final Exception? exception;
const AuthStateLoggedOut({
required this.exception,
required bool isLoading,
String? loadingText,
}) : super(
isLoading: isLoading,
loadingText: loadingText,
);
required super.isLoading,
super.loadingText = null,
});

@override
List<Object?> get props => [exception, isLoading];
Expand Down
3 changes: 1 addition & 2 deletions lib/views/forgot_password_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import '/utilities/dialogs/error_dialog.dart';
import '/utilities/dialogs/password_reset.dart';

class ForgotPasswordView extends StatefulWidget {
const ForgotPasswordView({Key? key}) : super(key: key);
const ForgotPasswordView({super.key});

@override
State<ForgotPasswordView> createState() => _ForgotPasswordViewState();
Expand Down Expand Up @@ -43,7 +43,6 @@ class _ForgotPasswordViewState extends State<ForgotPasswordView> {
await showPasswordResetSentDialog(context);
}
if (state.exception != null) {
if (!mounted) return;
await showErrorDialog(
context,
context.loc.forgot_password_view_generic_error,
Expand Down
14 changes: 7 additions & 7 deletions lib/views/home/home.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import '/constants/colors.dart';
import '/constants/routes.dart';
import '/services/auth/bloc/auth_event.dart';
import '/utilities/internet_snak_bar.dart';
import '/views/login_view.dart';
import '/widget/slider.dart';
import '/services/auth/bloc/auth_bloc.dart';

Expand All @@ -32,13 +31,14 @@ class _NewNotesViewState extends State<NewNotesView> {
borderRadius: BorderRadius.circular(30),
),
onPressed: () async {
final result = await Connectivity().checkConnectivity();
if (!mounted) return;
bool hasInternet = connectivitySnackBar(result);

hasInternet
? Navigator.of(context).pushNamed(createOrUpdateNoteRoute)
: InternetSnackBar.showTopSnackBar(context);
var connectivityResult = await (Connectivity().checkConnectivity());
if (connectivityResult == ConnectivityResult.none) {
InternetSnackBar.showTopSnackBar(context);
return;
} else {
Navigator.pushNamed(context, createOrUpdateNoteRoute);
}
},
child: Icon(
Icons.add,
Expand Down
Loading

0 comments on commit 5428c8c

Please sign in to comment.