Created
October 30, 2019 09:56
-
-
Save beijaflor/bcb3756e072d6598b63883f107f060ab to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ドロワーを追加する1 | |
drawer: MyNavigationDrawer(), | |
// ドロワーを追加する2 | |
class MyNavigationDrawer extends Drawer { | |
@override | |
Widget build(BuildContext context) { | |
return Drawer( | |
child: ListView( | |
padding: EdgeInsets.zero, | |
children: <Widget>[ | |
DrawerHeader( | |
child: Text('Drawer Header'), | |
decoration: BoxDecoration( | |
color: Colors.blue, | |
), | |
), | |
ListTile( | |
title: Text('Item 1'), | |
onTap: () { | |
// Update the state of the app. | |
// ... | |
Navigator.pop(context); | |
}, | |
), | |
ListTile( | |
title: Text('Item 2'), | |
onTap: () { | |
// Update the state of the app. | |
// ... | |
Navigator.pop(context); | |
}, | |
), | |
], | |
), | |
); | |
} | |
} | |
// モジュールを試してみる1。ブラウザ起動 | |
// pubspec.yaml に以下を追加して flutter pub get | |
/* | |
url_launcher: ^5.2.1 | |
*/ | |
import 'package:url_launcher/url_launcher.dart'; | |
void _launchUrl() async { | |
const url = 'https://wowma.jp'; | |
if (await canLaunch(url)) { | |
await launch(url); | |
} else { | |
throw 'Could not launch $url'; | |
} | |
} | |
// モジュールを試してみる2。カラーピッカー 1/2 - 画面の真ん中に色のついた丸を置く | |
Align( | |
child: Container( | |
height: 100, | |
width: 100, | |
margin: EdgeInsets.only(top: 40, left: 40, right: 40), | |
decoration: new BoxDecoration( | |
color: _color, | |
border: Border.all(color: Colors.black, width: 0.0), | |
borderRadius: new BorderRadius.all(Radius.elliptical(100, 100)), | |
), | |
child: Text(' '), | |
), | |
) | |
// モジュールを試してみる2。カラーピッカー 2/2 - カラーピッカーモジュールで選んだ色を反映する | |
// まず pubspec.yaml に以下を追加して flutter pub get | |
/* | |
flutter_colorpicker: ^0.2.6 | |
*/ | |
import 'package:flutter_colorpicker/flutter_colorpicker.dart'; | |
Color _color = Colors.blue; | |
Color _pickerColor = Color(0xff443a49); | |
void changeColor(Color color) { | |
setState(() => _pickerColor = color); | |
} | |
void _showColorPicker() { | |
showDialog( | |
context: context, | |
child: AlertDialog( | |
title: const Text('Pick a color!'), | |
content: SingleChildScrollView( | |
child: ColorPicker( | |
pickerColor: _pickerColor, | |
onColorChanged: changeColor, | |
enableLabel: true, | |
pickerAreaHeightPercent: 0.8, | |
), | |
), | |
actions: <Widget>[ | |
FlatButton( | |
child: const Text('Got it'), | |
onPressed: () { | |
setState(() => _color = _pickerColor); | |
Navigator.of(context).pop(); | |
}, | |
), | |
], | |
), | |
); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment