null safety
This commit is contained in:
@@ -54,7 +54,7 @@ Future<void> showConfirmDialog(
|
|||||||
FlatButton(
|
FlatButton(
|
||||||
color: Colors.grey[300],
|
color: Colors.grey[300],
|
||||||
child: Text(
|
child: Text(
|
||||||
AppTranslations.of(context).text('btn.cancel'),
|
AppTranslations.of(context)!.text('btn.cancel'),
|
||||||
style: Provider.of<LanguageModel>(context).isEng
|
style: Provider.of<LanguageModel>(context).isEng
|
||||||
? TextStyle()
|
? TextStyle()
|
||||||
: TextStyle(fontFamily: 'Myanmar3'),
|
: TextStyle(fontFamily: 'Myanmar3'),
|
||||||
@@ -67,7 +67,7 @@ Future<void> showConfirmDialog(
|
|||||||
),
|
),
|
||||||
FlatButton(
|
FlatButton(
|
||||||
color: primaryColor,
|
color: primaryColor,
|
||||||
child: Text(AppTranslations.of(context).text('btn.ok'),
|
child: Text(AppTranslations.of(context)!.text('btn.ok'),
|
||||||
style: Provider.of<LanguageModel>(context).isEng
|
style: Provider.of<LanguageModel>(context).isEng
|
||||||
? TextStyle(
|
? TextStyle(
|
||||||
color: Colors.white,
|
color: Colors.white,
|
||||||
@@ -367,7 +367,7 @@ Widget fcsButton(BuildContext context, String text,
|
|||||||
}
|
}
|
||||||
|
|
||||||
String getLocalString(BuildContext context, String key) {
|
String getLocalString(BuildContext context, String key) {
|
||||||
return AppTranslations.of(context).text(key);
|
return AppTranslations.of(context)!.text(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
void showToast(GlobalKey key, String text) {
|
void showToast(GlobalKey key, String text) {
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import 'package:fcs/pages/widgets/local_text.dart';
|
|||||||
import 'package:flutter/cupertino.dart';
|
import 'package:flutter/cupertino.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter/widgets.dart';
|
import 'package:flutter/widgets.dart';
|
||||||
import 'package:flutter_icons/flutter_icons.dart';
|
import 'package:flutter_vector_icons/flutter_vector_icons.dart';
|
||||||
import 'package:provider/provider.dart';
|
import 'package:provider/provider.dart';
|
||||||
|
|
||||||
class BottomWidgets extends StatelessWidget {
|
class BottomWidgets extends StatelessWidget {
|
||||||
|
|||||||
@@ -3,20 +3,20 @@ import 'package:fcs/helpers/theme.dart';
|
|||||||
import 'package:fcs/pages/delivery_address/delivery_address_row.dart';
|
import 'package:fcs/pages/delivery_address/delivery_address_row.dart';
|
||||||
import 'package:flutter/cupertino.dart';
|
import 'package:flutter/cupertino.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_icons/flutter_icons.dart';
|
import 'package:flutter_vector_icons/flutter_vector_icons.dart';
|
||||||
|
|
||||||
import 'callbacks.dart';
|
import 'callbacks.dart';
|
||||||
import 'display_text.dart';
|
import 'display_text.dart';
|
||||||
import 'local_text.dart';
|
import 'local_text.dart';
|
||||||
|
|
||||||
class DefaultDeliveryAddress extends StatelessWidget {
|
class DefaultDeliveryAddress extends StatelessWidget {
|
||||||
final DeliveryAddress deliveryAddress;
|
final DeliveryAddress? deliveryAddress;
|
||||||
final String labelKey;
|
final String? labelKey;
|
||||||
final OnTap onTap;
|
final OnTap? onTap;
|
||||||
final IconData iconData;
|
final IconData? iconData;
|
||||||
|
|
||||||
const DefaultDeliveryAddress(
|
const DefaultDeliveryAddress(
|
||||||
{Key key, this.deliveryAddress, this.onTap, this.labelKey, this.iconData})
|
{Key? key, this.deliveryAddress, this.onTap, this.labelKey, this.iconData})
|
||||||
: super(key: key);
|
: super(key: key);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@@ -37,7 +37,7 @@ class DefaultDeliveryAddress extends StatelessWidget {
|
|||||||
onTap == null
|
onTap == null
|
||||||
? Container()
|
? Container()
|
||||||
: GestureDetector(
|
: GestureDetector(
|
||||||
onTap: () => onTap(),
|
onTap: () => onTap!(),
|
||||||
child: Chip(
|
child: Chip(
|
||||||
label: LocalText(
|
label: LocalText(
|
||||||
context, "delivery_address.change_address",
|
context, "delivery_address.change_address",
|
||||||
@@ -50,8 +50,8 @@ class DefaultDeliveryAddress extends StatelessWidget {
|
|||||||
child: deliveryAddress == null
|
child: deliveryAddress == null
|
||||||
? Container()
|
? Container()
|
||||||
: DeliveryAddressRow(
|
: DeliveryAddressRow(
|
||||||
key: ValueKey(deliveryAddress.id),
|
key: ValueKey(deliveryAddress!.id),
|
||||||
deliveryAddress: deliveryAddress),
|
deliveryAddress: deliveryAddress!),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -10,11 +10,11 @@ import 'package:flutter/material.dart';
|
|||||||
import 'package:provider/provider.dart';
|
import 'package:provider/provider.dart';
|
||||||
|
|
||||||
class DeliveryAddressSelection extends StatefulWidget {
|
class DeliveryAddressSelection extends StatefulWidget {
|
||||||
final DeliveryAddress deliveryAddress;
|
final DeliveryAddress? deliveryAddress;
|
||||||
final User user;
|
final User? user;
|
||||||
|
|
||||||
const DeliveryAddressSelection({
|
const DeliveryAddressSelection({
|
||||||
Key key,
|
Key? key,
|
||||||
this.deliveryAddress,
|
this.deliveryAddress,
|
||||||
this.user,
|
this.user,
|
||||||
}) : super(key: key);
|
}) : super(key: key);
|
||||||
@@ -38,7 +38,7 @@ class _DeliveryAddressSelectionState extends State<DeliveryAddressSelection> {
|
|||||||
Provider.of<DeliveryAddressModel>(context, listen: false);
|
Provider.of<DeliveryAddressModel>(context, listen: false);
|
||||||
|
|
||||||
var deliveryAddresses =
|
var deliveryAddresses =
|
||||||
await addressModel.getDeliveryAddresses(widget.user.id);
|
await addressModel.getDeliveryAddresses(widget.user!.id);
|
||||||
setState(() {
|
setState(() {
|
||||||
this._deliveryAddresses = deliveryAddresses;
|
this._deliveryAddresses = deliveryAddresses;
|
||||||
});
|
});
|
||||||
@@ -95,7 +95,7 @@ class _DeliveryAddressSelectionState extends State<DeliveryAddressSelection> {
|
|||||||
padding: const EdgeInsets.all(10.0),
|
padding: const EdgeInsets.all(10.0),
|
||||||
child: Icon(Icons.check,
|
child: Icon(Icons.check,
|
||||||
color: widget.deliveryAddress != null &&
|
color: widget.deliveryAddress != null &&
|
||||||
_deliveryAddress.id == widget.deliveryAddress.id
|
_deliveryAddress.id == widget.deliveryAddress!.id
|
||||||
? primaryColor
|
? primaryColor
|
||||||
: Colors.black26),
|
: Colors.black26),
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -5,10 +5,10 @@ import 'package:flutter/material.dart';
|
|||||||
import 'local_text.dart';
|
import 'local_text.dart';
|
||||||
|
|
||||||
class DialogInput extends StatefulWidget {
|
class DialogInput extends StatefulWidget {
|
||||||
final String value;
|
final String? value;
|
||||||
final String label;
|
final String? label;
|
||||||
|
|
||||||
const DialogInput({Key key, this.label, this.value}) : super(key: key);
|
const DialogInput({Key? key, this.label, this.value}) : super(key: key);
|
||||||
@override
|
@override
|
||||||
_DialogInputState createState() => _DialogInputState();
|
_DialogInputState createState() => _DialogInputState();
|
||||||
}
|
}
|
||||||
@@ -24,7 +24,7 @@ class _DialogInputState extends State<DialogInput> {
|
|||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
if (widget.value != null) {
|
if (widget.value != null) {
|
||||||
_controller.text = widget.value;
|
_controller.text = widget.value!;
|
||||||
_focusNode.addListener(() {
|
_focusNode.addListener(() {
|
||||||
if (_focusNode.hasFocus) {
|
if (_focusNode.hasFocus) {
|
||||||
_controller.selection = TextSelection(
|
_controller.selection = TextSelection(
|
||||||
@@ -41,7 +41,7 @@ class _DialogInputState extends State<DialogInput> {
|
|||||||
child: AlertDialog(
|
child: AlertDialog(
|
||||||
title: LocalText(
|
title: LocalText(
|
||||||
context,
|
context,
|
||||||
widget.label,
|
widget.label!,
|
||||||
fontSize: 20,
|
fontSize: 20,
|
||||||
color: primaryColor,
|
color: primaryColor,
|
||||||
),
|
),
|
||||||
@@ -77,7 +77,7 @@ class _DialogInputState extends State<DialogInput> {
|
|||||||
fontWeight: FontWeight.bold,
|
fontWeight: FontWeight.bold,
|
||||||
),
|
),
|
||||||
onPressed: () async {
|
onPressed: () async {
|
||||||
if (!_formKey.currentState.validate()) return;
|
if (!_formKey.currentState!.validate()) return;
|
||||||
_save();
|
_save();
|
||||||
})
|
})
|
||||||
],
|
],
|
||||||
|
|||||||
@@ -6,13 +6,13 @@ import 'package:flutter/material.dart';
|
|||||||
import 'local_text.dart';
|
import 'local_text.dart';
|
||||||
|
|
||||||
class DiscountDropdown<T> extends StatelessWidget {
|
class DiscountDropdown<T> extends StatelessWidget {
|
||||||
final Function(T) callback;
|
final Function(T)? callback;
|
||||||
final IconData iconData;
|
final IconData? iconData;
|
||||||
final T selectedValue;
|
final T? selectedValue;
|
||||||
final List<T> values;
|
final List<T>? values;
|
||||||
|
|
||||||
const DiscountDropdown(
|
const DiscountDropdown(
|
||||||
{Key key, this.callback, this.iconData, this.selectedValue, this.values})
|
{Key? key, this.callback, this.iconData, this.selectedValue, this.values})
|
||||||
: super(key: key);
|
: super(key: key);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@@ -46,11 +46,11 @@ class DiscountDropdown<T> extends StatelessWidget {
|
|||||||
height: 1,
|
height: 1,
|
||||||
color: primaryColor,
|
color: primaryColor,
|
||||||
),
|
),
|
||||||
onChanged: (T newValue) {
|
onChanged: (T? newValue) {
|
||||||
callback(newValue);
|
callback!(newValue!);
|
||||||
},
|
},
|
||||||
isExpanded: true,
|
isExpanded: true,
|
||||||
items: values.map<DropdownMenuItem<T>>((T value) {
|
items: values!.map<DropdownMenuItem<T>>((T value) {
|
||||||
return DropdownMenuItem<T>(
|
return DropdownMenuItem<T>(
|
||||||
value: value,
|
value: value,
|
||||||
child: Text(value == null ? "" : (value as Discount).code,
|
child: Text(value == null ? "" : (value as Discount).code,
|
||||||
|
|||||||
@@ -4,12 +4,12 @@ import 'package:cached_network_image/cached_network_image.dart';
|
|||||||
import 'package:flutter/widgets.dart';
|
import 'package:flutter/widgets.dart';
|
||||||
|
|
||||||
class DisplayImageSource {
|
class DisplayImageSource {
|
||||||
String url;
|
String? url;
|
||||||
File file;
|
File? file;
|
||||||
DisplayImageSource({this.url, this.file});
|
DisplayImageSource({this.url, this.file});
|
||||||
|
|
||||||
ImageProvider get imageProvider =>
|
ImageProvider? get imageProvider =>
|
||||||
file == null ? CachedNetworkImageProvider(url) : FileImage(file);
|
file == null ? CachedNetworkImageProvider(url!) : FileImage(file!);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
bool operator ==(other) {
|
bool operator ==(other) {
|
||||||
|
|||||||
@@ -62,7 +62,7 @@ class DisplayText extends StatelessWidget {
|
|||||||
labelTextKey == null
|
labelTextKey == null
|
||||||
? Container()
|
? Container()
|
||||||
: Text(
|
: Text(
|
||||||
AppTranslations.of(context).text(labelTextKey!),
|
AppTranslations.of(context)!.text(labelTextKey!),
|
||||||
style: labelStyle,
|
style: labelStyle,
|
||||||
),
|
),
|
||||||
text == null
|
text == null
|
||||||
|
|||||||
@@ -5,10 +5,10 @@ import 'package:flutter/material.dart';
|
|||||||
import 'callbacks.dart';
|
import 'callbacks.dart';
|
||||||
|
|
||||||
class FcsExpansionTile extends StatefulWidget {
|
class FcsExpansionTile extends StatefulWidget {
|
||||||
final ValueChanged<bool> onExpansionChanged;
|
final ValueChanged<bool>? onExpansionChanged;
|
||||||
final CallBack onEditPress;
|
final CallBack? onEditPress;
|
||||||
final List<Widget> children;
|
final List<Widget>? children;
|
||||||
final Widget title;
|
final Widget? title;
|
||||||
final bool isEdit;
|
final bool isEdit;
|
||||||
const FcsExpansionTile(
|
const FcsExpansionTile(
|
||||||
{this.onExpansionChanged,
|
{this.onExpansionChanged,
|
||||||
@@ -21,7 +21,7 @@ class FcsExpansionTile extends StatefulWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class _FcsExpansionTileState extends State<FcsExpansionTile> {
|
class _FcsExpansionTileState extends State<FcsExpansionTile> {
|
||||||
bool expanded;
|
bool? expanded;
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
this.expanded = false;
|
this.expanded = false;
|
||||||
@@ -39,22 +39,22 @@ class _FcsExpansionTileState extends State<FcsExpansionTile> {
|
|||||||
expanded = value;
|
expanded = value;
|
||||||
});
|
});
|
||||||
if (widget.onExpansionChanged != null)
|
if (widget.onExpansionChanged != null)
|
||||||
widget.onExpansionChanged(value);
|
widget.onExpansionChanged!(value);
|
||||||
},
|
},
|
||||||
title: widget.title,
|
title: widget.title != null ? widget.title! : Container(),
|
||||||
children: widget.children,
|
children: widget.children != null ? widget.children! : [Container()],
|
||||||
trailing: widget.isEdit
|
trailing: widget.isEdit
|
||||||
? IconButton(
|
? IconButton(
|
||||||
padding: EdgeInsets.all(0),
|
padding: EdgeInsets.all(0),
|
||||||
iconSize: 20,
|
iconSize: 20,
|
||||||
onPressed: () =>
|
onPressed: () =>
|
||||||
widget.onEditPress != null ? widget.onEditPress() : {},
|
widget.onEditPress != null ? widget.onEditPress!() : {},
|
||||||
icon: Icon(
|
icon: Icon(
|
||||||
Icons.edit,
|
Icons.edit,
|
||||||
color: primaryColor,
|
color: primaryColor,
|
||||||
))
|
))
|
||||||
: AnimatedSwitcher(
|
: AnimatedSwitcher(
|
||||||
child: expanded
|
child: expanded!
|
||||||
? Icon(
|
? Icon(
|
||||||
Icons.remove,
|
Icons.remove,
|
||||||
color: primaryColor,
|
color: primaryColor,
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import 'package:flutter_icons/flutter_icons.dart';
|
import 'package:flutter_vector_icons/flutter_vector_icons.dart';
|
||||||
|
|
||||||
const cartonIconData = MaterialCommunityIcons.package;
|
const cartonIconData = MaterialCommunityIcons.package;
|
||||||
const customFeeIconData = MaterialCommunityIcons.security;
|
const customFeeIconData = MaterialCommunityIcons.security;
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import 'dart:io';
|
import 'dart:io';
|
||||||
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_icons/flutter_icons.dart';
|
import 'package:flutter_vector_icons/flutter_vector_icons.dart';
|
||||||
import 'package:image_picker/image_picker.dart';
|
import 'package:image_picker/image_picker.dart';
|
||||||
import 'local_text.dart';
|
import 'local_text.dart';
|
||||||
|
|
||||||
@@ -18,15 +18,15 @@ modelBottomSheet(BuildContext context, {final OnFile onFile}) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class ImageFile extends StatefulWidget {
|
class ImageFile extends StatefulWidget {
|
||||||
final OnFile onFile;
|
final OnFile? onFile;
|
||||||
|
|
||||||
const ImageFile({Key key, this.onFile}) : super(key: key);
|
const ImageFile({Key? key, this.onFile}) : super(key: key);
|
||||||
@override
|
@override
|
||||||
_ImageFileState createState() => _ImageFileState();
|
_ImageFileState createState() => _ImageFileState();
|
||||||
}
|
}
|
||||||
|
|
||||||
class _ImageFileState extends State<ImageFile> {
|
class _ImageFileState extends State<ImageFile> {
|
||||||
File selectedFile;
|
File? selectedFile;
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Container(
|
return Container(
|
||||||
@@ -44,7 +44,7 @@ class _ImageFileState extends State<ImageFile> {
|
|||||||
onTap: () async {
|
onTap: () async {
|
||||||
Navigator.pop(context);
|
Navigator.pop(context);
|
||||||
selectedFile = await pickImage(ImageSource.gallery);
|
selectedFile = await pickImage(ImageSource.gallery);
|
||||||
if (widget.onFile != null) widget.onFile(selectedFile);
|
if (widget.onFile != null) widget.onFile!(selectedFile!);
|
||||||
}),
|
}),
|
||||||
new ListTile(
|
new ListTile(
|
||||||
leading: CircleAvatar(
|
leading: CircleAvatar(
|
||||||
@@ -58,7 +58,7 @@ class _ImageFileState extends State<ImageFile> {
|
|||||||
Navigator.pop(context);
|
Navigator.pop(context);
|
||||||
selectedFile = await pickImage(ImageSource.camera);
|
selectedFile = await pickImage(ImageSource.camera);
|
||||||
|
|
||||||
if (widget.onFile != null) widget.onFile(selectedFile);
|
if (widget.onFile != null) widget.onFile!(selectedFile!);
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
new ListTile(
|
new ListTile(
|
||||||
@@ -75,7 +75,7 @@ class _ImageFileState extends State<ImageFile> {
|
|||||||
selectedFile = null;
|
selectedFile = null;
|
||||||
});
|
});
|
||||||
|
|
||||||
if (widget.onFile != null) widget.onFile(selectedFile);
|
if (widget.onFile != null) widget.onFile!(selectedFile!);
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
|
|||||||
@@ -8,10 +8,10 @@ import 'show_img.dart';
|
|||||||
typedef OnFile = void Function(File);
|
typedef OnFile = void Function(File);
|
||||||
|
|
||||||
class ImageUrl extends StatefulWidget {
|
class ImageUrl extends StatefulWidget {
|
||||||
final String title;
|
final String? title;
|
||||||
final String url;
|
final String? url;
|
||||||
|
|
||||||
const ImageUrl({Key key, this.title, this.url}) : super(key: key);
|
const ImageUrl({Key? key, this.title, this.url}) : super(key: key);
|
||||||
@override
|
@override
|
||||||
_ImageUrlState createState() => _ImageUrlState();
|
_ImageUrlState createState() => _ImageUrlState();
|
||||||
}
|
}
|
||||||
@@ -25,12 +25,12 @@ class _ImageUrlState extends State<ImageUrl> {
|
|||||||
context,
|
context,
|
||||||
MaterialPageRoute(
|
MaterialPageRoute(
|
||||||
builder: (context) =>
|
builder: (context) =>
|
||||||
ShowImage(url: widget.url, fileName: widget.title)),
|
ShowImage(url: widget.url!, fileName: widget.title!)),
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
child: Chip(
|
child: Chip(
|
||||||
avatar: Icon(Icons.image),
|
avatar: Icon(Icons.image),
|
||||||
label: Text(widget.title),
|
label: Text(widget.title!),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,19 +10,19 @@ class InputDate extends StatelessWidget {
|
|||||||
final String labelTextKey;
|
final String labelTextKey;
|
||||||
final IconData iconData;
|
final IconData iconData;
|
||||||
final TextEditingController controller;
|
final TextEditingController controller;
|
||||||
final FormFieldValidator<String> validator;
|
final FormFieldValidator<String>? validator;
|
||||||
final int maxLines;
|
final int maxLines;
|
||||||
final bool withBorder;
|
final bool withBorder;
|
||||||
final Color borderColor;
|
final Color? borderColor;
|
||||||
final TextInputType textInputType;
|
final TextInputType? textInputType;
|
||||||
final bool autoFocus;
|
final bool autoFocus;
|
||||||
final String dateFormatString;
|
final String dateFormatString;
|
||||||
|
|
||||||
const InputDate(
|
const InputDate(
|
||||||
{Key key,
|
{Key? key,
|
||||||
this.labelTextKey,
|
required this.labelTextKey,
|
||||||
this.iconData,
|
required this.iconData,
|
||||||
this.controller,
|
required this.controller,
|
||||||
this.validator,
|
this.validator,
|
||||||
this.maxLines = 1,
|
this.maxLines = 1,
|
||||||
this.withBorder = false,
|
this.withBorder = false,
|
||||||
@@ -72,7 +72,7 @@ class InputDate extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
labelText: labelTextKey == null
|
labelText: labelTextKey == null
|
||||||
? null
|
? null
|
||||||
: AppTranslations.of(context).text(labelTextKey),
|
: AppTranslations.of(context)!.text(labelTextKey),
|
||||||
labelStyle: languageModel.isEng
|
labelStyle: languageModel.isEng
|
||||||
? newLabelStyle(color: Colors.black54, fontSize: 20)
|
? newLabelStyle(color: Colors.black54, fontSize: 20)
|
||||||
: newLabelStyleMM(color: Colors.black54, fontSize: 20),
|
: newLabelStyleMM(color: Colors.black54, fontSize: 20),
|
||||||
|
|||||||
@@ -6,20 +6,20 @@ import 'package:flutter/material.dart';
|
|||||||
import 'package:provider/provider.dart';
|
import 'package:provider/provider.dart';
|
||||||
|
|
||||||
class InputText extends StatelessWidget {
|
class InputText extends StatelessWidget {
|
||||||
final String labelTextKey;
|
final String? labelTextKey;
|
||||||
final IconData iconData;
|
final IconData? iconData;
|
||||||
final TextEditingController controller;
|
final TextEditingController? controller;
|
||||||
final FormFieldValidator<String> validator;
|
final FormFieldValidator<String>? validator;
|
||||||
final int maxLines;
|
final int maxLines;
|
||||||
final bool withBorder;
|
final bool withBorder;
|
||||||
final Color borderColor;
|
final Color? borderColor;
|
||||||
final TextInputType textInputType;
|
final TextInputType? textInputType;
|
||||||
final bool autoFocus;
|
final bool autoFocus;
|
||||||
final TextAlign textAlign;
|
final TextAlign textAlign;
|
||||||
final bool enabled;
|
final bool enabled;
|
||||||
|
|
||||||
const InputText(
|
const InputText(
|
||||||
{Key key,
|
{Key? key,
|
||||||
this.labelTextKey,
|
this.labelTextKey,
|
||||||
this.iconData,
|
this.iconData,
|
||||||
this.controller,
|
this.controller,
|
||||||
@@ -30,7 +30,7 @@ class InputText extends StatelessWidget {
|
|||||||
this.autoFocus = false,
|
this.autoFocus = false,
|
||||||
this.textInputType,
|
this.textInputType,
|
||||||
this.enabled = true,
|
this.enabled = true,
|
||||||
this.textAlign})
|
this.textAlign = TextAlign.start})
|
||||||
: super(key: key);
|
: super(key: key);
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
@@ -46,7 +46,7 @@ class InputText extends StatelessWidget {
|
|||||||
style: textStyle,
|
style: textStyle,
|
||||||
maxLines: maxLines,
|
maxLines: maxLines,
|
||||||
keyboardType: textInputType,
|
keyboardType: textInputType,
|
||||||
textAlign: textAlign ?? TextAlign.start,
|
textAlign: textAlign,
|
||||||
decoration: new InputDecoration(
|
decoration: new InputDecoration(
|
||||||
// hintText: '',
|
// hintText: '',
|
||||||
hintStyle: TextStyle(
|
hintStyle: TextStyle(
|
||||||
@@ -54,7 +54,7 @@ class InputText extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
labelText: labelTextKey == null
|
labelText: labelTextKey == null
|
||||||
? null
|
? null
|
||||||
: AppTranslations.of(context).text(labelTextKey),
|
: AppTranslations.of(context)!.text(labelTextKey!),
|
||||||
labelStyle: languageModel.isEng
|
labelStyle: languageModel.isEng
|
||||||
? newLabelStyle(color: Colors.black54, fontSize: 20)
|
? newLabelStyle(color: Colors.black54, fontSize: 20)
|
||||||
: newLabelStyleMM(color: Colors.black54, fontSize: 20),
|
: newLabelStyleMM(color: Colors.black54, fontSize: 20),
|
||||||
|
|||||||
@@ -7,18 +7,18 @@ import 'package:intl/intl.dart';
|
|||||||
import 'package:provider/provider.dart';
|
import 'package:provider/provider.dart';
|
||||||
|
|
||||||
class InputTime extends StatelessWidget {
|
class InputTime extends StatelessWidget {
|
||||||
final String labelTextKey;
|
final String? labelTextKey;
|
||||||
final IconData iconData;
|
final IconData? iconData;
|
||||||
final TextEditingController controller;
|
final TextEditingController? controller;
|
||||||
final FormFieldValidator<String> validator;
|
final FormFieldValidator<String>? validator;
|
||||||
final int maxLines;
|
final int maxLines;
|
||||||
final bool withBorder;
|
final bool withBorder;
|
||||||
final Color borderColor;
|
final Color? borderColor;
|
||||||
final TextInputType textInputType;
|
final TextInputType? textInputType;
|
||||||
final bool autoFocus;
|
final bool autoFocus;
|
||||||
|
|
||||||
const InputTime(
|
const InputTime(
|
||||||
{Key key,
|
{Key? key,
|
||||||
this.labelTextKey,
|
this.labelTextKey,
|
||||||
this.iconData,
|
this.iconData,
|
||||||
this.controller,
|
this.controller,
|
||||||
@@ -45,14 +45,14 @@ class InputTime extends StatelessWidget {
|
|||||||
try {
|
try {
|
||||||
final format = DateFormat.jm(); //"6:00 AM"
|
final format = DateFormat.jm(); //"6:00 AM"
|
||||||
initialDate =
|
initialDate =
|
||||||
TimeOfDay.fromDateTime(format.parse(controller.text));
|
TimeOfDay.fromDateTime(format.parse(controller!.text));
|
||||||
// var values = controller.text.split(":");
|
// var values = controller.text.split(":");
|
||||||
// initialDate = TimeOfDay(
|
// initialDate = TimeOfDay(
|
||||||
// hour: int.parse(values[0]), minute: int.parse(values[1]));
|
// hour: int.parse(values[0]), minute: int.parse(values[1]));
|
||||||
} catch (e) {} // ignore error
|
} catch (e) {} // ignore error
|
||||||
}
|
}
|
||||||
|
|
||||||
TimeOfDay t = await showTimePicker(
|
TimeOfDay? t = await showTimePicker(
|
||||||
initialTime: initialDate,
|
initialTime: initialDate,
|
||||||
context: context,
|
context: context,
|
||||||
);
|
);
|
||||||
@@ -61,7 +61,7 @@ class InputTime extends StatelessWidget {
|
|||||||
final now = new DateTime.now();
|
final now = new DateTime.now();
|
||||||
final dt =
|
final dt =
|
||||||
DateTime(now.year, now.month, now.day, t.hour, t.minute);
|
DateTime(now.year, now.month, now.day, t.hour, t.minute);
|
||||||
controller.text = "${format.format(dt)}";
|
controller!.text = "${format.format(dt)}";
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
controller: controller,
|
controller: controller,
|
||||||
@@ -77,7 +77,7 @@ class InputTime extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
labelText: labelTextKey == null
|
labelText: labelTextKey == null
|
||||||
? null
|
? null
|
||||||
: AppTranslations.of(context).text(labelTextKey),
|
: AppTranslations.of(context)!.text(labelTextKey!),
|
||||||
labelStyle: languageModel.isEng
|
labelStyle: languageModel.isEng
|
||||||
? newLabelStyle(color: Colors.black54, fontSize: 20)
|
? newLabelStyle(color: Colors.black54, fontSize: 20)
|
||||||
: newLabelStyleMM(color: Colors.black54, fontSize: 20),
|
: newLabelStyleMM(color: Colors.black54, fontSize: 20),
|
||||||
|
|||||||
@@ -10,13 +10,13 @@ const MAX_INC = 50.0;
|
|||||||
const MAX_FEET = 25.0;
|
const MAX_FEET = 25.0;
|
||||||
|
|
||||||
class LengthPicker extends StatefulWidget {
|
class LengthPicker extends StatefulWidget {
|
||||||
final TextEditingController controller;
|
final TextEditingController? controller;
|
||||||
final String lableKey;
|
final String? lableKey;
|
||||||
final bool isReadOnly;
|
final bool isReadOnly;
|
||||||
final bool displayFeet;
|
final bool displayFeet;
|
||||||
|
|
||||||
const LengthPicker(
|
const LengthPicker(
|
||||||
{Key key,
|
{Key? key,
|
||||||
this.controller,
|
this.controller,
|
||||||
this.lableKey,
|
this.lableKey,
|
||||||
this.isReadOnly = false,
|
this.isReadOnly = false,
|
||||||
@@ -35,14 +35,14 @@ class _LengthPickerState extends State<LengthPicker> {
|
|||||||
super.initState();
|
super.initState();
|
||||||
if (widget.controller != null) {
|
if (widget.controller != null) {
|
||||||
_setText();
|
_setText();
|
||||||
widget.controller.addListener(() {
|
widget.controller!.addListener(() {
|
||||||
_setText();
|
_setText();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
_setText() {
|
_setText() {
|
||||||
double v = double.parse(widget.controller.text, (s) => 0);
|
double v = double.parse(widget.controller!.text, (s) => 0);
|
||||||
int _v = v.toInt();
|
int _v = v.toInt();
|
||||||
|
|
||||||
int f = (v / 12).floor();
|
int f = (v / 12).floor();
|
||||||
@@ -72,8 +72,8 @@ class _LengthPickerState extends State<LengthPicker> {
|
|||||||
context: context,
|
context: context,
|
||||||
builder: (BuildContext context) {
|
builder: (BuildContext context) {
|
||||||
return LengthPickerDialog(
|
return LengthPickerDialog(
|
||||||
controller: widget.controller,
|
controller: widget.controller!,
|
||||||
labelKey: widget.lableKey,
|
labelKey: widget.lableKey!,
|
||||||
displayFeet: widget.displayFeet,
|
displayFeet: widget.displayFeet,
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
@@ -82,12 +82,12 @@ class _LengthPickerState extends State<LengthPicker> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class LengthPickerDialog extends StatefulWidget {
|
class LengthPickerDialog extends StatefulWidget {
|
||||||
final TextEditingController controller;
|
final TextEditingController? controller;
|
||||||
final String labelKey;
|
final String? labelKey;
|
||||||
final bool displayFeet;
|
final bool? displayFeet;
|
||||||
|
|
||||||
const LengthPickerDialog(
|
const LengthPickerDialog(
|
||||||
{Key key, this.controller, this.labelKey, this.displayFeet})
|
{Key? key, this.controller, this.labelKey, this.displayFeet})
|
||||||
: super(key: key);
|
: super(key: key);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@@ -95,8 +95,8 @@ class LengthPickerDialog extends StatefulWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class _LengthPickerDialogState extends State<LengthPickerDialog> {
|
class _LengthPickerDialogState extends State<LengthPickerDialog> {
|
||||||
int _valueFeet;
|
late int _valueFeet;
|
||||||
int _valueInc;
|
late int _valueInc;
|
||||||
TextEditingController inchInputController = TextEditingController();
|
TextEditingController inchInputController = TextEditingController();
|
||||||
TextEditingController feetInputController = TextEditingController();
|
TextEditingController feetInputController = TextEditingController();
|
||||||
final _focusNode = FocusNode();
|
final _focusNode = FocusNode();
|
||||||
@@ -107,9 +107,9 @@ class _LengthPickerDialogState extends State<LengthPickerDialog> {
|
|||||||
_valueFeet = 0;
|
_valueFeet = 0;
|
||||||
_valueInc = 0;
|
_valueInc = 0;
|
||||||
if (widget.controller != null) {
|
if (widget.controller != null) {
|
||||||
double v = double.parse(widget.controller.text, (s) => 0);
|
double v = double.parse(widget.controller!.text, (s) => 0);
|
||||||
_valueFeet = (v / 12).floor();
|
_valueFeet = (v / 12).floor();
|
||||||
_valueInc = widget.displayFeet ? (v % 12).toInt() : v.toInt();
|
_valueInc = widget.displayFeet! ? (v % 12).toInt() : v.toInt();
|
||||||
inchInputController.text = _valueInc.toString();
|
inchInputController.text = _valueInc.toString();
|
||||||
feetInputController.text = _valueFeet.toString();
|
feetInputController.text = _valueFeet.toString();
|
||||||
}
|
}
|
||||||
@@ -144,7 +144,7 @@ class _LengthPickerDialogState extends State<LengthPickerDialog> {
|
|||||||
borderSide: BorderSide(color: primaryColor, width: 1.0),
|
borderSide: BorderSide(color: primaryColor, width: 1.0),
|
||||||
),
|
),
|
||||||
enabledBorder: OutlineInputBorder(
|
enabledBorder: OutlineInputBorder(
|
||||||
borderSide: BorderSide(color: Colors.grey[400], width: 1.0),
|
borderSide: BorderSide(color: Colors.grey.shade400, width: 1.0),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@@ -196,7 +196,7 @@ class _LengthPickerDialogState extends State<LengthPickerDialog> {
|
|||||||
borderSide: BorderSide(color: primaryColor, width: 1.0),
|
borderSide: BorderSide(color: primaryColor, width: 1.0),
|
||||||
),
|
),
|
||||||
enabledBorder: OutlineInputBorder(
|
enabledBorder: OutlineInputBorder(
|
||||||
borderSide: BorderSide(color: Colors.grey[400], width: 1.0),
|
borderSide: BorderSide(color: Colors.grey.shade400, width: 1.0),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@@ -233,14 +233,14 @@ class _LengthPickerDialogState extends State<LengthPickerDialog> {
|
|||||||
title: Center(
|
title: Center(
|
||||||
child: LocalText(
|
child: LocalText(
|
||||||
context,
|
context,
|
||||||
widget.labelKey,
|
widget.labelKey!,
|
||||||
color: primaryColor,
|
color: primaryColor,
|
||||||
fontSize: 16,
|
fontSize: 16,
|
||||||
)),
|
)),
|
||||||
children: [
|
children: [
|
||||||
Row(
|
Row(
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
||||||
children: widget.displayFeet
|
children: widget.displayFeet!
|
||||||
? [
|
? [
|
||||||
Container(width: 100, child: feetBox),
|
Container(width: 100, child: feetBox),
|
||||||
Container(width: 100, child: inchBox),
|
Container(width: 100, child: inchBox),
|
||||||
@@ -252,7 +252,7 @@ class _LengthPickerDialogState extends State<LengthPickerDialog> {
|
|||||||
SizedBox(
|
SizedBox(
|
||||||
height: 10,
|
height: 10,
|
||||||
),
|
),
|
||||||
widget.displayFeet
|
widget.displayFeet!
|
||||||
? Column(
|
? Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
@@ -295,11 +295,11 @@ class _LengthPickerDialogState extends State<LengthPickerDialog> {
|
|||||||
),
|
),
|
||||||
Slider(
|
Slider(
|
||||||
activeColor: primaryColor,
|
activeColor: primaryColor,
|
||||||
value: _valueInc.toDouble() > (widget.displayFeet ? 11 : MAX_INC)
|
value: _valueInc.toDouble() > (widget.displayFeet! ? 11 : MAX_INC)
|
||||||
? 0
|
? 0
|
||||||
: _valueInc.toDouble(),
|
: _valueInc.toDouble(),
|
||||||
min: 0,
|
min: 0,
|
||||||
max: widget.displayFeet ? 11 : MAX_INC,
|
max: widget.displayFeet! ? 11 : MAX_INC,
|
||||||
divisions: 100,
|
divisions: 100,
|
||||||
label: (_valueInc ?? 0).round().toString(),
|
label: (_valueInc ?? 0).round().toString(),
|
||||||
onChanged: (double v) {
|
onChanged: (double v) {
|
||||||
@@ -318,10 +318,10 @@ class _LengthPickerDialogState extends State<LengthPickerDialog> {
|
|||||||
});
|
});
|
||||||
int _v = _valueInc.round() + _valueFeet.round() * 12;
|
int _v = _valueInc.round() + _valueFeet.round() * 12;
|
||||||
if (widget.controller != null) {
|
if (widget.controller != null) {
|
||||||
widget.controller.text = _v.toString();
|
widget.controller!.text = _v.toString();
|
||||||
}
|
}
|
||||||
feetInputController.text =
|
feetInputController.text =
|
||||||
widget.displayFeet ? _valueFeet.round().toString() : _v.toString();
|
widget.displayFeet! ? _valueFeet.round().toString() : _v.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
_updateInc(double v) {
|
_updateInc(double v) {
|
||||||
@@ -330,8 +330,8 @@ class _LengthPickerDialogState extends State<LengthPickerDialog> {
|
|||||||
});
|
});
|
||||||
int _v = _valueInc.round() + _valueFeet.round() * 12;
|
int _v = _valueInc.round() + _valueFeet.round() * 12;
|
||||||
if (widget.controller != null) {
|
if (widget.controller != null) {
|
||||||
widget.controller.text =
|
widget.controller!.text =
|
||||||
widget.displayFeet ? _v.toString() : _valueInc.toString();
|
widget.displayFeet! ? _v.toString() : _valueInc.toString();
|
||||||
}
|
}
|
||||||
inchInputController.text = _valueInc.toString();
|
inchInputController.text = _valueInc.toString();
|
||||||
}
|
}
|
||||||
@@ -343,8 +343,8 @@ class _LengthPickerDialogState extends State<LengthPickerDialog> {
|
|||||||
});
|
});
|
||||||
int _v = _valueInc.round() + _valueFeet.round() * 12;
|
int _v = _valueInc.round() + _valueFeet.round() * 12;
|
||||||
if (widget.controller != null) {
|
if (widget.controller != null) {
|
||||||
widget.controller.text =
|
widget.controller!.text =
|
||||||
widget.displayFeet ? _v.toString() : _valueInc.toString();
|
widget.displayFeet! ? _v.toString() : _valueInc.toString();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -355,7 +355,7 @@ class _LengthPickerDialogState extends State<LengthPickerDialog> {
|
|||||||
});
|
});
|
||||||
int _v = _valueInc.round() + _valueFeet.round() * 12;
|
int _v = _valueInc.round() + _valueFeet.round() * 12;
|
||||||
if (widget.controller != null) {
|
if (widget.controller != null) {
|
||||||
widget.controller.text = _v.toString();
|
widget.controller!.text = _v.toString();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -6,13 +6,13 @@ import 'package:flutter/material.dart';
|
|||||||
import 'callbacks.dart';
|
import 'callbacks.dart';
|
||||||
|
|
||||||
class LocalButton extends StatelessWidget {
|
class LocalButton extends StatelessWidget {
|
||||||
final CallBack callBack;
|
final CallBack? callBack;
|
||||||
final IconData iconData;
|
final IconData? iconData;
|
||||||
final String textKey;
|
final String? textKey;
|
||||||
final Color color;
|
final Color? color;
|
||||||
|
|
||||||
const LocalButton(
|
const LocalButton(
|
||||||
{Key key,
|
{Key? key,
|
||||||
this.callBack,
|
this.callBack,
|
||||||
this.iconData,
|
this.iconData,
|
||||||
this.textKey,
|
this.textKey,
|
||||||
@@ -33,7 +33,7 @@ class LocalButton extends StatelessWidget {
|
|||||||
minWidth: 900.0,
|
minWidth: 900.0,
|
||||||
height: 100.0,
|
height: 100.0,
|
||||||
child: FlatButton(
|
child: FlatButton(
|
||||||
onPressed: callBack == null ? null : () => callBack(),
|
onPressed: callBack == null ? null : () => callBack!(),
|
||||||
child: Row(
|
child: Row(
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
children: [
|
children: [
|
||||||
@@ -48,7 +48,7 @@ class LocalButton extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
LocalText(
|
LocalText(
|
||||||
context,
|
context,
|
||||||
textKey,
|
textKey!,
|
||||||
color: Colors.white,
|
color: Colors.white,
|
||||||
fontSize: 16,
|
fontSize: 16,
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -5,15 +5,15 @@ import 'package:flutter/material.dart';
|
|||||||
import 'local_text.dart';
|
import 'local_text.dart';
|
||||||
|
|
||||||
class LocalDropdown<T> extends StatelessWidget {
|
class LocalDropdown<T> extends StatelessWidget {
|
||||||
final Function(T) callback;
|
final Function(T)? callback;
|
||||||
final IconData iconData;
|
final IconData? iconData;
|
||||||
final T selectedValue;
|
final T? selectedValue;
|
||||||
final List<T> values;
|
final List<T>? values;
|
||||||
final Function(T) display;
|
final Function(T)? display;
|
||||||
final String labelKey;
|
final String? labelKey;
|
||||||
|
|
||||||
const LocalDropdown(
|
const LocalDropdown(
|
||||||
{Key key,
|
{Key? key,
|
||||||
this.callback,
|
this.callback,
|
||||||
this.iconData,
|
this.iconData,
|
||||||
this.selectedValue,
|
this.selectedValue,
|
||||||
@@ -40,7 +40,7 @@ class LocalDropdown<T> extends StatelessWidget {
|
|||||||
padding: const EdgeInsets.only(right: 18.0),
|
padding: const EdgeInsets.only(right: 18.0),
|
||||||
child: LocalText(
|
child: LocalText(
|
||||||
context,
|
context,
|
||||||
labelKey,
|
labelKey!,
|
||||||
color: Colors.black54,
|
color: Colors.black54,
|
||||||
fontSize: 16,
|
fontSize: 16,
|
||||||
),
|
),
|
||||||
@@ -53,20 +53,20 @@ class LocalDropdown<T> extends StatelessWidget {
|
|||||||
height: 1,
|
height: 1,
|
||||||
color: Colors.grey,
|
color: Colors.grey,
|
||||||
),
|
),
|
||||||
onChanged: (T newValue) {
|
onChanged: (T? newValue) {
|
||||||
callback(newValue);
|
callback!(newValue!);
|
||||||
},
|
},
|
||||||
isExpanded: true,
|
isExpanded: true,
|
||||||
items: values == null
|
items: values == null
|
||||||
? []
|
? []
|
||||||
: values.map<DropdownMenuItem<T>>((T value) {
|
: values!.map<DropdownMenuItem<T>>((T value) {
|
||||||
return DropdownMenuItem<T>(
|
return DropdownMenuItem<T>(
|
||||||
value: value,
|
value: value,
|
||||||
child: Text(
|
child: Text(
|
||||||
value == null
|
value == null
|
||||||
? ""
|
? ""
|
||||||
: display != null
|
: display != null
|
||||||
? display(value)
|
? display!(value)
|
||||||
: value.toString(),
|
: value.toString(),
|
||||||
overflow: TextOverflow.ellipsis,
|
overflow: TextOverflow.ellipsis,
|
||||||
style: TextStyle(color: primaryColor)),
|
style: TextStyle(color: primaryColor)),
|
||||||
|
|||||||
@@ -7,15 +7,15 @@ import 'local_popupmenu.dart';
|
|||||||
typedef PopupMenuCallback = Function(LocalPopupMenu popupMenu);
|
typedef PopupMenuCallback = Function(LocalPopupMenu popupMenu);
|
||||||
|
|
||||||
class LocalPopupMenuButton extends StatefulWidget {
|
class LocalPopupMenuButton extends StatefulWidget {
|
||||||
final PopupMenuCallback popupMenuCallback;
|
final PopupMenuCallback? popupMenuCallback;
|
||||||
final List<LocalPopupMenu> popmenus;
|
final List<LocalPopupMenu>? popmenus;
|
||||||
final bool multiSelect;
|
final bool multiSelect;
|
||||||
final bool selectable;
|
final bool selectable;
|
||||||
final IconData buttonIcon;
|
final IconData? buttonIcon;
|
||||||
final Color buttonColor;
|
final Color buttonColor;
|
||||||
|
|
||||||
const LocalPopupMenuButton(
|
const LocalPopupMenuButton(
|
||||||
{Key key,
|
{Key? key,
|
||||||
this.popupMenuCallback,
|
this.popupMenuCallback,
|
||||||
this.popmenus,
|
this.popmenus,
|
||||||
this.buttonIcon,
|
this.buttonIcon,
|
||||||
@@ -29,11 +29,11 @@ class LocalPopupMenuButton extends StatefulWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class _LocalPopupMenuButtonState extends State<LocalPopupMenuButton> {
|
class _LocalPopupMenuButtonState extends State<LocalPopupMenuButton> {
|
||||||
List<LocalPopupMenu> popmenus;
|
late List<LocalPopupMenu> popmenus;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
popmenus = widget.popmenus;
|
popmenus = widget.popmenus!;
|
||||||
super.initState();
|
super.initState();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -64,7 +64,7 @@ class _LocalPopupMenuButtonState extends State<LocalPopupMenuButton> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (selected.enabled && widget.popupMenuCallback != null)
|
if (selected.enabled && widget.popupMenuCallback != null)
|
||||||
widget.popupMenuCallback(selected);
|
widget.popupMenuCallback!(selected);
|
||||||
},
|
},
|
||||||
icon: Container(
|
icon: Container(
|
||||||
width: 30,
|
width: 30,
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
class LocalPopupMenu {
|
class LocalPopupMenu {
|
||||||
int id;
|
int id;
|
||||||
String textKey;
|
String? textKey;
|
||||||
bool selected;
|
bool selected;
|
||||||
bool highlight;
|
bool highlight;
|
||||||
bool enabled;
|
bool enabled;
|
||||||
LocalPopupMenu(
|
LocalPopupMenu(
|
||||||
{this.id,
|
{required this.id,
|
||||||
this.textKey,
|
this.textKey,
|
||||||
this.selected = false,
|
this.selected = false,
|
||||||
this.highlight = false,
|
this.highlight = false,
|
||||||
|
|||||||
@@ -3,15 +3,15 @@ import 'package:flutter/cupertino.dart';
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
class LocalRadioButtons<T> extends StatelessWidget {
|
class LocalRadioButtons<T> extends StatelessWidget {
|
||||||
final Function(T) callback;
|
final Function(T)? callback;
|
||||||
final IconData iconData;
|
final IconData? iconData;
|
||||||
final T selectedValue;
|
final T? selectedValue;
|
||||||
final List<T> values;
|
final List<T>? values;
|
||||||
final bool readOnly;
|
final bool readOnly;
|
||||||
final bool hideUnselected;
|
final bool hideUnselected;
|
||||||
|
|
||||||
const LocalRadioButtons(
|
const LocalRadioButtons(
|
||||||
{Key key,
|
{Key? key,
|
||||||
this.callback,
|
this.callback,
|
||||||
this.iconData,
|
this.iconData,
|
||||||
this.selectedValue,
|
this.selectedValue,
|
||||||
@@ -26,19 +26,19 @@ class LocalRadioButtons<T> extends StatelessWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
List<Widget> getChildren() {
|
List<Widget> getChildren() {
|
||||||
return values
|
return values!
|
||||||
.toList()
|
.toList()
|
||||||
.map((e) => SizedBox(
|
.map((e) => SizedBox(
|
||||||
height: 30,
|
height: 30,
|
||||||
child: InkWell(
|
child: InkWell(
|
||||||
onTap: () => callback(e),
|
onTap: () => callback!(e),
|
||||||
child: Row(children: <Widget>[
|
child: Row(children: <Widget>[
|
||||||
Radio<T>(
|
Radio<T>(
|
||||||
activeColor: primaryColor,
|
activeColor: primaryColor,
|
||||||
groupValue: selectedValue,
|
groupValue: selectedValue,
|
||||||
value: e,
|
value: e,
|
||||||
onChanged: (T value) {
|
onChanged: (T? value) {
|
||||||
callback(value);
|
callback!(value!);
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
Text(e.toString()),
|
Text(e.toString()),
|
||||||
@@ -48,7 +48,7 @@ class LocalRadioButtons<T> extends StatelessWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
List<Widget> getReadonlyChildren() {
|
List<Widget> getReadonlyChildren() {
|
||||||
return values
|
return values!
|
||||||
.toList()
|
.toList()
|
||||||
.map((e) => hideUnselected && e == selectedValue
|
.map((e) => hideUnselected && e == selectedValue
|
||||||
? SizedBox(
|
? SizedBox(
|
||||||
|
|||||||
@@ -7,26 +7,26 @@ import 'package:fcs/helpers/theme.dart';
|
|||||||
class LocalText extends Text {
|
class LocalText extends Text {
|
||||||
final BuildContext context;
|
final BuildContext context;
|
||||||
LocalText(this.context, String translationKey,
|
LocalText(this.context, String translationKey,
|
||||||
{Color color,
|
{Color? color,
|
||||||
double fontSize,
|
double? fontSize,
|
||||||
FontWeight fontWeight,
|
FontWeight? fontWeight,
|
||||||
List<String> translationVariables,
|
List<String>? translationVariables,
|
||||||
String text,
|
String? text,
|
||||||
bool underline = false})
|
bool underline = false})
|
||||||
: super(
|
: super(
|
||||||
text ??
|
text ??
|
||||||
AppTranslations.of(context).text(translationKey,
|
AppTranslations.of(context)!.text(translationKey,
|
||||||
translationVariables: translationVariables),
|
translationVariables: translationVariables),
|
||||||
style: Provider.of<LanguageModel>(context, listen: false).isEng
|
style: Provider.of<LanguageModel>(context, listen: false).isEng
|
||||||
? newLabelStyle(
|
? newLabelStyle(
|
||||||
color: color,
|
color: color!,
|
||||||
fontSize: fontSize,
|
fontSize: fontSize!,
|
||||||
fontWeight: fontWeight,
|
fontWeight: fontWeight!,
|
||||||
underline: underline)
|
underline: underline)
|
||||||
: newLabelStyleMM(
|
: newLabelStyleMM(
|
||||||
color: color,
|
color: color!,
|
||||||
fontSize: fontSize,
|
fontSize: fontSize!,
|
||||||
fontWeight: fontWeight,
|
fontWeight: fontWeight!,
|
||||||
underline: underline));
|
underline: underline));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -35,10 +35,10 @@ class LocalLargeTitle extends Text {
|
|||||||
LocalLargeTitle(
|
LocalLargeTitle(
|
||||||
this.context,
|
this.context,
|
||||||
String translationKey, {
|
String translationKey, {
|
||||||
Color color,
|
Color? color,
|
||||||
List<String> translationVariables,
|
List<String>? translationVariables,
|
||||||
}) : super(
|
}) : super(
|
||||||
AppTranslations.of(context).text(translationKey,
|
AppTranslations.of(context)!.text(translationKey,
|
||||||
translationVariables: translationVariables),
|
translationVariables: translationVariables),
|
||||||
style: Provider.of<LanguageModel>(context).isEng
|
style: Provider.of<LanguageModel>(context).isEng
|
||||||
? TextStyle(color: color)
|
? TextStyle(color: color)
|
||||||
@@ -48,7 +48,7 @@ class LocalLargeTitle extends Text {
|
|||||||
class TextLocalStyle extends Text {
|
class TextLocalStyle extends Text {
|
||||||
final BuildContext context;
|
final BuildContext context;
|
||||||
TextLocalStyle(this.context, String text,
|
TextLocalStyle(this.context, String text,
|
||||||
{Color color, double fontSize, FontWeight fontWeight})
|
{Color? color, double? fontSize, FontWeight? fontWeight})
|
||||||
: super(text,
|
: super(text,
|
||||||
style: Provider.of<LanguageModel>(context).isEng
|
style: Provider.of<LanguageModel>(context).isEng
|
||||||
? TextStyle(
|
? TextStyle(
|
||||||
|
|||||||
@@ -4,10 +4,10 @@ import 'package:flutter/cupertino.dart';
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
class LocalTitle extends StatelessWidget {
|
class LocalTitle extends StatelessWidget {
|
||||||
final String textKey;
|
final String? textKey;
|
||||||
final Widget trailing;
|
final Widget? trailing;
|
||||||
|
|
||||||
const LocalTitle({Key key, this.textKey, this.trailing}) : super(key: key);
|
const LocalTitle({Key? key, this.textKey, this.trailing}) : super(key: key);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
@@ -20,13 +20,13 @@ class LocalTitle extends StatelessWidget {
|
|||||||
children: [
|
children: [
|
||||||
LocalText(
|
LocalText(
|
||||||
context,
|
context,
|
||||||
textKey,
|
textKey!,
|
||||||
fontSize: 20,
|
fontSize: 20,
|
||||||
fontWeight: FontWeight.bold,
|
fontWeight: FontWeight.bold,
|
||||||
color: primaryColor,
|
color: primaryColor,
|
||||||
),
|
),
|
||||||
trailing != null ? Spacer() : Container(),
|
trailing != null ? Spacer() : Container(),
|
||||||
trailing != null ? trailing : Container()
|
trailing != null ? trailing! : Container()
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -79,16 +79,16 @@ class MultiImgController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
List<File> get getUpdatedFile {
|
List<File> get getUpdatedFile {
|
||||||
List<File> _addfiles = getAddedFile;
|
List<File?> _addfiles = getAddedFile;
|
||||||
this.imageFiles.addAll(_addfiles);
|
this.imageFiles.addAll(_addfiles);
|
||||||
return this.imageFiles;
|
return this.imageFiles;
|
||||||
}
|
}
|
||||||
|
|
||||||
List<File> get getAddedFile {
|
List<File?> get getAddedFile {
|
||||||
return addedFiles.map((e) => e.file).toList();
|
return addedFiles.map((e) => e.file).toList();
|
||||||
}
|
}
|
||||||
|
|
||||||
List<String> get getDeletedUrl {
|
List<String?> get getDeletedUrl {
|
||||||
return removedFiles.map((e) => e.url).toList();
|
return removedFiles.map((e) => e.url).toList();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ import 'package:fcs/pages/widgets/show_img.dart';
|
|||||||
import 'package:fcs/pages/widgets/show_multiple_img.dart';
|
import 'package:fcs/pages/widgets/show_multiple_img.dart';
|
||||||
import 'package:flutter/cupertino.dart';
|
import 'package:flutter/cupertino.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_icons/flutter_icons.dart';
|
import 'package:flutter_vector_icons/flutter_vector_icons.dart';
|
||||||
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
|
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
|
||||||
import 'package:image_picker/image_picker.dart';
|
import 'package:image_picker/image_picker.dart';
|
||||||
|
|
||||||
@@ -18,13 +18,13 @@ import 'multi_img_controller.dart';
|
|||||||
typedef OnFile = void Function(File);
|
typedef OnFile = void Function(File);
|
||||||
|
|
||||||
class MultiImageFile extends StatefulWidget {
|
class MultiImageFile extends StatefulWidget {
|
||||||
final String title;
|
final String? title;
|
||||||
final bool enabled;
|
final bool enabled;
|
||||||
final ImageSource imageSource;
|
final ImageSource imageSource;
|
||||||
final MultiImgController controller;
|
final MultiImgController? controller;
|
||||||
|
|
||||||
const MultiImageFile(
|
const MultiImageFile(
|
||||||
{Key key,
|
{Key? key,
|
||||||
this.title,
|
this.title,
|
||||||
this.enabled = true,
|
this.enabled = true,
|
||||||
this.controller,
|
this.controller,
|
||||||
@@ -39,10 +39,10 @@ class _MultiImageFileState extends State<MultiImageFile> {
|
|||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
fileContainers = widget.controller.fileContainers;
|
fileContainers = widget.controller!.fileContainers;
|
||||||
widget.controller.onChange(() {
|
widget.controller!.onChange(() {
|
||||||
setState(() {
|
setState(() {
|
||||||
this.fileContainers = widget.controller.fileContainers;
|
this.fileContainers = widget.controller!.fileContainers;
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -133,7 +133,7 @@ class _MultiImageFileState extends State<MultiImageFile> {
|
|||||||
fit: BoxFit.cover,
|
fit: BoxFit.cover,
|
||||||
width: 50,
|
width: 50,
|
||||||
height: 50,
|
height: 50,
|
||||||
imageUrl: fileContainers[index].url,
|
imageUrl: fileContainers[index].url!,
|
||||||
placeholder: (context, url) => Column(
|
placeholder: (context, url) => Column(
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
mainAxisSize: MainAxisSize.min,
|
mainAxisSize: MainAxisSize.min,
|
||||||
@@ -150,7 +150,7 @@ class _MultiImageFileState extends State<MultiImageFile> {
|
|||||||
: FittedBox(
|
: FittedBox(
|
||||||
fit: BoxFit.cover,
|
fit: BoxFit.cover,
|
||||||
child: Image.file(
|
child: Image.file(
|
||||||
fileContainers[index].file,
|
fileContainers[index].file!,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@@ -189,13 +189,13 @@ class _MultiImageFileState extends State<MultiImageFile> {
|
|||||||
fileContainer.file = selectedFile;
|
fileContainer.file = selectedFile;
|
||||||
setState(() {
|
setState(() {
|
||||||
fileContainers.add(fileContainer);
|
fileContainers.add(fileContainer);
|
||||||
widget.controller.addFile = fileContainer;
|
widget.controller!.addFile = fileContainer;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
_fileRemove(DisplayImageSource fileContainer) {
|
_fileRemove(DisplayImageSource fileContainer) {
|
||||||
setState(() {
|
setState(() {
|
||||||
widget.controller.removeFile = fileContainer;
|
widget.controller!.removeFile = fileContainer;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -232,11 +232,11 @@ class _MultiImageFileState extends State<MultiImageFile> {
|
|||||||
context,
|
context,
|
||||||
MaterialPageRoute(
|
MaterialPageRoute(
|
||||||
builder: (context) => ShowImage(
|
builder: (context) => ShowImage(
|
||||||
imageFile: fileContainer.file,
|
imageFile: fileContainer.file!,
|
||||||
url: fileContainer.file == null
|
url: fileContainer.file == null
|
||||||
? fileContainer.url
|
? fileContainer.url!
|
||||||
: null,
|
: '',
|
||||||
fileName: widget.title)),
|
fileName: widget.title!)),
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
child: Chip(
|
child: Chip(
|
||||||
@@ -249,7 +249,7 @@ class _MultiImageFileState extends State<MultiImageFile> {
|
|||||||
deleteIcon: Icon(
|
deleteIcon: Icon(
|
||||||
Icons.close,
|
Icons.close,
|
||||||
),
|
),
|
||||||
label: Text(widget.title + " - ${index + 1}"),
|
label: Text("${widget.title}" + " - ${index + 1}"),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@@ -308,7 +308,7 @@ class _MultiImageFileState extends State<MultiImageFile> {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget actionIcon({OnTap onTap, Color color, IconData iconData}) {
|
Widget actionIcon({OnTap? onTap, Color? color, IconData? iconData}) {
|
||||||
return InkWell(
|
return InkWell(
|
||||||
onTap: onTap,
|
onTap: onTap,
|
||||||
child: ClipOval(
|
child: ClipOval(
|
||||||
|
|||||||
@@ -5,9 +5,9 @@ import 'package:fcs/helpers/theme.dart' as theme;
|
|||||||
class NumberCell extends StatelessWidget {
|
class NumberCell extends StatelessWidget {
|
||||||
final int number;
|
final int number;
|
||||||
final numberFormatter;
|
final numberFormatter;
|
||||||
final TextStyle textStyle;
|
final TextStyle? textStyle;
|
||||||
|
|
||||||
NumberCell(this.number, {Key key, this.textStyle})
|
NumberCell(this.number, {Key? key, this.textStyle})
|
||||||
: numberFormatter = new NumberFormat("#,###"),
|
: numberFormatter = new NumberFormat("#,###"),
|
||||||
super(key: key);
|
super(key: key);
|
||||||
|
|
||||||
|
|||||||
@@ -6,14 +6,14 @@ import 'package:provider/provider.dart';
|
|||||||
|
|
||||||
class OfflineRedirect extends StatefulWidget {
|
class OfflineRedirect extends StatefulWidget {
|
||||||
final Widget child;
|
final Widget child;
|
||||||
OfflineRedirect({@required this.child});
|
OfflineRedirect({required this.child});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
_OfflineRedirectState createState() => _OfflineRedirectState();
|
_OfflineRedirectState createState() => _OfflineRedirectState();
|
||||||
}
|
}
|
||||||
|
|
||||||
class _OfflineRedirectState extends State<OfflineRedirect> {
|
class _OfflineRedirectState extends State<OfflineRedirect> {
|
||||||
Timer offlineTimer;
|
Timer? offlineTimer;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
@@ -27,7 +27,7 @@ class _OfflineRedirectState extends State<OfflineRedirect> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
_startOfflineTimer() async {
|
_startOfflineTimer() async {
|
||||||
if (offlineTimer != null && offlineTimer.isActive) return;
|
if (offlineTimer != null && offlineTimer!.isActive) return;
|
||||||
var _duration = new Duration(milliseconds: 500);
|
var _duration = new Duration(milliseconds: 500);
|
||||||
this.offlineTimer = new Timer.periodic(_duration, offlineNav);
|
this.offlineTimer = new Timer.periodic(_duration, offlineNav);
|
||||||
}
|
}
|
||||||
@@ -41,7 +41,7 @@ class _OfflineRedirectState extends State<OfflineRedirect> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void dispose() {
|
void dispose() {
|
||||||
offlineTimer.cancel();
|
offlineTimer!.cancel();
|
||||||
super.dispose();
|
super.dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -11,10 +11,10 @@ import 'package:flutter_pdfview/flutter_pdfview.dart';
|
|||||||
import 'package:share/share.dart';
|
import 'package:share/share.dart';
|
||||||
|
|
||||||
class PDFScreen extends StatefulWidget {
|
class PDFScreen extends StatefulWidget {
|
||||||
final String title;
|
final String? title;
|
||||||
final String url;
|
final String? url;
|
||||||
|
|
||||||
PDFScreen({Key key, this.url, this.title}) : super(key: key);
|
PDFScreen({Key? key, this.url, this.title}) : super(key: key);
|
||||||
|
|
||||||
_PDFScreenState createState() => _PDFScreenState();
|
_PDFScreenState createState() => _PDFScreenState();
|
||||||
}
|
}
|
||||||
@@ -33,10 +33,10 @@ class _PDFScreenState extends State<PDFScreen> with WidgetsBindingObserver {
|
|||||||
download();
|
download();
|
||||||
}
|
}
|
||||||
|
|
||||||
File file;
|
File? file;
|
||||||
Future<void> download() async {
|
Future<void> download() async {
|
||||||
try {
|
try {
|
||||||
File f = await PdfCacheMgr.pdfs.getSingleFile(widget.url);
|
File f = await PdfCacheMgr.pdfs.getSingleFile(widget.url!);
|
||||||
setState(() {
|
setState(() {
|
||||||
file = f;
|
file = f;
|
||||||
});
|
});
|
||||||
@@ -89,23 +89,23 @@ class _PDFScreenState extends State<PDFScreen> with WidgetsBindingObserver {
|
|||||||
fitPolicy: FitPolicy.BOTH,
|
fitPolicy: FitPolicy.BOTH,
|
||||||
preventLinkNavigation:
|
preventLinkNavigation:
|
||||||
false, // if set to true the link is handled in flutter
|
false, // if set to true the link is handled in flutter
|
||||||
onRender: (_pages) {
|
onRender: (int?_pages) {
|
||||||
print(('pages => $pages'));
|
print(('pages => $pages'));
|
||||||
setState(() {
|
setState(() {
|
||||||
pages = _pages;
|
pages = _pages!;
|
||||||
isReady = true;
|
isReady = true;
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
onViewCreated: (PDFViewController pdfViewController) {
|
onViewCreated: (PDFViewController pdfViewController) {
|
||||||
_controller.complete(pdfViewController);
|
_controller.complete(pdfViewController);
|
||||||
},
|
},
|
||||||
onLinkHandler: (String uri) {
|
onLinkHandler: (String? uri) {
|
||||||
print('goto uri: $uri');
|
print('goto uri: $uri');
|
||||||
},
|
},
|
||||||
onPageChanged: (int page, int total) {
|
onPageChanged: (int? page, int? total) {
|
||||||
print('page change: $page/$total');
|
print('page change: $page/$total');
|
||||||
setState(() {
|
setState(() {
|
||||||
currentPage = page;
|
currentPage = page!;
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
@@ -116,8 +116,8 @@ class _PDFScreenState extends State<PDFScreen> with WidgetsBindingObserver {
|
|||||||
}
|
}
|
||||||
|
|
||||||
_share() async {
|
_share() async {
|
||||||
final RenderBox box = context.findRenderObject();
|
final RenderBox box = context.findRenderObject() as RenderBox;
|
||||||
await Share.shareFiles([file.path],
|
await Share.shareFiles([file!.path],
|
||||||
mimeTypes: ["application/pdf"],
|
mimeTypes: ["application/pdf"],
|
||||||
subject: "File",
|
subject: "File",
|
||||||
sharePositionOrigin: box.localToGlobal(Offset.zero) & box.size);
|
sharePositionOrigin: box.localToGlobal(Offset.zero) & box.size);
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
class PopupMenu {
|
class PopupMenu {
|
||||||
int id;
|
int id;
|
||||||
String status;
|
String status;
|
||||||
PopupMenu({this.id, this.status});
|
PopupMenu({required this.id, required this.status});
|
||||||
}
|
}
|
||||||
|
|
||||||
List<PopupMenu> menuPopup = <PopupMenu>[
|
List<PopupMenu> menuPopup = <PopupMenu>[
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import 'package:provider/provider.dart';
|
|||||||
import 'package:fcs/helpers/theme.dart';
|
import 'package:fcs/helpers/theme.dart';
|
||||||
|
|
||||||
class LocalProgress extends Progress {
|
class LocalProgress extends Progress {
|
||||||
LocalProgress({bool inAsyncCall, Widget child})
|
LocalProgress({required bool inAsyncCall, required Widget child})
|
||||||
: super(
|
: super(
|
||||||
inAsyncCall: inAsyncCall,
|
inAsyncCall: inAsyncCall,
|
||||||
child: child,
|
child: child,
|
||||||
|
|||||||
@@ -6,12 +6,12 @@ import 'package:flutter/material.dart';
|
|||||||
import 'package:photo_view/photo_view.dart';
|
import 'package:photo_view/photo_view.dart';
|
||||||
|
|
||||||
class ShowImage extends StatefulWidget {
|
class ShowImage extends StatefulWidget {
|
||||||
final String url;
|
final String? url;
|
||||||
final File imageFile;
|
final File? imageFile;
|
||||||
final String fileName;
|
final String? fileName;
|
||||||
final String localImage;
|
final String? localImage;
|
||||||
const ShowImage(
|
const ShowImage(
|
||||||
{Key key, this.imageFile, this.fileName, this.url, this.localImage})
|
{Key? key, this.imageFile, this.fileName, this.url, this.localImage})
|
||||||
: super(key: key);
|
: super(key: key);
|
||||||
@override
|
@override
|
||||||
_ShowImageState createState() => _ShowImageState();
|
_ShowImageState createState() => _ShowImageState();
|
||||||
@@ -20,6 +20,13 @@ class ShowImage extends StatefulWidget {
|
|||||||
class _ShowImageState extends State<ShowImage> {
|
class _ShowImageState extends State<ShowImage> {
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
|
final ImageProvider<Object>? p;
|
||||||
|
if (widget.imageFile != null) {
|
||||||
|
p = FileImage(widget.imageFile!);
|
||||||
|
} else {
|
||||||
|
p = AssetImage(widget.localImage!);
|
||||||
|
}
|
||||||
|
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
appBar: AppBar(
|
appBar: AppBar(
|
||||||
leading: new IconButton(
|
leading: new IconButton(
|
||||||
@@ -35,11 +42,7 @@ class _ShowImageState extends State<ShowImage> {
|
|||||||
backgroundDecoration: const BoxDecoration(
|
backgroundDecoration: const BoxDecoration(
|
||||||
color: primaryColor,
|
color: primaryColor,
|
||||||
),
|
),
|
||||||
imageProvider: widget.url != null
|
imageProvider: widget.url != null ? NetworkImage(widget.url!) : p,
|
||||||
? NetworkImage(widget.url)
|
|
||||||
: widget.imageFile != null
|
|
||||||
? FileImage(widget.imageFile)
|
|
||||||
: AssetImage(widget.localImage),
|
|
||||||
minScale: PhotoViewComputedScale.contained * 1)),
|
minScale: PhotoViewComputedScale.contained * 1)),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user