forked from cwtch.im/cwtch-ui
Fix NPE Exception in Double Col View During Notification Swtiching
This commit is contained in:
parent
be26d40176
commit
f585122f57
|
@ -18,6 +18,7 @@ class _DoubleColumnViewState extends State<DoubleColumnView> {
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
var flwtch = Provider.of<AppState>(context);
|
var flwtch = Provider.of<AppState>(context);
|
||||||
|
var selectedConversation = flwtch.selectedConversation;
|
||||||
var cols = Provider.of<Settings>(context).uiColumns(true);
|
var cols = Provider.of<Settings>(context).uiColumns(true);
|
||||||
return Flex(
|
return Flex(
|
||||||
direction: Axis.horizontal,
|
direction: Axis.horizontal,
|
||||||
|
@ -30,7 +31,7 @@ class _DoubleColumnViewState extends State<DoubleColumnView> {
|
||||||
),
|
),
|
||||||
Flexible(
|
Flexible(
|
||||||
flex: cols[1],
|
flex: cols[1],
|
||||||
child: flwtch.selectedConversation == null
|
child: selectedConversation == null
|
||||||
? Container(
|
? Container(
|
||||||
color: Provider.of<Settings>(context).theme.backgroundMainColor,
|
color: Provider.of<Settings>(context).theme.backgroundMainColor,
|
||||||
child: Card(
|
child: Card(
|
||||||
|
@ -40,9 +41,10 @@ class _DoubleColumnViewState extends State<DoubleColumnView> {
|
||||||
: //dev
|
: //dev
|
||||||
MultiProvider(providers: [
|
MultiProvider(providers: [
|
||||||
ChangeNotifierProvider.value(value: Provider.of<ProfileInfoState>(context)),
|
ChangeNotifierProvider.value(value: Provider.of<ProfileInfoState>(context)),
|
||||||
ChangeNotifierProvider.value(
|
// there is a potential timing issue here where selectConversation is changes as we move profiles, this will result
|
||||||
value: flwtch.selectedConversation != null ? Provider.of<ProfileInfoState>(context).contactList.getContact(flwtch.selectedConversation!)! : ContactInfoState("", -1, "")),
|
// in getContact being null, in that case we replace with an empty Contact Info State
|
||||||
], child: Container(key: Key(flwtch.selectedConversation!.toString()), child: MessageView())),
|
ChangeNotifierProvider.value(value: Provider.of<ProfileInfoState>(context).contactList.getContact(selectedConversation) ?? ContactInfoState("", -1, "")),
|
||||||
|
], child: Container(key: Key(selectedConversation.toString()), child: MessageView())),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
|
|
Loading…
Reference in New Issue