@@ -38,7 +38,7 @@ Add following dependencies and fonts for `SendbirdIcons` in `pubspec.yaml`.
3838
3939``` yaml
4040dependencies :
41- sendbird_uikit : ^1.0.0
41+ sendbird_uikit : ^1.0.1
4242 sendbird_chat_sdk : ^4.2.30
4343
4444flutter :
@@ -64,12 +64,7 @@ void main() async {
6464 await SendbirdUIKit.init(appId: 'YOUR_APP_ID');
6565 await SendbirdUIKit.connect('YOUR_USER_ID');
6666
67- runApp(SendbirdUIKit.provider(
68- child: const MaterialApp(
69- debugShowCheckedModeBanner: false,
70- home: MyApp(), // This class will be implemented below.
71- ),
72- ));
67+ runApp(const MyApp());
7368}
7469` ` `
7570
@@ -81,6 +76,27 @@ You can easily add `SBUGroupChannelListScreen`, `SBUGroupChannelCreateScreen` an
8176class MyApp extends StatelessWidget {
8277 const MyApp({super.key});
8378
79+ @override
80+ Widget build(BuildContext context) {
81+ return MaterialApp(
82+ debugShowCheckedModeBanner: false,
83+ builder: (context, child) {
84+ return SendbirdUIKit.provider(
85+ child: Navigator(
86+ onGenerateRoute: (settings) => MaterialPageRoute(
87+ builder: (context) => child!,
88+ ),
89+ ),
90+ );
91+ },
92+ home: const HomeScreen(), // Separate screen widget
93+ );
94+ }
95+ }
96+
97+ class HomeScreen extends StatelessWidget {
98+ const HomeScreen({super.key});
99+
84100 @override
85101 Widget build(BuildContext context) {
86102 return Scaffold(
@@ -98,29 +114,35 @@ class MyApp extends StatelessWidget {
98114 }
99115
100116 void moveToGroupChannelCreateScreen(BuildContext context) {
101- Navigator.of(context).push(MaterialPageRoute(
102- builder: (_) => Scaffold(
103- body: SafeArea(
104- child: SBUGroupChannelCreateScreen(
105- onChannelCreated: (channel) {
106- moveToGroupChannelScreen(context, channel.channelUrl);
107- },
117+ Navigator.push(
118+ context,
119+ MaterialPageRoute(
120+ builder: (context) => Scaffold(
121+ body: SafeArea(
122+ child: SBUGroupChannelCreateScreen(
123+ onChannelCreated: (channel) {
124+ moveToGroupChannelScreen(context, channel.channelUrl);
125+ },
126+ ),
108127 ),
109128 ),
110129 ),
111- )) ;
130+ );
112131 }
113132
114133 void moveToGroupChannelScreen(BuildContext context, String channelUrl) {
115- Navigator.of(context).push(MaterialPageRoute(
116- builder: (_) => Scaffold(
117- body: SafeArea(
118- child: SBUGroupChannelScreen(
119- channelUrl: channelUrl,
134+ Navigator.push(
135+ context,
136+ MaterialPageRoute(
137+ builder: (context) => Scaffold(
138+ body: SafeArea(
139+ child: SBUGroupChannelScreen(
140+ channelUrl: channelUrl,
141+ ),
120142 ),
121143 ),
122144 ),
123- )) ;
145+ );
124146 }
125147}
126148` ` `
0 commit comments