text
stringlengths 1
372
|
|---|
for further details on internationalization and localization in flutter,
|
see the internationalization guide, which has sample code
|
with and without the intl package.
|
<topic_end>
|
<topic_start>
|
managing dependencies
|
in iOS, you add dependencies with CocoaPods by adding to your podfile.
|
flutter uses dart’s build system and the pub package manager
|
to handle dependencies. the tools delegate the building of the
|
native android and iOS wrapper apps to the
|
respective build systems.
|
while there is a podfile in the iOS folder in your
|
flutter project, only use this if you are adding native
|
dependencies needed for per-platform integration.
|
in general, use pubspec.yaml to declare external dependencies in flutter.
|
a good place to find great packages for flutter is on pub.dev.
|
<topic_end>
|
<topic_start>
|
ViewControllers
|
this section of the document discusses the equivalent
|
of ViewController in flutter and how to listen to
|
lifecycle events.
|
<topic_end>
|
<topic_start>
|
equivalent of ViewController in flutter
|
in UIKit, a ViewController represents a portion of user interface,
|
most commonly used for a screen or section.
|
these are composed together to build complex user interfaces,
|
and help scale your application’s UI.
|
in flutter, this job falls to widgets.
|
as mentioned in the navigation section,
|
screens in flutter are represented by widgets since
|
“everything is a widget!”
|
use a navigator to move between different routes
|
that represent different screens or pages,
|
or maybe different states or renderings of the same data.
|
<topic_end>
|
<topic_start>
|
listening to lifecycle events
|
in UIKit, you can override methods to the ViewController
|
to capture lifecycle methods for the view itself,
|
or register lifecycle callbacks in the AppDelegate.
|
in flutter, you have neither concept, but you can instead
|
listen to lifecycle events by hooking into
|
the WidgetsBinding observer and listening to
|
the didChangeAppLifecycleState() change event.
|
the observable lifecycle events are:
|
for more details on the meaning of these states, see
|
AppLifecycleState documentation.
|
<topic_end>
|
<topic_start>
|
layouts
|
this section discusses different layouts in flutter
|
and how they compare with UIKit.
|
<topic_end>
|
<topic_start>
|
displaying a list view
|
in UIKit, you might show a list in
|
either a UITableView or a UICollectionView.
|
in flutter, you have a similar implementation using a ListView.
|
in UIKit, these views have delegate methods
|
for deciding the number of rows,
|
the cell for each index path, and the size of the cells.
|
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 {
|
const SampleApp({super.key});
|
// this widget is the root of your application.
|
@override
|
widget build(BuildContext context) {
|
return const MaterialApp(
|
title: 'sample app',
|
home: SampleAppPage(),
|
);
|
}
|
}
|
class SampleAppPage extends StatefulWidget {
|
const SampleAppPage({super.key});
|
@override
|
State<SampleAppPage> createState() => _SampleAppPageState();
|
}
|
class _SampleAppPageState extends State<SampleAppPage> {
|
List<Widget> _getListData() {
|
final List<Widget> widgets = [];
|
for (int i = 0; i < 100; i++) {
|
widgets.add(Padding(
|
padding: const EdgeInsets.all(10),
|
child: Text('Row $i'),
|
));
|
}
|
return widgets;
|
}
|
@override
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.