Platforms and setup
Native platforms: ios, android.
Public actions
Twitter.open
factory Twitter.open({final bool fallbackToStore = false})
Launch with DeeplinkX.launchApp. Native platforms: ios, android. Action web fallback: available. Store-fallback flag: supported; opt in explicitly.
| Parameter | Type | Required | Default |
|---|---|---|---|
fallbackToStore | bool | No | false |
Twitter.openProfile
static TwitterOpenProfileAction openProfile({ required final String username, final bool fallbackToStore = false, })
Launch with DeeplinkX.launchAction. Native platforms: ios, android. Action web fallback: available. Store-fallback flag: supported; opt in explicitly.
| Parameter | Type | Required | Default |
|---|---|---|---|
username | String | Yes | — |
fallbackToStore | bool | No | false |
Twitter.openTweet
static TwitterOpenTweetAction openTweet({ required final String tweetId, final bool fallbackToStore = false, })
Launch with DeeplinkX.launchAction. Native platforms: ios, android. Action web fallback: available. Store-fallback flag: supported; opt in explicitly.
| Parameter | Type | Required | Default |
|---|---|---|---|
tweetId | String | Yes | — |
fallbackToStore | bool | No | false |
Twitter.search
static TwitterSearchAction search({ required final String query, final bool fallbackToStore = false, })
Launch with DeeplinkX.launchAction. Native platforms: ios, android. Action web fallback: available. Store-fallback flag: supported; opt in explicitly.
| Parameter | Type | Required | Default |
|---|---|---|---|
query | String | Yes | — |
fallbackToStore | bool | No | false |
Provider setup and examples
DeeplinkX provides comprehensive support for Twitter deep linking actions.
Available Actions
Launch Twitter App
final deeplinkX = DeeplinkX();
// Simple launch
await deeplinkX.launchApp(Twitter.open());
// Launch with store fallback if not installed
await deeplinkX.launchApp(Twitter.open(fallbackToStore: true));
// Launch with fallback disabled
await deeplinkX.launchApp(Twitter.open(), disableFallback: true);
Open Profile Action
final deeplinkX = DeeplinkX();
// Simple action
await deeplinkX.launchAction(Twitter.openProfile(username: 'twitter')); // Twitter username
// Action with store fallback if not installed
await deeplinkX.launchAction(Twitter.openProfile(
username: 'twitter', // Twitter username
fallbackToStore: true,
));
// Action with fallback disabled
await deeplinkX.launchAction(
Twitter.openProfile(username: 'twitter'), // Twitter username
disableFallback: true,
);
Open Tweet Action
final deeplinkX = DeeplinkX();
// Simple action
await deeplinkX.launchAction(Twitter.openTweet(tweetId: '1234567890')); // Twitter tweet ID
// Action with store fallback if not installed
await deeplinkX.launchAction(Twitter.openTweet(
tweetId: '1234567890', // Twitter tweet ID
fallbackToStore: true,
));
// Action with fallback disabled
await deeplinkX.launchAction(
Twitter.openTweet(tweetId: '1234567890'), // Twitter tweet ID
disableFallback: true,
);
Search Action
final deeplinkX = DeeplinkX();
// Simple action
await deeplinkX.launchAction(Twitter.search(query: 'flutter')); // Search query
// Action with store fallback if not installed
await deeplinkX.launchAction(Twitter.search(
query: 'flutter', // Search query
fallbackToStore: true,
));
// Action with fallback disabled
await deeplinkX.launchAction(
Twitter.search(query: 'flutter'), // Search query
disableFallback: true,
);
Parameter Validations
Username Validation
Twitter usernames must follow these rules:
- Length: 1-15 characters
- Can contain letters, numbers, and underscores
- Cannot contain spaces or special characters
- Cannot start with a number or underscore
- Cannot end with an underscore
- Cannot contain consecutive underscores
Example valid usernames:
twitterelonmuskflutter_dev
Example invalid usernames:
_twitter(starts with underscore)twitter_(ends with underscore)twitter__dev(consecutive underscores)twitter dev(contains space)twitter@dev(contains special character)
Tweet ID Validation
Twitter tweet IDs must follow these rules:
- Must be a valid numeric string
- Cannot be empty
Platform-Specific Configuration
iOS
Add the following to your ios/Runner/Info.plist:
<key>LSApplicationQueriesSchemes</key>
<array>
<string>twitter</string>
<string>itms-apps</string>
</array>
Android
Add the following to your android/app/src/main/AndroidManifest.xml inside the <queries> tag:
<queries>
<!-- For Twitter app -->
<package android:name="com.twitter.android" />
<!-- For Play Store fallback (if using fallbackToStore) -->
<package android:name="com.android.vending" />
<!-- For web fallback (required) -->
<intent>
<action android:name="android.intent.action.VIEW" />
<data android:scheme="https" />
</intent>
</queries>
URL Schemes
DeeplinkX uses the following URL schemes for Twitter:
Native App Deep Links
When Twitter is installed, the following scheme is used:
twitter://- Native Twitter URL scheme- For profiles:
twitter://user?screen_name={username} - For tweets:
twitter://status?id={tweetId} - For search:
twitter://search?query={query}
Web Fallback URLs
When Twitter is not installed, DeeplinkX automatically falls back to:
https://twitter.com- Official Twitter web URL- For profiles:
https://twitter.com/{username} - For tweets:
https://twitter.com/i/status/{tweetId} - For search:
https://twitter.com/search?q={query}
Supported Fallback Stores
When the Twitter app is not installed, DeeplinkX can redirect users to download Twitter from the following app stores:
- iOS App Store
- Google Play Store
To enable fallback to app stores, use the fallbackToStore parameter:
final deeplinkX = DeeplinkX();
await deeplinkX.launchApp(Twitter.open(fallbackToStore: true));
Fallback Behavior
DeeplinkX follows this sequence when handling Twitter deeplinks:
- First, it attempts to launch the Twitter app if it's installed on the device.
- If the Twitter app is not installed and
fallbackToStoreis set totrue, it will redirect to the appropriate app store based on the user's platform (iOS App Store or Google Play Store). - If no supported store is available for the current platform or the store app cannot be launched, it will fall back to opening the Twitter web interface in the default browser.
- You can disable all fallbacks by setting
disableFallback: truein the launch methods.
Fallback Support for Actions
| Action | Store Fallback | Web Fallback |
|---|---|---|
| open | ✅ | ✅ |
| openProfile | ✅ | ✅ |
| openTweet | ✅ | ✅ |
| search | ✅ | ✅ |
Check If Twitter Is Installed
final deeplinkX = DeeplinkX();
final isInstalled = await deeplinkX.isAppInstalled(Twitter());