2021-03-02 22:26:59 +01:00
|
|
|
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
|
|
|
|
class LanguageSelector extends StatefulWidget {
|
|
|
|
|
|
|
|
|
|
|
|
@override
|
2021-03-02 23:35:47 +01:00
|
|
|
LanguageSelectorState createState() => new LanguageSelectorState();
|
2021-03-02 22:26:59 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
class LanguageSelectorState extends State<LanguageSelector> {
|
2021-03-02 23:35:47 +01:00
|
|
|
List<bool> isSelected;
|
2021-03-02 22:26:59 +01:00
|
|
|
|
|
|
|
@override
|
|
|
|
void initState() {
|
|
|
|
super.initState();
|
|
|
|
isSelected = [true, false, false];
|
|
|
|
}
|
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
return ToggleButtons(
|
2021-03-02 23:35:47 +01:00
|
|
|
isSelected: isSelected,
|
|
|
|
children: <Widget> [
|
2021-03-02 22:26:59 +01:00
|
|
|
LanguageOption("Auto"),
|
|
|
|
LanguageOption("Japanese"),
|
|
|
|
LanguageOption("English")
|
|
|
|
],
|
2021-03-02 23:35:47 +01:00
|
|
|
selectedColor: Colors.blue,
|
|
|
|
onPressed: (int buttonIndex) {
|
|
|
|
setState(() {
|
|
|
|
for (var i in Iterable.generate(isSelected.length)) {
|
|
|
|
isSelected[i] = i == buttonIndex;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
},
|
2021-03-02 22:26:59 +01:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
class LanguageOption extends StatelessWidget {
|
|
|
|
final String _language;
|
|
|
|
|
|
|
|
LanguageOption(this._language);
|
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
return Expanded(
|
|
|
|
child: Container(
|
2021-03-02 23:35:47 +01:00
|
|
|
padding: EdgeInsets.symmetric(vertical: 10.0, horizontal: 20.0),
|
2021-03-02 22:26:59 +01:00
|
|
|
child: Center(child: Text(_language)),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|