Flutter plugin for manage your app with basic and general functionalities.
Using
For use init config.
import 'package:base_flutter_app/config/api_log_config.dart';
import 'package:base_flutter_app/config/base_flutter_app_config.dart';
BaseFlutterAppConfig().apiLogConfig = ApiLogConfig();
BaseFlutterAppConfig().secDbPassword = 'mySecPassword';
For use Bloc.
import 'package:base_flutter_app/blocs/bloc.dart';
class UsersBloc with Bloc {
@override
void dispose() {
// TODO: dispose controllers.
}
}
import 'package:base_flutter_app/blocs/provider.dart';
var bloc = Provider.of<UsersBloc>(() => UsersBloc());
For use Connectivity.
import 'package:base_flutter_app/connectivity/connectivity.dart';
Connectivity connectivity = ConnectivityAdapter();
if (await connectivity.isConnected()) {
// Do something
} else {
// Do something
}
For use string_extensions
import 'package:base_flutter_app/string_extensions.dart';
var stringFormated = 'Hello {{0}}, {{1}}'.format(['Wordl!!', 'User']);
print(stringFormated); // Hello Wordl!!, User
For use ApiSource
import 'package:base_flutter_app/connectivity/connectivity.dart';
import 'package:base_flutter_app/data_source/api/api_source.dart';
import 'package:http/http.dart' as http;
class MyApiSource with ApiSource {
final String _baseUrl;
final http.Client _client;
final Connectivity _connectivity;
MyApiSource(
this._baseUrl,
this._client,
this._connectivity,
);
@override
String get baseUrl => _baseUrl;
@override
http.Client get client => _client;
@override
Connectivity get connectivity => _connectivity;
@override
Map<String, String> getHeaders(Map<String, String> headers) {
headers = headers ?? {};
return headers;
}
}
var myApiSource = MyApiSource('https://base.url.com', http.Client(), ConnectivityAdapter());myApiSource.getApi(url, (value) => null);
myApiSource.postApi(url, body, (value) => null);
For use general api sources
class UsersApiSourceAdapter implements UsersApiSource {
final MyApiSource apiSource;
UsersApiSourceAdapter(this.apiSource);
@override
Future<List<User>> getAll([Map args]) {
var url = '${apiSource.baseUrl}/api/users';
return apiSource.getApi<List<User>>(url, (value) {
return (value as List).map((value) {
return User.fromJson(value);
}).toList();
});
}
}
For use general db source
class UsersDbSourceAdapter
with StreamAllDbSourceAdapter<User>, PutAllDbSourceAdapter<User>
implements UsersDbSource {
@override
User mapper(Map<String, dynamic> value) {
return User.fromJson(value);
}
@override
List<SortOrder> get sortOrders => [SortOrder('name')];
}
Libraries
- blocs/bloc
- blocs/bloc_cache
- blocs/provider
- connectivity/connectivity
- connectivity/connectivity_adapter
- data_source/api/api_source
- data_source/db/config/app_database
- data_source/db/config/encrypt_codec
- data_source/db/delete_by_id_db_source
- data_source/db/put_all_db_source
- data_source/db/put_db_source
- data_source/db/simple_put_db_source
- data_source/db/simple_stream_db_source
- data_source/db/stream_all_db_source
- data_source/db/stream_by_id_db_source
- string_extensions
- ui/platform_widgets/error_text_widget
- ui/platform_widgets/platform_progress_indicator
- ui/platform_widgets/platform_widget