分类标签归档:Flutter

flutter插件url_launcher


用于在移动平台中启动URL的Flutter插件。支持iOS和Android。

添加依赖

dependencies:
  url_launcher: ^5.0.1

安装

$ flutter packages get

实例

import 'package:flutter/material.dart';
import 'package:url_launcher/url_launcher.dart';

void main() {
  runApp(Scaffold(
    body: Center(
      child: RaisedButton(
   ...

阅读全文...

flutter 插件shared_preferences


封装iOS上的NSUserDefaults和Android上的SharedPreferences,为简单数据提供持久存储。数据以异步方式持久保存到磁盘。这两个平台都不能保证在返回后写入将持久保存到磁盘,并且此插件不能用于存储关键数据。

添加依赖

dependencies:
  shared_preferences: ^0.5.1+1

安装

flutter packages get

导入

import 'package:shared_preferences/shared_preferences.dart';

实例

import 'package:flutter/material.d...

阅读全文...

flutter 视频播放插件video_player


添加依赖

dependencies:
  video_player: ^0.10.0+2

安装

flutter packages get

导入

import 'package:video_player/video_player.dart';

iOS

警告:视频播放器在iOS模拟器上无法正常运行。在开发/测试期间必须使用iOS设备。

将以下条目添加到位于<project root> /ios/Runner/Info.plist中的Info.plist文件中:

<key>NSAppTransportSecurity</key>
<d...

阅读全文...

Flutter SelectionControls


import 'package:flutter/material.dart';

import '../../gallery/demo.dart';

const String _checkboxText =
  'Checkboxes allow the user to select multiple options from a set. '
  'A normal checkbox\'s value is true or false and a tristate checkbox\'s '
  '...

阅读全文...

Flutter Overscroll


import 'dart:async';

import 'package:flutter/material.dart';

import '../../gallery/demo.dart';

enum IndicatorType { overscroll, refresh }

class OverscrollDemo extends StatefulWidget {
  const OverscrollDemo({ Key key }) : super(key: key);

  static const String routeNa...

阅读全文...

Flutter ReorderableList


import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart';

import '../../gallery/demo.dart';

enum _ReorderableListType {
  /// A list tile that contains a [CircleAvatar].
  horizontalAvatar,

  /// A...

阅读全文...

Flutter 搜索实例


import 'package:flutter/material.dart';

import '../../gallery/demo.dart';

class SearchDemo extends StatefulWidget {
  static const String routeName = '/material/search';

  @override
  _SearchDemoState createState() => _SearchDemoState();
}

class _SearchDemoState ext...

阅读全文...

Flutter Elevation


import 'package:flutter/material.dart';

import '../../gallery/demo.dart';

class ElevationDemo extends StatefulWidget {
  static const String routeName = '/material/elevation';

  @override
  State<StatefulWidget> createState() => _ElevationDemoState();
}

class ...

阅读全文...

Flutter Backdrop


import 'dart:math' as math;

import 'package:flutter/material.dart';

// 该Demo一次显示一个类别。背景显示了一个列表
// 显示所有类别和所选类别
//(CategoryView)在背景之上。

class Category {
  const Category({ this.title, this.assets });
  final String title;
  final List<String> assets;
  @override
  String toS...

阅读全文...

Flutter MaterialPageRoute


简介

页面跳转携带参数替换整个屏幕的页面路由。

  • 对于Android,页面的进入以下方滑动向上,页面退出,以上方滑动向下方。在ios上,页面进度从右边滑入,退出相反。
  • 默认情况下,当路由器被另外一个替换时,前一个路由将被保留在内存中,如果希望在不需要的时候能够释放资源,请将maintainState设置为false

实例演示

import 'package:flutter/material.dart';

class User {
  final String account, email;

  const User({
    this.account,
    t...

阅读全文...