• Ian Hickson's avatar
    ImageIcon (#4649) · e502e9c8
    Ian Hickson authored
    Anywhere that accepted IconData now accepts either an Icon or an
    ImageIcon.
    
    Places that used to take an IconData in an `icon` argument, notably
    IconButton and DrawerItem, now take a Widget in that slot. You can wrap
    the value that used to be passed in in an Icon constructor to get the
    same result.
    
    Icon itself now takes the icon as a positional argument, for brevity.
    
    ThemeData now has an iconTheme as well as a primaryIconTheme, the same
    way it has had a textTheme and primaryTextTheme for a while.
    
    IconTheme.of() always returns a value now (though that value itself may
    have nulls in it). It defaults to the ThemeData.iconTheme.
    
    IconThemeData.fallback() is a new method that returns an icon theme data
    structure with all fields filled in.
    
    IconTheme.merge() is a new constructor that takes a context and creates
    a widget that mixes in the new values with the inherited values.
    
    Most places that introduced an IconTheme widget now use IconTheme.merge.
    
    IconThemeData.merge and IconThemeData.copyWith act in a way analogous to
    the similarly-named members of TextStyle.
    
    ImageIcon is introduced. It acts like Icon but takes an ImageProvider
    instead of an IconData.
    
    Also: Fix the analyzer to actually check the stocks app.
    e502e9c8
tooltip_demo.dart 2.16 KB
// Copyright 2016 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

import 'package:flutter/material.dart';

const String _introText =
  "Tooltips are short identifying messages that briefly appear in response to "
  "a long press. Tooltip messages are also used by services that make Flutter "
  "apps accessible, like screen readers.";

class TooltipDemo extends StatelessWidget {

  static const String routeName = '/tooltips';

  @override
  Widget build(BuildContext context) {
    final ThemeData theme = Theme.of(context);
    return new Scaffold(
      appBar: new AppBar(
        title: new Text('Tooltips')
      ),
      body: new Builder(
        builder: (BuildContext context) {
          return new Block(
            children: <Widget>[
              new Text(_introText, style: theme.textTheme.subhead),
              new Row(
                children: <Widget>[
                  new Text('Long press the ', style: theme.textTheme.subhead),
                  new Tooltip(
                    message: 'call icon',
                    child: new Icon(
                      Icons.call,
                      size: 18.0,
                      color: theme.primaryColor
                    )
                  ),
                  new Text(' icon.', style: theme.textTheme.subhead)
                ]
              ),
              new Center(
                child: new IconButton(
                  size: 48.0,
                  icon: new Icon(Icons.call),
                  color: theme.primaryColor,
                  tooltip: 'Place a phone call',
                  onPressed: () {
                    Scaffold.of(context).showSnackBar(new SnackBar(
                       content: new Text('That was an ordinary tap.')
                    ));
                  }
                )
              )
            ]
            .map((Widget widget) {
              return new Padding(
                padding: const EdgeInsets.only(top: 16.0, left: 16.0, right: 16.0),
                child: widget
              );
            })
            .toList()
          );
        }
      )
    );
  }
}