Git Product home page Git Product logo

hn_app's Introduction

hn_app Build Status

A HackerNews reader app in Flutter.

Development

If the Article API gets changed, you should run:

$ flutter packages pub run build_runner build --delete-conflicting-outputs

FVM

For faster switching between versions of Flutter, this app uses the community tool called fvm.

You don't need to use it, but if you want to, then install the tool and then run everything with fvm (e.g. fvm flutter build). Read the tool's README for more information.

hn_app's People

Contributors

efortuna avatar filiph avatar gamebox avatar iampato avatar mjohnsullivan avatar nosmirck avatar redbrogdon avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

hn_app's Issues

Does BehaviorSubject need to be closed?

New to dart/flutter. I apologize for creating a PR to ask questions.
Are the close() methods of HackerNewsBloc/PrefsBloc ever executed actually?
Regardless, is it necessary to close BehaviorSubjects in this use case?

`build_runner` stuck

I'm at b5cca6d212aa8920bc93c81ac18d213f8348d06f.

I run $ flutter -v pub run build_runner build.

It seems stuck.

[INFO] 2m 6s elapsed, 1/15 actions completed.
[INFO] 2m 7s elapsed, 1/15 actions completed.
[INFO] 2m 8s elapsed, 1/15 actions completed.
[INFO] 2m 9s elapsed, 1/15 actions completed.
[INFO] 2m 10s elapsed, 1/15 actions completed.
[INFO] 2m 11s elapsed, 1/15 actions completed.
[INFO] 2m 12s elapsed, 1/15 actions completed.
[INFO] 2m 13s elapsed, 1/15 actions completed.
[INFO] 2m 14s elapsed, 1/15 actions completed.
[INFO] 2m 15s elapsed, 1/15 actions completed.
[WARNING] No actions completed for 15.1s, waiting on:
  - built_value_generator:built_value on test/json_test.dart
  - built_value_generator:built_value on test/widget_test.dart
  - built_value_generator:built_value on lib/main.dart
  - built_value_generator:built_value on lib/src/article.dart
  - built_value_generator:built_value on lib/src/widgets/search.dart
  .. and 9 more

[INFO] 2m 17s elapsed, 1/15 actions completed.
[INFO] 2m 19s elapsed, 1/15 actions completed.
[INFO] 2m 20s elapsed, 1/15 actions completed.
[INFO] 2m 21s elapsed, 1/15 actions completed.
[INFO] 2m 22s elapsed, 1/15 actions completed.
[INFO] 2m 23s elapsed, 1/15 actions completed.
[INFO] 2m 24s elapsed, 1/15 actions completed.

[Isolate] Null check operator used on a null value

I tried to implement isolate to update firestore database. But I got Null check operator error. Can't firebase use on secondary isolate?

Error

I/flutter ( 9135): [Null check operator used on a null value, #0      MethodChannel.binaryMessenger (package:flutter/src/services/platform_channel.dart:142:86)
I/flutter ( 9135): #1      MethodChannel._invokeMethod (package:flutter/src/services/platform_channel.dart:148:36)
I/flutter ( 9135): #2      MethodChannel.invokeMethod (package:flutter/src/services/platform_channel.dart:331:12)
I/flutter ( 9135): #3      MethodChannel.invokeListMethod (package:flutter/src/services/platform_channel.dart:344:41)
I/flutter ( 9135): #4      MethodChannelFirebase._initializeCore (package:firebase_core_platform_interface/src/method_channel/method_channel_firebase.dart:30:37)
I/flutter ( 9135): #5      MethodChannelFirebase.initializeApp (package:firebase_core_platform_interface/src/method_channel/method_channel_firebase.dart:77:13)
I/flutter ( 9135): #6      Firebase.initializeApp (package:firebase_core/src/firebase.dart:42:47)
I/flutter ( 9135): #7      Worker.readUpdate (package:yello/services/chatMessageService.dart:202:20)
I/flutter ( 9135): #8      Worker._isolateEntry.<anonymous closure> (package:yello/services/chatMessageService.dart:214:15)
I/flutter ( 9135): #9      Worker._isolateEntry.<anon
I/chatty  ( 9135): uid=10206(u0_a206) 1.ui identical 1 line
I/flutter ( 9135): [Null check operator used on a null value, #0      MethodChannel.binaryMessenger (package:flutter/src/services/platform_channel.dart:142:86)
I/flutter ( 9135): #1      MethodChannel._invokeMethod (package:flutter/src/services/platform_channel.dart:148:36)
I/flutter ( 9135): #2      MethodChannel.invokeMethod (package:flutter/src/services/platform_channel.dart:331:12)
I/flutter ( 9135): #3      MethodChannel.invokeListMethod (package:flutter/src/services/platform_channel.dart:344:41)
I/flutter ( 9135): #4      MethodChannelFirebase._initializeCore (package:firebase_core_platform_interface/src/method_channel/method_channel_firebase.dart:30:37)
I/flutter ( 9135): #5      MethodChannelFirebase.initializeApp (package:firebase_core_platform_interface/src/method_channel/method_channel_firebase.dart:77:13)
I/flutter ( 9135): #6      Firebase.initializeApp (package:firebase_core/src/firebase.dart:42:47)
I/flutter ( 9135): #7      Worker.readUpdate (package:yello/services/chatMessageService.dart:202:20)
I/flutter ( 9135): #8      Worker._isolateEntry.<anonymous closure> (package:yello/services/chatMessageService.dart:214:15)
I/flutter ( 9135): #9      Worker._isolateEntry.<anon

Full Code

class Worker {
  SendPort _sendPort;

  Isolate _isolate;

  final _isolateReady = Completer<void>();

  Worker() {
    init();
  }

  Future<void> get isReady => _isolateReady.future;

  void dispose() {
    _isolate.kill();
  }

  Future<void> fetch(ChatModel model) async {
    _sendPort.send(model);
  }

  Future<void> init() async {
    final receivePort = ReceivePort();
    final errorPort = ReceivePort();
    errorPort.listen(print);

    receivePort.listen(_handleMessage);
    _isolate = await Isolate.spawn(
      _isolateEntry,
      receivePort.sendPort,
      onError: errorPort.sendPort,
    );
  }

  void _handleMessage(dynamic message) {
    if (message is SendPort) {
      _sendPort = message;
      _isolateReady.complete();
      return;
    }

    if (message is bool) {
      return;
    }

    throw UnimplementedError("Undefined behavior for message: $message");
  }

  static Future<void> readUpdate(ChatModel model) async {
    await Firebase.initializeApp();
    final FirebaseFirestore _db = FirebaseFirestore.instance;
    return _db.collection('chats').doc(model.chatFieldId).collection('messages').doc(model.messageId).update({'readStatus': 'R'});
  }

  static void _isolateEntry(dynamic message) {
    SendPort sendPort;
    final receivePort = ReceivePort();

    receivePort.listen((dynamic message) async {
      assert(message is ChatModel);
      try {
        await readUpdate(message);
        sendPort.send(true);
      } finally {
        //client.close();
      }
    });

    if (message is SendPort) {
      sendPort = message;
      sendPort.send(receivePort.sendPort);
      return;
    }
  }
}

moor error

Compiler message:
lib/src/favorites.g.dart:137:8: Error: The return type of the method '$FavoritesTable.validateIntegrity' is 'bool', which does not
match the return type, 'VerificationContext', of the overridden method, 'TableInfo.validateIntegrity'.
 - 'VerificationContext' is from 'package:moor/src/runtime/structure/error_handling.dart'
 ('file:///Users/jintian/development/flutter/.pub-cache/hosted/pub.flutter-io.cn/moor-1.5.1/lib/src/runtime/structure/error_handling.d
 art').
Change to a subtype of 'VerificationContext'.
  bool validateIntegrity(Favorite instance, bool isInserting) =>

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.