null safety

This commit is contained in:
phyothandar
2021-09-10 14:25:37 +06:30
parent 5a313d641e
commit 079c9a135d
31 changed files with 230 additions and 227 deletions

View File

@@ -5,15 +5,15 @@ import 'package:flutter/material.dart';
import 'local_text.dart';
class LocalDropdown<T> extends StatelessWidget {
final Function(T) callback;
final IconData iconData;
final T selectedValue;
final List<T> values;
final Function(T) display;
final String labelKey;
final Function(T)? callback;
final IconData? iconData;
final T? selectedValue;
final List<T>? values;
final Function(T)? display;
final String? labelKey;
const LocalDropdown(
{Key key,
{Key? key,
this.callback,
this.iconData,
this.selectedValue,
@@ -40,7 +40,7 @@ class LocalDropdown<T> extends StatelessWidget {
padding: const EdgeInsets.only(right: 18.0),
child: LocalText(
context,
labelKey,
labelKey!,
color: Colors.black54,
fontSize: 16,
),
@@ -53,20 +53,20 @@ class LocalDropdown<T> extends StatelessWidget {
height: 1,
color: Colors.grey,
),
onChanged: (T newValue) {
callback(newValue);
onChanged: (T? newValue) {
callback!(newValue!);
},
isExpanded: true,
items: values == null
? []
: values.map<DropdownMenuItem<T>>((T value) {
: values!.map<DropdownMenuItem<T>>((T value) {
return DropdownMenuItem<T>(
value: value,
child: Text(
value == null
? ""
: display != null
? display(value)
? display!(value)
: value.toString(),
overflow: TextOverflow.ellipsis,
style: TextStyle(color: primaryColor)),