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 Store { | |
Store(this.name, this.address, this.geoPosition, this.employees); | |
Store.fromUnsafeMap(Map<String, dynamic> json) | |
: name = json['name'], | |
address = json['address'], | |
geoPosition = json['geoPosition'], | |
employees = json['employees']; | |
final String name; |
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 main() { | |
final email1 = Email.maybeFrom("frank@moreno"); | |
final email2 = Email.maybeFrom("[email protected]"); | |
print(email1); | |
print(email2); | |
} | |
bool isValidEmail(String email) { | |
// Regular expression to validate the format of an email |
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:flutter_riverpod/flutter_riverpod.dart'; | |
void main() => runApp(ProviderScope(child: const MyApp())); | |
final counterProvider = StateProvider<int>((ref) { | |
//final unsub = someStream.subscribe((val) => ref.state = va;); | |
//ref.onDispose(() => unsub()); | |
return 0; | |
}); |
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 main() { | |
print(fibo(3)); | |
print(fibo(5)); | |
print(fibo(13)); | |
print(fibo(8)); | |
} | |
// TODO: refactorizar usando cache | |
int fibox(int n) { |
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 main() { | |
final list = <int>[1, 2, 3, 4, 2, -1, 5]; | |
final maxValue = 12; | |
late final int sum; | |
{ | |
var _sum = 0; | |
for(final val in list) { | |
_sum += val; | |
} |
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 main() { | |
final list = <int>[1, 2, 3, 4, 2, -1, 5]; | |
final maxValue = 12; | |
final sum = (){ | |
var sum = 0; | |
for(final val in list) { | |
sum += val; | |
} | |
if(sum > maxValue) { |
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 main() { | |
final list = <int>[1, 2, 3, 4, 2, -1, 5]; | |
final maxValue = 12; | |
final sum = list.clampedSum(maxValue); | |
/// ... more code that uses `sum` ... | |
} | |
extension ClampedAdder on List<int> { |
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 main() { | |
final list = <int>[1, 2, 3, 4, 2, -1, 5]; | |
final maxValue = 12; | |
var sum = 0; | |
for(final val in list) { | |
sum += val; | |
} | |
if(sum > maxValue) { | |
sum = maxValue; |
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 main() { | |
final obj1 = MyComplexObject(1, 2.0); | |
final obj2 = MyComplexObject(1, 2.0); | |
assert(!identical(obj1, obj2)); // obj1 and obj2 are not the same object | |
const cobj1 = MyComplexObject(1, 2.0); | |
const cobj2 = MyComplexObject(1, 2.0); | |
assert(identical(cobj1, cobj2)); // cobj1 and cobj2 are the same object | |
assert(!identical(cobj1, obj1)); // cobj1 and obj1 are not the same object | |
} |
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
/// Temporal file for migrating to [WidgetRef] syntax in the | |
/// becoming `riverpod` version. | |
/// | |
/// See the new RFC and the implementation (WIP) | |
/// - RFC: https://github.com/rrousselGit/river_pod/issues/335 | |
/// - PR: https://github.com/rrousselGit/river_pod/pull/462 | |
/// | |
/// Medum article about the usage: https://link.medium.com/4F5gdDISXfb | |
library temporal_widget_ref_migration; |
NewerOlder