This file contains 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 Clicker extends StatelessWidget with Floop { | |
Widget build(BuildContext context) { | |
return Scaffold( | |
body: Center( | |
child: Opacity( | |
// opacity goes from 0 to 1 in two seconds | |
opacity: transition(2000), | |
// Text always displays the current value of floop[#clicks]. | |
child: Text('${floop[#clicks]}'), | |
) |
This file contains 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:benchmark_harness/benchmark_harness.dart'; | |
void main() { | |
print('Running app'); | |
runMiscBenchmarks(); | |
print('-----------------------------------------------------'); | |
print('-------------END------------------------------------'); | |
print('-----------------------------------------------------'); | |
} |
This file contains 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:math'; | |
import 'package:floop/floop.dart'; | |
import 'package:flutter/material.dart'; | |
void main() { | |
runApp(MaterialApp(title: 'Color boxes', home: ColoredGrid())); | |
} | |
class Dyn { |
This file contains 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 ColorBox extends DynamicWidget { | |
final int id; | |
ColorBox(this.id, {Key key}) : super(key: key); | |
initDyn() { | |
dyn[#color] = randomColor(); | |
dyn[#textColor] = contrastColor(dyn[#color]); | |
dyn[#clicks] = 0; | |
} |
This file contains 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:floop/floop.dart'; | |
import 'package:http/http.dart' as http; | |
void main() { | |
fetchAndUpdateImage(); | |
runApp(MaterialApp(title: 'Fetch image', home: ImageDisplay())); | |
} | |
class DynamicValues { |
This file contains 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 TransitionImage extends FloopWidget { | |
final Image image; | |
const TransitionImage(this.image); | |
@override | |
Widget build(BuildContext context) { | |
// Opacity transitions from 0 to 1 in 1.5 seconds. | |
return GestureDetector( | |
child: Opacity(opacity: transition(1500), child: image), | |
onTap: () async { |
This file contains 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 DynamicValues { | |
static Widget get image => floop['image']; | |
static set image(Widget widget) => floop['image'] = widget; | |
// Here should go all the reads and writes to `floop` | |
} | |
/// It's also possible to create a local [ObservedMap]. | |
/// `floop` is just an instance of [ObservedMap]. | |
class DynamicValuesLocal { | |
static ObservedMap<String, dynamic> dyn = ObservedMap(); |
This file contains 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:floop/floop.dart'; | |
import 'package:http/http.dart' as http; | |
void main() { | |
fetchAndUpdateImage(); | |
runApp(MaterialApp(title: 'Fetch image', home: ImageDisplay())); | |
} | |
var _fetching = false; |
This file contains 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
var _fetching = false; | |
fetchAndUpdateImage([String url = 'https://picsum.photos/300/200']) async { | |
if(_fetching) { | |
return; | |
} | |
_fetching = true; | |
final response = await http.get(url); | |
floop['image'] = TransitionImage(Image.memory(response.bodyBytes)); | |
_fetching = false; |
This file contains 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 ImageDisplay extends StatelessWidget with Floop { | |
@override | |
Widget build(BuildContext context) { | |
return Scaffold( | |
body: floop['image'] == null | |
? Center( | |
child: Text( | |
'Loading...', | |
textScaleFactor: 2, | |
), |
NewerOlder