text
stringlengths 1
372
|
|---|
}
|
@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>
|
listviews and adapters
|
<topic_end>
|
<topic_start>
|
what is the equivalent to a ListView in flutter?
|
the equivalent to a ListView in flutter is … a ListView!
|
in a Xamarin.Forms ListView, you create a ViewCell
|
and possibly a DataTemplateSelectorand pass it into the ListView,
|
which renders each row with what your
|
DataTemplateSelector or ViewCell returns.
|
however, you often have to make sure you turn on cell recycling
|
otherwise you will run into memory issues and slow scrolling speeds.
|
due to flutter’s immutable widget pattern,
|
you pass a list of widgets to your ListView,
|
and flutter takes care of making sure that scrolling is fast and smooth.
|
<code_start>
|
import 'package:flutter/material.dart';
|
void main() {
|
runApp(const SampleApp());
|
}
|
class SampleApp extends StatelessWidget {
|
/// this widget is the root of your application.
|
const SampleApp({super.key});
|
@override
|
widget build(BuildContext context) {
|
return const MaterialApp(
|
title: 'sample app',
|
home: SampleAppPage(),
|
);
|
}
|
}
|
class SampleAppPage extends StatelessWidget {
|
const SampleAppPage({super.key});
|
List<Widget> _getListData() {
|
return List<Widget>.generate(
|
100,
|
(index) => padding(
|
padding: const EdgeInsets.all(10),
|
child: Text('Row $index'),
|
),
|
);
|
}
|
@override
|
widget build(BuildContext context) {
|
return scaffold(
|
appBar: AppBar(title: const Text('Sample app')),
|
body: ListView(children: _getListData()),
|
);
|
}
|
}
|
<code_end>
|
<topic_end>
|
<topic_start>
|
how do i know which list item has been clicked?
|
in Xamarin.Forms, the ListView has an ItemTapped method
|
to find out which item was clicked.
|
there are many other techniques you might have used
|
such as checking when SelectedItem or EventToCommand
|
behaviors change.
|
in flutter, use the touch handling provided by the passed-in widgets.
|
<code_start>
|
import 'dart:developer' as developer;
|
import 'package:flutter/material.dart';
|
void main() {
|
runApp(const SampleApp());
|
}
|
class SampleApp extends StatelessWidget {
|
// this widget is the root of your application.
|
const SampleApp({super.key});
|
@override
|
widget build(BuildContext context) {
|
return const MaterialApp(
|
title: 'sample app',
|
home: SampleAppPage(),
|
);
|
}
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.