1+ import 'dart:io' ;
12import 'package:flutter/material.dart' ;
23import 'package:stream_feed_flutter_core/stream_feed_flutter_core.dart' ;
34
@@ -24,41 +25,74 @@ Future<void> main() async {
2425 );
2526
2627 runApp (
27- MaterialApp (
28+ MyApp (client: client),
29+ );
30+ }
31+
32+ class MyApp extends StatelessWidget {
33+ const MyApp ({
34+ Key ? key,
35+ required this .client,
36+ }) : super (key: key);
37+
38+ final StreamFeedClient client;
39+
40+ @override
41+ Widget build (BuildContext context) {
42+ return MaterialApp (
2843 builder: (context, child) => FeedProvider (
2944 bloc: FeedBloc (
3045 client: client,
3146 ),
3247 child: child! ,
3348 ),
34- home: Scaffold (
35- body: FlatFeedCore (
36- feedGroup: 'user' ,
37- userId: client.currentUser! .id,
38- feedBuilder: (BuildContext context, activities, int index) {
39- return InkWell (
40- child: ListTile (
41- title: Text ('${activities [index ].actor !.data !['handle' ]}' ),
42- subtitle: Text ('${activities [index ].object }' ),
43- ),
44- onTap: () {
45- Navigator .of (context).push (
46- MaterialPageRoute <void >(
47- builder: (BuildContext context) => Scaffold (
48- body: ReactionListCore (
49- lookupValue: activities[index].id! ,
50- reactionsBuilder: (context, reactions, idx) => Text (
51- '${reactions [index ].data ?['text' ]}' ,
52- ),
49+ home: HomePage (client: client),
50+ );
51+ }
52+ }
53+
54+ class HomePage extends StatefulWidget {
55+ const HomePage ({
56+ Key ? key,
57+ required this .client,
58+ }) : super (key: key);
59+
60+ final StreamFeedClient client;
61+
62+ @override
63+ State <HomePage > createState () => _HomePageState ();
64+ }
65+
66+ class _HomePageState extends State <HomePage > {
67+ @override
68+ Widget build (BuildContext context) {
69+ return Scaffold (
70+ body: FlatFeedCore (
71+ feedGroup: 'user' ,
72+ userId: widget.client.currentUser! .id,
73+ feedBuilder: (BuildContext context, activities, int index) {
74+ return InkWell (
75+ child: ListTile (
76+ title: Text ('${activities [index ].actor !.data !['handle' ]}' ),
77+ subtitle: Text ('${activities [index ].object }' ),
78+ ),
79+ onTap: () {
80+ Navigator .of (context).push (
81+ MaterialPageRoute <void >(
82+ builder: (BuildContext context) => Scaffold (
83+ body: ReactionListCore (
84+ lookupValue: activities[index].id! ,
85+ reactionsBuilder: (context, reactions, idx) => Text (
86+ '${reactions [index ].data ?['text' ]}' ,
5387 ),
5488 ),
5589 ),
56- );
57- },
58- );
59- },
60- ) ,
90+ ),
91+ );
92+ },
93+ );
94+ } ,
6195 ),
62- ),
63- );
96+ );
97+ }
6498}
0 commit comments