class
=” token keyword “>import‘ package : flutter / material.dart ‘;
import‘ package : states_bloc / drawer_menu. dart ‘;
import‘ package : states_bloc / bloc / settings / settings_bloc. dart ‘;
import‘ package : flutter_bloc / flutter_bloc. dart ‘;
classSettingsextendsStatelessWidget{
double_value =0.5;
boolisBold =false;
boolisItalic =false;
@override
Widgetbuild(BuildContextcontext){
finalSettingsBlocsettingsBloc =BlocProvider.ofvàlt;SettingsBlocvàgt;(context);
returnScaffold(
appBar:AppBar(
backgroundColor:Colors.teal,
title:Text(‘ Settings ‘),
),
drawer:DrawerMenu(),
body toàn thân:BlocBuildervàlt;SettingsBloc,SettingsStatevàgt;(
builder:(context,state){
returnColumn(
crossAxisAlignment:CrossAxisAlignment.start,
children:vàlt;Widgetvàgt;[
Padding(
padding:EdgeInsets.only(left:20,top:20),
child:Text(
‘ Font Size : $ { state. fontSize. toInt ( ) } ‘,
style:TextStyle(
fontSize:Theme.of(context).textTheme.headline.fontSize),
),
),
Slider(
min:0.5,
value:state.sliderFontSize,
onChanged:(newValue){
settingsBloc.dispatch(FontSize(newValue));
}),
Container(
margin:EdgeInsets.symmetric(horizontal:8),
span
>
child:Row(
children:vàlt;Widgetvàgt;[
Checkbox(
value:state.isBold,
onChanged:(newVal){
settingsBloc.dispatch(Bold(newVal));
},
),
Text(
‘ Bold ‘,
style:getStyle(state.isBold,false),
),
],
),
),
Container(
margin:EdgeInsets.symmetric(horizontal:8),
child:Row(
children:vàlt;Widgetvàgt;[
Checkbox(
value:state.isItalic,
onChanged:(newVal){
settingsBloc.dispatch(Italic(newVal));
}),
Text(
‘ Italic ‘,
style:getStyle(false,state.isItalic),
),
],
),
),
],
);
},
),
);
}
TextStylegetStyle([boolisBold =false,boolisItalic =false]){
returnTextStyle(
fontSize:18,
fontWeight:isBold?FontWeight.bold:FontWeight.normal,
fontStyle:isItalic?FontStyle.italic:FontStyle.normal,
);
}
}<
/
span>