Fix StyledToast

This commit is contained in:
Christian Pauly 2020-05-13 10:45:50 +02:00
commit 9f4660bd9f
12 changed files with 74 additions and 79 deletions

View file

@ -6,7 +6,7 @@ import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_localizations/flutter_localizations.dart';
import 'package:flutter_styled_toast/flutter_styled_toast.dart';
import 'package:bot_toast/bot_toast.dart';
import 'l10n/l10n.dart';
import 'components/theme_switcher.dart';
@ -31,47 +31,41 @@ class App extends StatelessWidget {
child: Builder(
// Workaround for: https://github.com/JackJonson/flutter_styled_toast/issues/7
builder: (BuildContext context) => MaterialApp(
home: StyledToast(
duration: Duration(seconds: 5),
child: MaterialApp(
title: 'FluffyChat',
theme: ThemeSwitcherWidget.of(context).themeData,
localizationsDelegates: [
AppLocalizationsDelegate(),
GlobalMaterialLocalizations.delegate,
GlobalWidgetsLocalizations.delegate,
GlobalCupertinoLocalizations.delegate,
],
supportedLocales: [
const Locale('en'), // English
const Locale('de'), // German
const Locale('hu'), // Hungarian
const Locale('pl'), // Polish
],
locale: kIsWeb
? Locale(html.window.navigator.language.split("-").first)
: null,
home: FutureBuilder<LoginState>(
future: Matrix.of(context)
.client
.onLoginStateChanged
.stream
.first,
builder: (context, snapshot) {
if (!snapshot.hasData) {
return Scaffold(
body: Center(
child: CircularProgressIndicator(),
),
);
}
if (Matrix.of(context).client.isLogged()) {
return ChatListView();
}
return HomeserverPicker();
},
),
),
title: 'FluffyChat',
builder: BotToastInit(),
navigatorObservers: [BotToastNavigatorObserver()],
theme: ThemeSwitcherWidget.of(context).themeData,
localizationsDelegates: [
AppLocalizationsDelegate(),
GlobalMaterialLocalizations.delegate,
GlobalWidgetsLocalizations.delegate,
GlobalCupertinoLocalizations.delegate,
],
supportedLocales: [
const Locale('en'), // English
const Locale('de'), // German
const Locale('hu'), // Hungarian
const Locale('pl'), // Polish
],
locale: kIsWeb
? Locale(html.window.navigator.language.split("-").first)
: null,
home: FutureBuilder<LoginState>(
future:
Matrix.of(context).client.onLoginStateChanged.stream.first,
builder: (context, snapshot) {
if (!snapshot.hasData) {
return Scaffold(
body: Center(
child: CircularProgressIndicator(),
),
);
}
if (Matrix.of(context).client.isLogged()) {
return ChatListView();
}
return HomeserverPicker();
},
),
),
),