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 GithubUser { | |
final String login; | |
final String avatarUrl; | |
const GithubUser({this.login, this.avatarUrl}); | |
static GithubUser fromJson(dynamic json) { | |
return GithubUser( | |
login: json['login'] as String, | |
avatarUrl: json['avatar_url'] as String, |
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 SearchResultError { | |
final String message; | |
const SearchResultError({this.message}); | |
static SearchResultError fromJson(dynamic json) { | |
return SearchResultError( | |
message: json['message'] as String, | |
); | |
} |
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:common_github_search/common_github_search.dart'; | |
class GithubCache { | |
final _cache = <String, SearchResult>{}; | |
SearchResult get(String term) => _cache[term]; | |
void set(String term, SearchResult result) => _cache[term] = result; | |
bool contains(String term) => _cache.containsKey(term); |
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 'package:common_github_search/common_github_search.dart'; | |
class GithubRepository { | |
final GithubCache cache; | |
final GithubClient client; | |
GithubRepository(this.cache, this.client); |
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:equatable/equatable.dart'; | |
abstract class GithubSearchEvent extends Equatable { | |
GithubSearchEvent([List props = const []]) : super(props); | |
} | |
class TextChanged extends GithubSearchEvent { | |
final String text; | |
TextChanged({this.text}) : super([text]); |
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:equatable/equatable.dart'; | |
import 'package:common_github_search/common_github_search.dart'; | |
abstract class GithubSearchState extends Equatable { | |
GithubSearchState([List props = const []]) : super(props); | |
} | |
class SearchStateEmpty extends GithubSearchState { | |
@override |
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 'package:meta/meta.dart'; | |
import 'package:rxdart/rxdart.dart'; | |
import 'package:bloc/bloc.dart'; | |
import 'package:common_github_search/common_github_search.dart'; | |
class GithubSearchBloc extends Bloc<GithubSearchEvent, GithubSearchState> { | |
final GithubRepository githubRepository; |
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
name: flutter_github_search | |
description: A new Flutter project. | |
version: 1.0.0+1 | |
environment: | |
sdk: ">=2.0.0-dev.68.0 <3.0.0" | |
dependencies: | |
flutter: |
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
// SearchForm Implementation | |
class _SearchBar extends StatefulWidget { | |
final GithubSearchBloc githubSearchBloc; | |
_SearchBar({Key key, this.githubSearchBloc}) : super(key: key); | |
@override | |
State<_SearchBar> createState() => _SearchBarState(); | |
} |
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
// _SearchBar Implementation | |
class _SearchBody extends StatelessWidget { | |
final GithubSearchBloc githubSearchBloc; | |
const _SearchBody({Key key, this.githubSearchBloc}) : super(key: key); | |
@override | |
Widget build(BuildContext context) { | |
return BlocBuilder<GithubSearchEvent, GithubSearchState>( |