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 'dart:convert'; | |
| import 'package:cloud_firestore/cloud_firestore.dart'; | |
| import 'package:equatable/equatable.dart'; | |
| import 'package:flutter/material.dart'; | |
| import 'package:translator/l10n/l10n.dart'; | |
| // To parse this JSON data, do | |
| // | |
| // final translation = translationFromJson(jsonString); |
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
| /// * si usamos Riverpod | |
| void main() => runApp(ProviderScope(child: MyApp())); | |
| ... | |
| final userStateNotifierProvider = Provider<UserStateNotifier>( | |
| (_) => UserStateNotifier(); | |
| ); |
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
| /// * si usamos Provider | |
| void main() => runApp( | |
| StateNotifierProvider<UserStateNotifier, UserState>( | |
| create: (_) => UserStateNotifier(), | |
| child: MyApp(), | |
| ), | |
| ); | |
| ... |
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 UserStateNotifier extends StateNotifier<UserState> { | |
| // usamos super para crear nuestro estado inicial, | |
| // igual que en Bloc | |
| UserStateNotifier() : super(UserNotLogged()); | |
| // cambiamos el estado asignando uno nuevo | |
| void logIn(User user) => state = UserLogged(user: user); | |
| } |
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 UserState { } | |
| class UserNotLogged extends UserState { } | |
| class UserLogged extends UserState { | |
| UserLogged({@required this.user}); | |
| final User user; | |
| } |
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
| # * si usas Provider | |
| provider: ^4.3.3 | |
| state_notifier: ^0.6.0 | |
| flutter_state_notifier: ^0.6.1 | |
| # * si usas Riverpod, ya integra state_notifier | |
| flutter_riverpod: ^0.12.2 | |
| # usa las dependencias más recientes o | |
| # las que sean compatibles con tu proyecto |
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
| Container(height: 100, width: 100, color: ColorName.justBlack); |
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
| Assets.images.background.image(); |
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 API { | |
| static const url = 'url_to_my_api.dev/api'; | |
| } | |
| Future callToAPI() async { | |
| await http.get(API.url); | |
| } | |
| Future anotherCallToAPI() async { | |
| await http.get('${API.url}/other'); |
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
| Text( | |
| 'Esto es usando las fuentes con FlutterGen', | |
| style: TextStyle(fontFamily: FontFamily.googleSans), | |
| ); |
NewerOlder