0 purchases
crow
crow #
Crow gives you utils widgets, to apply separation of concerns.
Installation #
Add this to your packages pubspec.yaml file:
dependencies:
crow: <^last>
copied to clipboard
Install it You can install it from the command line:
$ flutter pub get
copied to clipboard
Import it Now in Dart code, you can use:
import 'package:crow/crow.dart';
copied to clipboard
Offers #
contracts (interfaces) #
data layer
Model
RemoteDataSource
LocalDataSource
domain layer
Entity
Service
UseCase
presentation layer
middleware
page
screen
view
view_model
generic
crud_operation
params
repository
Services #
connectivity_service
preferences_service
theme_mode_service
Usage #
There are two types of Widgets:
View - The StatelessWidget implementation but with extra features.
Screen - The responsive version of View, which offers more utils. You will find only View
examples, but Screen are the same except they have more method for the build. Like: phone(),
tablet() etc.
Start #
First of all At the top of your main method you need to call Crow initDependencies, which will
allows you getting benefits of preregistered dependencies.
Define your View.
If you need custom viewModel then set the View generic type to the ViewModel which you have been
created.
Register your ViewModel as a dependency.
Enjoy crow!.
void main() async {
await Crow.instance.initAsyncServices();
Crow.instance.initDependencies();
Get.lazyPut<HomeViewModel>(HomeViewModel.new); // Or
// Get.lazyPut<HomeViewModel>(() => HomeViewModel()); same thing.
}
// Remember to set the View generic `Type` in order to accesses your custom properties,
// getters, setters, methods in your Widget. As below HomeViewModel is subclass of ViewModel.
// If you don't specify the View generic `Type` then you'll be able to accesses only predefined stuff. e.g a context getter.
class HomeView extends View<HomeViewModel> {
const HomeView({Key? key}) : super(key: key);
// Note: that you can assess the BuildContext globally in your widget.
@override
Widget? builder() {
return Scaffold(
appBar: AppBar(
title: Text(viewModel.title),
),
body: Center(
child: ElevatedButton(
onPressed: viewModel.navToNext, // Your custom method.
child: const Text('Go Next'),
),
),
);
}
}
class HomeViewModel extends ViewModel {
final String title = 'flutter_crow';
void navToNext() {
Navigator.push(
context, // You can accesses the BuildContext globally in your ViewModel.
MaterialPageRoute(
builder: (context) {
return const SecondPage();
},
),
);
}
}
// Remember what we have side?
// The type parameter on View is optional, so in this case you cannot access custom invocation,
// but still able to get the predefined ones like the global context.
class SecondPage extends View {
const SecondPage({Key? key}) : super(key: key);
@override
Widget builder() {
return const Scaffold(
body: Center(
child: Text('Go back'),
),
);
}
}
copied to clipboard
For personal and professional use. You cannot resell or redistribute these repositories in their original state.
There are no reviews.