GitXplorerGitXplorer
H

flutter_buttons

public
13 stars
4 forks
11 issues

Commits

List of commits on branch master.
Verified
9f069cf081f245328a90c4399b0e949aa3745d18

Merge pull request #7 from HansMuller/v4

HHansMuller committed 5 years ago
Unverified
a4481f1e64fc778cd587db9833112a10d5125ab3

Added ButtonStyle.side

committed 5 years ago
Verified
e415041c4dcf27b976d38e632ea22ccf20550f48

Merge pull request #6 from HansMuller/v3

HHansMuller committed 5 years ago
Unverified
7524da39650998bf4323d8b956cc6c4344889ec9

Updated the README

committed 5 years ago
Verified
af9f4d2bf8caacc8d7a6ff0e90685447b1683615

Merge pull request #5 from HansMuller/v2

HHansMuller committed 5 years ago
Unverified
7c25b5223ee1d2f710831eeb388f6ad7b9a6c77a

Added button.icon factories

committed 5 years ago

README

The README file for this repository.

flutter_buttons

A prototype implementation of the new design for buttons and button themes.

For more information about the design and to provide feedback please visit:

Sample

Here's a trivial example of the new button classes and their themes.

// pubspec.yaml must contain a dependency on the prototype flutter_buttons package
//
//  flutter_buttons:
//    git: git@github.com:HansMuller/flutter_buttons.git

import 'package:flutter/material.dart';

import 'package:flutter_buttons/flutter_buttons.dart';

class Buttons extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Center(
      child: Column(
        mainAxisSize: MainAxisSize.min,
        children: <Widget>[
          TextButton (
            onPressed: () { },
            child: Text('TextButton'),
          ),
          SizedBox(height: 16),
          ContainedButton(
            onPressed: () { print('ContainedButton'); },
            child: Text('ContainedButton'),
          ),
          SizedBox(height: 16),
          OutlinedButton(
            onPressed: () { },
            child: Text('OutlinedButton'),
          ),
        ],
      ),
    );
  }
}

class Home extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    final TextStyle headline4 = Theme.of(context).textTheme.headline4;
    return Scaffold(
      body: TextButtonTheme(
        data: TextButtonThemeData(
          style: TextButton.styleFrom(
            textStyle: headline4,
          ),
        ),
        child: ContainedButtonTheme(
          data: ContainedButtonThemeData(
            style: ContainedButton.styleFrom(
              textStyle: headline4,
            ),
          ),
          child: OutlinedButtonTheme(
            data: OutlinedButtonThemeData(
              style: OutlinedButton.styleFrom(
                textStyle: headline4,
              ),
            ),
            child: Buttons(),
          ),
        ),
      ),
    );
  }
}

void main() {
  runApp(MaterialApp(home: Home()));
}

This is a prototype, so there isn't any integration with the ThemeData class. When the classes in this repo are part of the Flutter framework, the button themes would be created as part of the app's overall theme. Instead of nesting the three button themes, one could write:

MaterialApp(
  home: Home(),
  theme: ThemeData(
    textButtonTheme: TextButtonTheme(
      data: TextButtonThemeData(
        style: TextButton.styleFrom(
          textStyle: headline4,
        ),
      ),
    ),
    containedButtonTheme: containedButtonTheme(
      data: ContainedButtonThemeData(
        style: ContainedButton.styleFrom(
          textStyle: headline4,
        ),
      ),
    ),
    outlinedButtonTheme: OutlinedButtonTheme(
      data: OutlinedButtonThemeData(
        style: OutlinedButton.styleFrom(
          textStyle: headline4,
        ),
      ),
    ),
  ),
)