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 DownloadService { | |
Future<void> download({required String url}); | |
} | |
class WebDownloadService implements DownloadService { | |
@override | |
Future<void> download({required String url}) { | |
throw UnimplementedError(); | |
} | |
} |
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
... | |
dependencies: | |
flutter: | |
sdk: flutter | |
# file downloads | |
path_provider: ^2.0.8 | |
dio: ^4.0.4 | |
permission_handler: ^8.3.0 | |
open_file: ^3.2.1 |
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 MyHomePage extends StatefulWidget { | |
const MyHomePage({Key? key}) : super(key: key); | |
@override | |
State<MyHomePage> createState() => _MyHomePageState(); | |
} | |
class _MyHomePageState extends State<MyHomePage> { | |
void _downloadFile() {} |
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 MyReactiveService with ReactiveServiceMixin { | |
ReactiveValue<int> _counterOne = ReactiveValue<int>(0); | |
ReactiveValue<int> _counterTwo = ReactiveValue<int>(0); | |
int get counterOne => _counterOne.value; | |
int get counterTwo => _counterTwo.value; | |
ProposalSheetFormService() { | |
listenToReactiveValues([_counterOne, _counterTwo]); | |
} |
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 Info extends InheritedWidget { | |
// this udget uses the of(context) | |
//method to call the build method | |
// when updateShouldNotify function returns true | |
const Info({ | |
Key key, | |
@required this.score, | |
@required Widget child, | |
}) : assert(score != null), | |
assert(child != 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
import 'package:flutter/material.dart'; | |
import 'package:stacked/stacked.dart'; | |
class MyView extends StatelessWidget { | |
const MyView({Key? key}) : super(key: key); | |
@override | |
Widget build(BuildContext context) { | |
// we have to wrap our widget inside a ViewModelBuilder | |
// to react to our viewmodel this implementation utilises |
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
import 'package:flutter/material.dart'; | |
import 'package:provider/provider.dart'; | |
void main() { | |
runApp( | |
MultiProvider( | |
providers: [ | |
// Counter is the name of the provider model | |
// we will use to update the state of the Widgets | |
ChangeNotifierProvider(create: (_) => Counter()), |
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 Info extends InheritedWidget { | |
// this udget uses the of(context) | |
//method to call the build method | |
// when updateShouldNotify function returns true | |
const Info({ | |
Key key, | |
@required this.score, | |
@required Widget child, | |
}) : assert(score != null), | |
assert(child != 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
import 'package:flutter/material.dart'; | |
// Global reactive value | |
final counter = ValueNotifier<int>(0); | |
class MyWidget extends StatefulWidget { | |
@override | |
_MyWidgetState createState() => _MyWidgetState(); | |
} |