import 'package:checker/base/base_state.dart'; import 'package:checker/consts.dart'; import 'package:checker/db.dart'; import 'package:checker/strings.dart'; import 'package:flutter/material.dart'; abstract class SettingsBaseState extends BaseState { SettingsBaseState(SqliteHelper helper, String app) { this.helper = helper; this.app = app; } int selectedItem; @override Widget build(BuildContext context) { return new Scaffold(appBar: getAppBar(), body: getScreenContent()); } @override Widget getScreenContent() { getSelectedValue(); List widgets = new List(); for (String option in getOptions()) { widgets.add(getItem(option)); } return new ListView(children: widgets); } List getOptions(); void saveOption(); void getSelectedValue(); @override List getMenuButtons() { return null; } Widget getItem(String option) { return new Container( height: 56.0, child: (new FlatButton(onPressed: () { saveOption(); setState(() { selectedItem = getOptions().indexOf(option); }); }, child: new Row(children: [ new Expanded(child: new Text(option)), getCheckMark(getOptions().indexOf(option))])))); } Widget getCheckMark(int index) { return index == selectedItem ? new Image.asset(check_png, width: 28.0, height: 28.0) : new Image.asset(check_png, color: new Color(0xffffff)); } @override String getTitle() { return StringsLocalization.settings(); } }