Skip to content

Instantly share code, notes, and snippets.

@jacobaraujo7
Last active May 11, 2019 02:58
Show Gist options
  • Save jacobaraujo7/4d6a9f28fdce78c5eb86209e37a962ad to your computer and use it in GitHub Desktop.
Save jacobaraujo7/4d6a9f28fdce78c5eb86209e37a962ad to your computer and use it in GitHub Desktop.
home_page.dart
import 'package:flutter/material.dart';
class HomePage extends StatefulWidget {
@override
_HomePageState createState() => _HomePageState();
}
class _HomePageState extends State<HomePage> {
//regra de negócio
double _value = 0.0;
_onChangeValue(double v) {
setState(() {
_value = v;
});
}
//fim da regra de negócio
Widget _textValue() {
return Text(
"Value: ${_value.toStringAsPrecision(1)}",
style: TextStyle(
color: Colors.white,
fontSize: 24,
fontWeight: FontWeight.bold,
),
);
}
@override
Widget build(BuildContext context) {
print("reconstruindo");
return Material(
color: Color.lerp(Colors.red, Colors.purple, 0.0),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
_textValue(),
Container(
height: 25,
),
Slider(
activeColor: Colors.white,
inactiveColor: Colors.white,
min: 0.0,
max: 1.0,
onChanged: _onChangeValue,
value: _value),
],
),
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment