Created
April 26, 2020 01:25
-
-
Save riscait/f678566b2c8a96d118fba10d4f00b240 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
import 'package:flutter/material.dart'; | |
import 'package:provider/provider.dart'; | |
import 'ex_theme_mode.dart'; | |
import 'theme_mode_notifier.dart'; | |
class ThemeListView extends StatelessWidget { | |
const ThemeListView(); | |
@override | |
Widget build(BuildContext context) { | |
final themeModeNotifier = Provider.of<ThemeModeNotifier>(context); | |
var _selectedTheme = themeModeNotifier.current; | |
return ListView.builder( | |
itemCount: ExThemeMode.values.length, | |
itemBuilder: (_, index) { | |
final themeDataMode = ExThemeMode.values[index]; | |
return RadioListTile( | |
title: Text(themeDataMode.name), | |
subtitle: Text(themeDataMode.description), | |
secondary: Icon(themeDataMode.icon), | |
controlAffinity: ListTileControlAffinity.platform, | |
value: themeDataMode, | |
groupValue: _selectedTheme, | |
onChanged: (ExThemeMode theme) { | |
_selectedTheme = theme; | |
themeModeNotifier.change(theme); | |
}, | |
); | |
}, | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment