Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import 'package:bloc_pattern/bloc_pattern.dart';
- import 'package:flutter/material.dart';
- import 'value_bloc.dart';
- class HomePage extends StatefulWidget {
- @override
- _HomePageState createState() => _HomePageState();
- }
- class _HomePageState extends State<HomePage> {
- Widget _textValue(String v) {
- return Text(v,
- style: TextStyle(
- color: Colors.white,
- fontSize: 24,
- fontWeight: FontWeight.bold,
- ),
- );
- }
- @override
- Widget build(BuildContext context) {
- print("reconstruindo");
- ValueBloc valueBloc = BlocProvider.getBloc<ValueBloc>();
- return Material(
- color: Color.lerp(Colors.red, Colors.purple, valueBloc.value),
- child: Column(
- mainAxisAlignment: MainAxisAlignment.center,
- children: <Widget>[
- StreamBuilder<String>(
- stream: valueBloc.valueStringOut,
- initialData: "",
- builder: (BuildContext context, snapshot) {
- return _textValue(snapshot.data);
- },
- ),
- Container(
- height: 25,
- ),
- StreamBuilder<double>(
- stream: valueBloc.valueOut,
- initialData: 0,
- builder: (context, snapshot) {
- return Slider(
- activeColor: Colors.white,
- inactiveColor: Colors.white,
- min: 0.0,
- max: 1.0,
- onChanged: valueBloc.onChangeValue,
- value: snapshot.data);
- },
- ),
- ],
- ),
- );
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement