LCOV - code coverage report
Current view: top level - src - stream_feed_core.dart (source / functions) Hit Total Coverage
Test: lcov.info Lines: 5 10 50.0 %
Date: 2021-09-21 09:01:33 Functions: 0 0 -

          Line data    Source code
       1             : import 'dart:async';
       2             : 
       3             : import 'package:flutter/foundation.dart';
       4             : import 'package:flutter/material.dart';
       5             : import 'package:stream_feed/stream_feed.dart';
       6             : import 'package:stream_feed_flutter_core/src/activities_bloc.dart';
       7             : 
       8             : /// Widget used to provide information about the feed to the widget tree.
       9             : /// This Widget is used to react to life cycle changes and system updates.
      10             : /// When the app goes into the background, the websocket connection is kept
      11             : /// alive for two minutes before being terminated.
      12             : ///
      13             : /// Conversely, when app is resumed or restarted, a new connection is initiated.
      14             : ///
      15             : /// ```dart
      16             : /// class MyApp extends StatelessWidget {
      17             : ///   final StreamFeedClient client;
      18             : ///
      19             : ///   MyApp(this.client);
      20             : ///
      21             : ///   @override
      22             : ///   Widget build(BuildContext context) {
      23             : ///     return MaterialApp(
      24             : ///       home: Container(
      25             : ///         child: StreamFeedCore(
      26             : ///           client: client,
      27             : ///           child: child,
      28             : ///         ),
      29             : ///       ),
      30             : ///     );
      31             : ///   }
      32             : /// }
      33             : /// ```
      34             : ///
      35             : class StreamFeedProvider extends InheritedWidget {
      36             :   /// Constructor used for creating a new instance of [StreamFeedCore].
      37             :   ///
      38             :   /// [StreamFeedCore] is a stateful widget which reacts to system events and
      39             :   /// updates Stream's connection status accordingly.
      40           6 :   StreamFeedProvider({
      41             :     Key? key,
      42             :     required this.client,
      43             :     required Widget child,
      44             :     this.enableAnalytics = false,
      45             :     this.navigatorKey,
      46             :     this.analyticsLocation,
      47             :     this.analyticsClient,
      48           6 :   }) : super(key: key, child: child);
      49             : 
      50             :   /// Instance of Stream Feed Client containing information about the current
      51             :   /// application.
      52             :   final StreamFeedClient client;
      53             : 
      54             :   ///Analytics client
      55             :   final StreamAnalytics? analyticsClient;
      56             : 
      57             :   ///wether or not you want to track analytics in your app (can be useful for customised feeds via ML)
      58             :   final bool enableAnalytics;
      59             : 
      60             :   /// The location that should be used for analytics when liking in the feed,
      61             :   /// this is only useful when you have analytics enabled for your app.
      62             :   final String? analyticsLocation;
      63             : 
      64             :   ///Your navigator key
      65             :   final GlobalKey<NavigatorState>? navigatorKey;
      66             : 
      67             :   /// The current user
      68             :   // StreamUser? get user => client.currentUser;
      69             : 
      70           1 :   static StreamFeedProvider of(BuildContext context) {
      71             :     final StreamFeedProvider? result =
      72           1 :         context.dependOnInheritedWidgetOfExactType<StreamFeedProvider>();
      73           1 :     assert(result != null, 'No StreamFeedProvider found in context');
      74             :     return result!;
      75             :   }
      76             : 
      77           0 :   @override
      78             :   bool updateShouldNotify(StreamFeedProvider old) =>
      79           0 :       navigatorKey != old.navigatorKey ||
      80           0 :       analyticsClient != old.analyticsClient ||
      81           0 :       analyticsLocation != old.analyticsLocation ||
      82           0 :       enableAnalytics != old.enableAnalytics;
      83             : }

Generated by: LCOV version 1.15