text
stringlengths 1
372
|
---|
<code_start> |
CupertinoButton( |
onPressed: () async { |
await launchUrl( |
uri.parse('https://google.com'), |
); |
}, |
child: const text( |
'open website', |
), |
), |
<code_end> |
<topic_end> |
<topic_start> |
themes, styles, and media |
you can style flutter apps with little effort. |
styling includes switching between light and dark themes, |
changing the design of your text and UI components, |
and more. this section covers how to style your apps. |
<topic_end> |
<topic_start> |
using dark mode |
in SwiftUI, you call the preferredColorScheme() |
function on a view to use dark mode. |
in flutter, you can control light and dark mode at the app-level. |
to control the brightness mode, use the theme property |
of the app class: |
<code_start> |
CupertinoApp( |
theme: CupertinoThemeData( |
brightness: brightness.dark, |
), |
home: HomePage(), |
); |
<code_end> |
<topic_end> |
<topic_start> |
styling text |
in SwiftUI, you use modifier functions to style text. |
for example, to change the font of a text string, |
use the font() modifier: |
to style text in flutter, add a TextStyle widget as the value |
of the style parameter of the text widget. |
<code_start> |
text( |
'hello, world!', |
style: TextStyle( |
fontSize: 30, |
fontWeight: FontWeight.bold, |
color: CupertinoColors.systemYellow, |
), |
), |
<code_end> |
<topic_end> |
<topic_start> |
styling buttons |
in SwiftUI, you use modifier functions to style buttons. |
to style button widgets in flutter, set the style of its child, |
or modify properties on the button itself. |
in the following example: |
<code_start> |
child: CupertinoButton( |
color: CupertinoColors.systemYellow, |
onPressed: () {}, |
padding: const EdgeInsets.all(16), |
child: const text( |
'do something', |
style: TextStyle( |
color: CupertinoColors.systemBlue, |
fontSize: 30, |
fontWeight: FontWeight.bold, |
), |
), |
), |
<code_end> |
<topic_end> |
<topic_start> |
using custom fonts |
in SwiftUI, you can use a custom font in your app in two steps. |
first, add the font file to your SwiftUI project. after adding the file, |
use the .font() modifier to apply it to your UI components. |
in flutter, you control your resources with a file |
named pubspec.yaml. this file is platform agnostic. |
to add a custom font to your project, follow these steps: |
add your custom font(s) under the fonts section. |
after you add the font to your project, you can use it as in the |
following example: |
<code_start> |
text( |
'cupertino', |
style: TextStyle( |
fontSize: 40, |
fontFamily: 'bungeespice', |
), |
) |
<code_end> |
info note |
to download custom fonts to use in your apps, |
check out google fonts. |
<topic_end> |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.