text stringlengths 1 372 |
|---|
the following example shows a GestureDetector |
that rotates the flutter logo on a double tap: |
<code_start> |
class SampleApp extends StatefulWidget { |
const SampleApp({super.key}); |
@override |
State<SampleApp> createState() => _SampleAppState(); |
} |
class _SampleAppState extends State<SampleApp> |
with SingleTickerProviderStateMixin { |
late AnimationController controller; |
late CurvedAnimation curve; |
@override |
void initState() { |
super.initState(); |
controller = AnimationController( |
vsync: this, |
duration: const duration(milliseconds: 2000), |
); |
curve = CurvedAnimation( |
parent: controller, |
curve: Curves.easeIn, |
); |
} |
@override |
widget build(BuildContext context) { |
return scaffold( |
body: center( |
child: GestureDetector( |
onDoubleTap: () { |
if (controller.iscompleted) { |
controller.reverse(); |
} else { |
controller.forward(); |
} |
}, |
child: RotationTransition( |
turns: curve, |
child: const FlutterLogo( |
size: 200, |
), |
), |
), |
), |
); |
} |
} |
<code_end> |
<topic_end> |
<topic_start> |
themes, styles, and media |
flutter applications are easy to style; you can switch |
between light and dark themes, |
change the style of your text and UI components, |
and more. this section covers aspects of styling your flutter apps |
and compares how you might do the same in UIKit. |
<topic_end> |
<topic_start> |
using a theme |
out of the box, flutter comes with a beautiful implementation |
of material design, which takes care of a lot of styling and |
theming needs that you would typically do. |
to take full advantage of material components in your app, |
declare a top-level widget, MaterialApp, |
as the entry point to your application. |
MaterialApp is a convenience widget that wraps a number |
of widgets that are commonly required for applications |
implementing material design. |
it builds upon a WidgetsApp by adding material specific functionality. |
but flutter is flexible and expressive enough to implement |
any design language. on iOS, you can use the |
cupertino library to produce an interface that adheres to the |
human interface guidelines. |
for the full set of these widgets, |
see the cupertino widgets gallery. |
you can also use a WidgetsApp as your app widget, |
which provides some of the same functionality, |
but is not as rich as MaterialApp. |
to customize the colors and styles of any child components, |
pass a ThemeData object to the MaterialApp widget. |
for example, in the code below, |
the color scheme from seed is set to deepPurple and divider color is grey. |
<code_start> |
import 'package:flutter/material.dart'; |
class SampleApp extends StatelessWidget { |
const SampleApp({super.key}); |
@override |
widget build(BuildContext context) { |
return MaterialApp( |
title: 'sample app', |
theme: ThemeData( |
colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple), |
dividerColor: colors.grey, |
), |
home: const SampleAppPage(), |
); |
} |
} |
<code_end> |
<topic_end> |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.