Skip to content

Commit

Permalink
⬆ update flutter
Browse files Browse the repository at this point in the history
  • Loading branch information
Shadow60539 committed Apr 23, 2023
2 parents 6ecc43a + 4ced01b commit 70fd177
Show file tree
Hide file tree
Showing 8 changed files with 303 additions and 186 deletions.
26 changes: 23 additions & 3 deletions .metadata
@@ -1,10 +1,30 @@
# 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.
# This file should be version controlled.

version:
revision: d79295af24c3ed621c33713ecda14ad196fd9c31
channel: unknown
revision: 4d9e56e694b656610ab87fcf2efbcd226e0ed8cf
channel: stable

project_type: app

# Tracks metadata for the flutter migrate command
migration:
platforms:
- platform: root
create_revision: 4d9e56e694b656610ab87fcf2efbcd226e0ed8cf
base_revision: 4d9e56e694b656610ab87fcf2efbcd226e0ed8cf
- platform: android
create_revision: 4d9e56e694b656610ab87fcf2efbcd226e0ed8cf
base_revision: 4d9e56e694b656610ab87fcf2efbcd226e0ed8cf

# User provided section

# List of Local paths (relative to this file) that should be
# ignored by the migrate tool.
#
# Files that are not part of the templates will be ignored by default.
unmanaged_files:
- 'lib/main.dart'
- 'ios/Runner.xcodeproj/project.pbxproj'
29 changes: 29 additions & 0 deletions analysis_options.yaml
@@ -0,0 +1,29 @@
# This file configures the analyzer, which statically analyzes Dart code to
# check for errors, warnings, and lints.
#
# The issues identified by the analyzer are surfaced in the UI of Dart-enabled
# IDEs (https://dart.dev/tools#ides-and-editors). The analyzer can also be
# invoked from the command line by running `flutter analyze`.

# The following line activates a set of recommended lints for Flutter apps,
# packages, and plugins designed to encourage good coding practices.
include: package:flutter_lints/flutter.yaml

linter:
# The lint rules applied to this project can be customized in the
# section below to disable rules from the `package:flutter_lints/flutter.yaml`
# included above or to enable additional rules. A list of all available lints
# and their documentation is published at
# https://dart-lang.github.io/linter/lints/index.html.
#
# Instead of disabling a lint rule for the entire project in the
# section below, it can also be suppressed for a single line of code
# or a specific dart file by using the `// ignore: name_of_lint` and
# `// ignore_for_file: name_of_lint` syntax on the line or in the file
# producing the lint.
rules:
# avoid_print: false # Uncomment to disable the `avoid_print` rule
# prefer_single_quotes: true # Uncomment to enable the `prefer_single_quotes` rule

# Additional information about this file can be found at
# https://dart.dev/guides/language/analysis-options
2 changes: 1 addition & 1 deletion android/app/build.gradle
Expand Up @@ -26,7 +26,7 @@ apply plugin: 'kotlin-android'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"

android {
compileSdkVersion 31
compileSdkVersion 33

sourceSets {
main.java.srcDirs += 'src/main/kotlin'
Expand Down
2 changes: 1 addition & 1 deletion android/build.gradle
Expand Up @@ -6,7 +6,7 @@ buildscript {
}

dependencies {
classpath 'com.android.tools.build:gradle:4.1.0'
classpath 'com.android.tools.build:gradle:7.4.2'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
Expand Down
3 changes: 1 addition & 2 deletions android/gradle/wrapper/gradle-wrapper.properties
@@ -1,6 +1,5 @@
#Fri Jun 23 08:50:38 CEST 2017
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.7-all.zip
32 changes: 15 additions & 17 deletions lib/bloc/preload_bloc.dart
Expand Up @@ -2,7 +2,6 @@ import 'dart:async';
import 'dart:developer';

import 'package:bloc/bloc.dart';
import 'package:flutter_preload_videos/injection.dart';
import 'package:flutter_preload_videos/service/api_service.dart';
import 'package:flutter_preload_videos/core/constants.dart';
import 'package:flutter_preload_videos/main.dart';
Expand All @@ -17,17 +16,16 @@ part 'preload_state.dart';
@injectable
@prod
class PreloadBloc extends Bloc<PreloadEvent, PreloadState> {
PreloadBloc() : super(PreloadState.initial());

@override
Stream<PreloadState> mapEventToState(
PreloadEvent event,
) async* {
yield* event.map(
setLoading: (e) async* {
yield state.copyWith(isLoading: true);
PreloadBloc() : super(PreloadState.initial()) {
on(_mapEventToState);
}

void _mapEventToState(PreloadEvent event, Emitter<PreloadState> emit) async {
await event.map(
setLoading: (e) {
emit(state.copyWith(isLoading: true));
},
getVideosFromApi: (e) async* {
getVideosFromApi: (e) async {
/// Fetch first 5 videos from api
final List<String> _urls = await ApiService.getVideos();
state.urls.addAll(_urls);
Expand All @@ -41,10 +39,10 @@ class PreloadBloc extends Bloc<PreloadEvent, PreloadState> {
/// Initialize 2nd video
await _initializeControllerAtIndex(1);

yield state.copyWith(reloadCounter: state.reloadCounter + 1);
emit(state.copyWith(reloadCounter: state.reloadCounter + 1));
},
// initialize: (e) async* {},
onVideoIndexChanged: (e) async* {
onVideoIndexChanged: (e) {
/// Condition to fetch new videos
final bool shouldFetch = (e.index + kPreloadLimit) % kNextLimit == 0 &&
state.urls.length == e.index + kPreloadLimit;
Expand All @@ -60,17 +58,17 @@ class PreloadBloc extends Bloc<PreloadEvent, PreloadState> {
_playPrevious(e.index);
}

yield state.copyWith(focusedIndex: e.index);
emit(state.copyWith(focusedIndex: e.index));
},
updateUrls: (e) async* {
updateUrls: (e) {
/// Add new urls to current urls
state.urls.addAll(e.urls);

/// Initialize new url
_initializeControllerAtIndex(state.focusedIndex + 1);

yield state.copyWith(
reloadCounter: state.reloadCounter + 1, isLoading: false);
emit(state.copyWith(
reloadCounter: state.reloadCounter + 1, isLoading: false));
log('πŸš€πŸš€πŸš€ NEW VIDEOS ADDED');
},
);
Expand Down

0 comments on commit 70fd177

Please sign in to comment.