Skip to content
Open

Main #15

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 16 additions & 16 deletions example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,11 @@ class _MyAppState extends State<MyApp> {
// The StatefulWidget's job is to take in some data and create a State class.
// In this case, the Widget takes a title, and creates a _MyHomePageState.
class MyHomePage extends StatefulWidget {
final String title;
final String? title;

final VoidCallback onSetting;
final VoidCallback? onSetting;

MyHomePage({Key key, this.title, this.onSetting}) : super(key: key);
MyHomePage({Key? key, this.title, this.onSetting}) : super(key: key);

@override
_MyHomePageState createState() => _MyHomePageState();
Expand All @@ -59,23 +59,23 @@ class MyHomePage extends StatefulWidget {
class _MyHomePageState extends State<MyHomePage> {
// Whether the green box should be visible or invisible

String selectedIndexText;
String? selectedIndexText;

int selectIdx;
int? selectIdx;

String singleSelectedIndexText;
String? singleSelectedIndexText;

int selectIndex;
int? selectIndex;

String multiSelectedIndexesText;
String? multiSelectedIndexesText;

List<int> selectedIndexes;
List<int>? selectedIndexes;

@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text(widget.title),
title: Text(widget.title ??''),
actions: <Widget>[
IconButton(
icon: Icon(Icons.settings),
Expand Down Expand Up @@ -683,7 +683,7 @@ class _MyHomePageState extends State<MyHomePage> {
),
ListTile(
title: Text(
"List dialog ${selectedIndexText != null && selectedIndexText.isNotEmpty ? '(index:' + selectedIndexText + ')' : ''}",
"List dialog ${selectedIndexText != null && selectedIndexText!.isNotEmpty ? '(index:' + selectedIndexText! + ')' : ''}",
),
onTap: () async {
int index = await showAnimatedDialog(
Expand Down Expand Up @@ -722,7 +722,7 @@ class _MyHomePageState extends State<MyHomePage> {
),
ListTile(
title: Text(
"List single select${singleSelectedIndexText != null && singleSelectedIndexText.isNotEmpty ? '(index:' + singleSelectedIndexText + ')' : ''}",
"List single select${singleSelectedIndexText != null && singleSelectedIndexText!.isNotEmpty ? '(index:' + singleSelectedIndexText! + ')' : ''}",
),
onTap: () async {
int index = await showAnimatedDialog(
Expand All @@ -733,7 +733,7 @@ class _MyHomePageState extends State<MyHomePage> {
titleText: 'Title',
listType: ListType.singleSelect,
activeColor: Colors.red,
selectedIndex: selectIndex,
selectedIndex: selectIndex!,
dataList: List.generate(
20,
(index) {
Expand All @@ -759,7 +759,7 @@ class _MyHomePageState extends State<MyHomePage> {
),
ListTile(
title: Text(
"List multiple select${multiSelectedIndexesText != null && multiSelectedIndexesText.isNotEmpty ? '(index:' + multiSelectedIndexesText + ')' : ''}",
"List multiple select${multiSelectedIndexesText != null && multiSelectedIndexesText!.isNotEmpty ? '(index:' + multiSelectedIndexesText! + ')' : ''}",
),
onTap: () async {
List<int> indexes = await showAnimatedDialog(
Expand All @@ -769,7 +769,7 @@ class _MyHomePageState extends State<MyHomePage> {
return ClassicListDialogWidget<ListDataModel>(
titleText: 'Title',
listType: ListType.multiSelect,
selectedIndexes: selectedIndexes,
selectedIndexes: selectedIndexes!,
activeColor: Colors.green,
dataList: List.generate(
20,
Expand All @@ -788,7 +788,7 @@ class _MyHomePageState extends State<MyHomePage> {
print('selectedIndex:${selectedIndexes?.toString()}');
setState(() {
this.multiSelectedIndexesText =
selectedIndexes != null && selectedIndexes.length > 0
selectedIndexes != null && selectedIndexes!.length > 0
? selectedIndexes.toString()
: '';
});
Expand Down
6 changes: 3 additions & 3 deletions example/lib/model/list_data_model.dart
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
///List data model
class ListDataModel {
///Name
String name;
String? name;

///Value
String value;
String? value;

ListDataModel({this.name, this.value});

@override
String toString() {
return name;
return name?? '';
}
}
Loading