Skip to content

Instantly share code, notes, and snippets.

View MCarlomagno's full-sized avatar
🚀

Marcos Carlomagno MCarlomagno

🚀
  • OpenZeppelin
  • Rosario - Argentina
View GitHub Profile
abstract class DownloadService {
Future<void> download({required String url});
}
class WebDownloadService implements DownloadService {
@override
Future<void> download({required String url}) {
throw UnimplementedError();
}
}
...
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
import 'package:flutter/material.dart';
class DownloadButton extends StatelessWidget {
const DownloadButton({Key? key}) : super(key: key);
void _downloadFile() {}
@override
Widget build(BuildContext context) {
return ElevatedButton.icon(
class MyHomePage extends StatefulWidget {
const MyHomePage({Key? key}) : super(key: key);
@override
State<MyHomePage> createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
void _downloadFile() {}
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]);
}
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),
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
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()),
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),
import 'package:flutter/material.dart';
// Global reactive value
final counter = ValueNotifier<int>(0);
class MyWidget extends StatefulWidget {
@override
_MyWidgetState createState() => _MyWidgetState();
}