This file contains hidden or 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
| @override | |
| Widget build(BuildContext context) { | |
| var width = MediaQuery.of(context).size.width; | |
| return WillPopScope( | |
| onWillPop: onBackPressed, | |
| child: GestureDetector( | |
| onVerticalDragUpdate: _handleDragUpdate, | |
| onVerticalDragEnd: _handleDragEnd, | |
| child: Scaffold( |
This file contains hidden or 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 _handleDragUpdate(DragUpdateDetails details) { | |
| if (_dismissUnderway) return; | |
| var change = details.primaryDelta / (_childHeight ?? details.primaryDelta); | |
| if (_isDirectionTop()) | |
| _animationController.value += change; | |
| else | |
| _animationController.value -= change; | |
| } |
This file contains hidden or 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
| AnimatedBuilder( | |
| animation: _animation, | |
| builder: (context, _) { | |
| return Transform( | |
| transform: Matrix4.translationValues( | |
| 0.0, width * _animation.value, 0.0), | |
| child: Container( | |
| width: width, | |
| child: GestureDetector( | |
| behavior: HitTestBehavior.opaque, |
This file contains hidden or 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 Observable<T> { | |
| T _value; | |
| Function(T) _onValueChanged; | |
| void observe(Function(T) onValueChanged) { | |
| this._onValueChanged = onValueChanged; | |
| } | |
| void setValue(T changedValue) { | |
| if (changedValue != null) { |
This file contains hidden or 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 ApiConnector { | |
| Dio _dio; | |
| String tag = "API call :"; | |
| CancelToken _cancelToken; | |
| ApiConnector() { | |
| _dio = createDio(); | |
| } | |
| Dio createDio() { |
This file contains hidden or 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 ApiUtil { | |
| ApiConnector _apiConnector; | |
| ApiUtil() { | |
| _apiConnector = ApiConnector(); | |
| } | |
| void cancelRequests({CancelToken cancelToken}) { | |
| _apiConnector.cancelRequests(cancelToken: cancelToken); | |
| } |
This file contains hidden or 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 BaseRepo { | |
| final ApiUtil apiService = GetIt.I<ApiUtil>(); | |
| dynamic callApi( | |
| Future<dynamic> Function() apiBlock, Observable<ApiError> onApiError, | |
| {int reqCode = -1}) async { | |
| return await apiBlock().catchError((error) { | |
| onApiError.setValue(ApiError(error, reqCode)); | |
| return null; | |
| }); |
This file contains hidden or 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 BaseModel { | |
| Observable<ApiError> onApiError = Observable(); | |
| } |
This file contains hidden or 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
| abstract class BaseScreen extends StatefulWidget {} | |
| abstract class BaseScreenState<T extends BaseScreen> extends State<T> { | |
| ApiUtil apiService = GetIt.I<ApiUtil>(); | |
| Observable<ApiError> onApiError(); | |
| @override | |
| void initState() { | |
| super.initState(); |
This file contains hidden or 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 Home extends BaseScreen { | |
| @override | |
| _HomeState createState() => _HomeState(); | |
| } | |
| class _HomeState extends BaseScreenState<Home> { | |
| HomeModel model; | |
| String text = ""; |
OlderNewer