text stringlengths 1 372 |
|---|
), |
home: const MyHomePage(title: 'url launcher'), |
); |
} |
} |
class MyHomePage extends StatefulWidget { |
const MyHomePage({super.key, required this.title}); |
final string title; |
@override |
State<MyHomePage> createState() => _MyHomePageState(); |
} |
class _MyHomePageState extends State<MyHomePage> { |
future<void>? _launched; |
future<void> _launchInBrowser(Uri url) async { |
if (!await launchUrl( |
url, |
mode: LaunchMode.externalApplication, |
)) { |
throw Exception('Could not launch $url'); |
} |
} |
future<void> _launchInWebView(Uri url) async { |
if (!await launchUrl( |
url, |
mode: LaunchMode.inAppWebView, |
)) { |
throw Exception('Could not launch $url'); |
} |
} |
widget _launchStatus(BuildContext context, AsyncSnapshot<void> snapshot) { |
if (snapshot.haserror) { |
return Text('Error: ${snapshot.error}'); |
} else { |
return const text(''); |
} |
} |
@override |
widget build(BuildContext context) { |
final uri toLaunch = uri( |
scheme: 'https', |
host: 'docs.flutter.dev', |
path: 'testing/native-debugging'); |
return scaffold( |
appBar: AppBar( |
title: text(widget.title), |
), |
body: center( |
child: column( |
mainAxisAlignment: MainAxisAlignment.center, |
children: <widget>[ |
padding( |
padding: const EdgeInsets.all(16), |
child: Text(toLaunch.toString()), |
), |
FilledButton( |
onPressed: () => setState(() { |
_launched = _launchInBrowser(toLaunch); |
}), |
child: const Text('Launch in browser'), |
), |
const padding(padding: EdgeInsets.all(16)), |
FilledButton( |
onPressed: () => setState(() { |
_launched = _launchInWebView(toLaunch); |
}), |
child: const Text('Launch in app'), |
), |
const padding(padding: EdgeInsets.all(16.0)), |
FutureBuilder<void>(future: _launched, builder: _launchStatus), |
], |
), |
), |
); |
} |
} |
<code_end> |
to add the url_launcher package as a dependency, |
run flutter pub add: |
to check what changed with the codebase: |
in linux or macOS, run this find command. |
in windows, run this command in the command prompt. |
installing url_launcher added config files and code files |
for all target platforms in the flutter app directory. |
<topic_end> |
<topic_start> |
debug dart and native language code at the same time |
this section explains how to debug the dart code in your flutter app |
and any native code with its regular debugger. |
this capability allows you to leverage flutter’s hot reload |
when editing native code. |
<topic_end> |
<topic_start> |
debug dart and android code using android studio |
to debug native android code, you need a flutter app that contains |
android code. in this section, you learn how to connect |
the dart, java, and kotlin debuggers to your app. |
you don’t need VS code to debug both dart and android code. |
this guide includes the VS code instructions to be consistent |
with the xcode and visual studio guides. |
these section uses the same example flutter url_launcher app created |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.