Package selection guidance compiled from public package information, community data, and project usage.
A Flutter package that provides a representation and implementation of Telegram Web App and Mini Apps APIs, enabling seamless integration with Telegram's web-based applications. It allows developers to access Telegram-specific functionalities such as user data, theme settings, and deep linking within Flutter web apps. The package is designed for use in web environments and supports the full range of Telegram Mini App features through Dart interfaces.
Use cases
Integrating Flutter web apps with Telegram
Building Telegram Mini Apps
Accessing Telegram user and theme data
Enabling deep linking in Telegram
Creating interactive web experiences within Telegram
Key features
Telegram Web App API bindings
Theme and user data access
Deep linking support
Web platform only
Simple Dart interface
Suitable for
Flutter developers building Telegram Mini Apps
Web app creators targeting Telegram users
Apps requiring Telegram-specific integrations
Considerations
Limited to web platform
Requires Telegram environment
No support for mobile or desktop
Depends on Telegram Web App context
Not suitable for standalone web apps
Original README
Original README snapshot from the linked source repository. Visit the repository for the latest content.
Telegram Web App
Build telegram web apps in flutter using telegram_web_app library
Checkout details of available telegram_web apis here
You can also find detailed examples in example project.
Setup for development
Enable debugging in telegram web app. Checkout this post for more details
Then navigate to \example folder
Deploy the example app via firebase or any other hosting service. You can find firebase hosting documentation here
Create web app in telegram
Use the website url to load the webapp in telegram
You can also inspect the app with Javascript logs via debugging as described here
For more info and support, you can join telegram group flutter_telegram
Here is an article on how to deploy web to Firebase and link to Telegram web app 👉 Telegram Mini Apps
How to use
There is a class TelegramWebApp which contains all the telegram web apis. You can call the methods via TelegramWebApp.instance
You can also mock TelegramWebApp by extending it if you are trying to test outside telegram platform. Alternatively, TelegramWebAppFake object can also be used for the same purpose.
Example
// current telegram versionText(TelegramWebApp.instance.version)
// telegram colors associated with the user's appText(TelegramWebApp.instance.themeParams)
// Object containing user details and user validation hashText(TelegramWebApp.instance.initData.toString())
You can find full list of api examples in example folder. Please feel free to contribute for improvements and any updates.
Note
All the apis are only available inside telegram web app. You can't use the apis outside the platform.
In Android, Web App is sometimes not loading (only grey/white screen showing up). If this happens to you, there is a 'hacky' workaround. You can also find it in example app:
voidmain() async {
try {
if (TelegramWebApp.instance.isSupported) {
TelegramWebApp.instance.ready();
Future.delayed(constDuration(seconds: 1), TelegramWebApp.instance.expand);
}
} catch (e) {
print("Error happened in Flutter while loading Telegram $e");
// add delay for 'Telegram seldom not loading' bugawaitFuture.delayed(constDuration(milliseconds: 200));
main();
return;
}
FlutterError.onError = (details) {
print("Flutter error happened: $details");
};
runApp(constMyApp());
}