This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'dart:async'; | |
import 'dart:convert'; | |
import 'package:meta/meta.dart'; | |
import 'package:rxdart/rxdart.dart'; | |
import 'package:http/http.dart' as http; | |
import 'package:bloc/bloc.dart'; | |
import 'package:flutter_infinite_list/bloc/bloc.dart'; | |
import 'package:flutter_infinite_list/models/models.dart'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'package:flutter/material.dart'; | |
void main() { | |
runApp(MyApp()); | |
} | |
class MyApp extends StatelessWidget { | |
@override | |
Widget build(BuildContext context) { | |
return MaterialApp( |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class HomePage extends StatefulWidget { | |
@override | |
_HomePageState createState() => _HomePageState(); | |
} | |
class _HomePageState extends State<HomePage> { | |
final _scrollController = ScrollController(); | |
final PostBloc _postBloc = PostBloc(httpClient: http.Client()); | |
final _scrollThreshold = 200.0; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class BottomLoader extends StatelessWidget { | |
@override | |
Widget build(BuildContext context) { | |
return Container( | |
alignment: Alignment.center, | |
child: Center( | |
child: SizedBox( | |
width: 33, | |
height: 33, | |
child: CircularProgressIndicator( |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class PostWidget extends StatelessWidget { | |
final Post post; | |
const PostWidget({Key key, @required this.post}) : super(key: key); | |
@override | |
Widget build(BuildContext context) { | |
return ListTile( | |
leading: Text( | |
post.id.toString(), |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'package:bloc/bloc.dart'; | |
class SimpleBlocDelegate extends BlocDelegate { | |
@override | |
void onTransition(Bloc bloc, Transition transition) { | |
super.onTransition(bloc, transition); | |
print(transition); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void main() { | |
BlocSupervisor.delegate = SimpleBlocDelegate(); | |
runApp(MyApp()); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'package:flutter/material.dart'; | |
import 'package:bloc/bloc.dart'; | |
/// A Flutter widget which provides a bloc to its children via `BlocProvider.of(context)`. | |
/// It is used as a DI widget so that a single instance of a bloc can be provided | |
/// to multiple widgets within a subtree. | |
class BlocProvider extends StatefulWidget { | |
/// The Blocs which are to be made available throughout the subtree. | |
/// If multiple blocs are provided, the blocs will be inserted in the same order they are specified. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Person { | |
final String name; | |
final int age; | |
const Person({this.name, this.age}); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void main() { | |
final Person bob = Person(name: "Bob", age: 40); | |
} |