-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: +10 pub points by increasing description on pubspec.yaml fix: running flutter format to increase pub point
- Loading branch information
Showing
35 changed files
with
585 additions
and
597 deletions.
There are no files selected for viewing
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
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
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
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
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
93 changes: 49 additions & 44 deletions
93
example/lib/03_depend_observable_sample/depends_on_sample.dart
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,78 +1,83 @@ | ||
import 'package:flutter/material.dart'; | ||
import 'package:telescope/telescope.dart'; | ||
|
||
|
||
class DependObservableSampleLayout extends StatefulWidget { | ||
const DependObservableSampleLayout({Key? key}) : super(key: key); | ||
|
||
@override | ||
State<DependObservableSampleLayout> createState() => DependObservableSampleLayoutState(); | ||
State<DependObservableSampleLayout> createState() => | ||
DependObservableSampleLayoutState(); | ||
} | ||
|
||
class DependObservableSampleLayoutState extends State<DependObservableSampleLayout> { | ||
|
||
class DependObservableSampleLayoutState | ||
extends State<DependObservableSampleLayout> { | ||
// observables | ||
late Telescope<int> height; | ||
late Telescope<int> weight; | ||
late Telescope<double> bmi; | ||
late Telescope<String> showingText; | ||
|
||
@override | ||
void initState(){ | ||
void initState() { | ||
super.initState(); | ||
|
||
height = Telescope(186); | ||
weight = Telescope(72); | ||
|
||
bmi = Telescope.dependsOn([height,weight], () { | ||
return weight.value / ((height.value/100) * (height.value/100)); | ||
bmi = Telescope.dependsOn([height, weight], () { | ||
return weight.value / ((height.value / 100) * (height.value / 100)); | ||
}); | ||
|
||
showingText = Telescope.dependsOn([bmi], () { | ||
return "weight is ${weight.value} and height is ${height.value} so bmi will be ${bmi.value.toString().substring(0,5)}"; | ||
showingText = Telescope.dependsOn([bmi], () { | ||
return "weight is ${weight.value} and height is ${height.value} so bmi will be ${bmi.value.toString().substring(0, 5)}"; | ||
}); | ||
} | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
|
||
var style = const TextStyle(fontSize: 40); | ||
return Material( | ||
type: MaterialType.transparency, | ||
child: SafeArea( | ||
child: Container( | ||
color: Colors.white, | ||
child: Column(children: [ | ||
const SizedBox(height: 20), | ||
Text("Weight(kg):",style: style,), | ||
Slider( | ||
value: weight.watch(this).toDouble(), | ||
min: 1, | ||
max: 200, | ||
label: weight.watch(this).round().toString(), | ||
onChanged: (double value) { | ||
weight.value = value.toInt(); | ||
} | ||
), | ||
|
||
Text("Height(cm):",style: style,), | ||
Slider( | ||
value: height.watch(this).toDouble(), | ||
min: 1, | ||
max: 200, | ||
label: height.watch(this).round().toString(), | ||
onChanged: (double value) { | ||
height.value = value.toInt(); | ||
} | ||
), | ||
Text("Result:",style: style,), | ||
Text( | ||
showingText.watch(this), | ||
style: style, | ||
), | ||
],), | ||
) | ||
) | ||
); | ||
color: Colors.white, | ||
child: Column( | ||
children: [ | ||
const SizedBox(height: 20), | ||
Text( | ||
"Weight(kg):", | ||
style: style, | ||
), | ||
Slider( | ||
value: weight.watch(this).toDouble(), | ||
min: 1, | ||
max: 200, | ||
label: weight.watch(this).round().toString(), | ||
onChanged: (double value) { | ||
weight.value = value.toInt(); | ||
}), | ||
Text( | ||
"Height(cm):", | ||
style: style, | ||
), | ||
Slider( | ||
value: height.watch(this).toDouble(), | ||
min: 1, | ||
max: 200, | ||
label: height.watch(this).round().toString(), | ||
onChanged: (double value) { | ||
height.value = value.toInt(); | ||
}), | ||
Text( | ||
"Result:", | ||
style: style, | ||
), | ||
Text( | ||
showingText.watch(this), | ||
style: style, | ||
), | ||
], | ||
), | ||
))); | ||
} | ||
} | ||
} |
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
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
Oops, something went wrong.