Skip to content

Instantly share code, notes, and snippets.

@riscait
Created April 26, 2020 01:25
Show Gist options
  • Save riscait/f678566b2c8a96d118fba10d4f00b240 to your computer and use it in GitHub Desktop.
Save riscait/f678566b2c8a96d118fba10d4f00b240 to your computer and use it in GitHub Desktop.
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