Welcome, guest! Login / Register - Why register?
Psst.. new poll here.
Psst.. new forums here.
Microsoft is blocking us again (TY IP Reputation!) so just use oauth login instead. :)

Paste

Pasted as Dart by nur ( 3 years ago )
import 'package:lms_flutter_app/core/l10n/app_localizations.dart';
import 'package:lms_flutter_app/presentation/pages/profile/qicscus/qiscus_consumer_page.dart';
import 'package:lms_flutter_app/core/core.dart';
import 'package:lms_flutter_app/core/environment/environment.dart';
import 'package:flutter/material.dart';
import 'package:qiscus_multichannel_widget/qiscus_multichannel_widget.dart';

class QiscusProviderPage extends StatefulWidget {
  const QiscusProviderPage({Key? key}) : super(key: key);

  @override
  State<QiscusProviderPage> createState() => _QiscusProviderPageState();
}

class NavObserver extends NavigatorObserver {
  @override
  void didPop(Route route, Route? previousRoute) {
    super.didPop(route, previousRoute);
  }

  @override
  void didPush(Route route, Route? previousRoute) {
    super.didPush(route, previousRoute);
  }
}

class _QiscusProviderPageState extends State<QiscusProviderPage> {
  final navKey = GlobalKey<NavigatorState>(debugLabel: 'NavKey');

  @override
  Widget build(BuildContext context) {
    return QMultichannelProvider(
      appId: Environment.qiscusAppId,
      channelId: '126276',
      title: 'Pintar Support',
      avatar: const QAvatarConfig.disabled(),
      theme: QAppTheme(
          baseColor: ColorConstants.white,
          navigationColor: ColorConstants.white,
          navigationTitleColor: ColorConstants.jetBlack,
          rightBubbleColor: ColorConstants.greyBubbleRight,
          rightBubbleTextColor: ColorConstants.white,
          leftBubbleColor: ColorConstants.greyBubbleLeft,
          leftBubbleTextColor: ColorConstants.greyTextBubbleLeft,
          sendContainerColor: Colors.grey),
      builder: (ctx) {
        return MaterialApp(
          home: WillPopScope(
            onWillPop: () async {
              return !(await navKey.currentState!.maybePop());
            },
            child: QMultichannelConsumer(
              builder: (context, ref) {
                var roomId = ref.roomId;
                ref.enableDebugMode(false);

                return Navigator(
                  key: navKey,
                  onGenerateRoute: (_) => null,
                  pages: [
                    QiscusConsumerPage(
                        AppLocalizations.of(ctx)!.load_chat_message),
                    if (roomId != null) //
                      QChatRoomPage((e) {
                        ref.clearUser();
                      }),
                  ],
                  observers: [
                    NavObserver(),
                  ],
                  onPopPage: (route, result) => route.didPop(result),
                );
              },
            ),
          ),
        );
      },
    );
  }
}

 

Revise this Paste

Your Name: Code Language: